Skip to main content

MXCL1

state​

struct MXCData.State state

onlyFromEOA​

modifier onlyFromEOA()

init​

function init(address _addressManager, bytes32 _genesisBlockHash, uint256 _feeBase) external

commitBlock​

function commitBlock(uint64 commitSlot, bytes32 commitHash) external

Write a commit hash so a few blocks later a L2 block can be proposed such that calculateCommitHash(meta.beneficiary, meta.txListHash) equals to this commit hash.

Parameters​

NameTypeDescription
commitSlotuint64A slot to save this commit. Slot 0 will always be reset
to zero for refund.
commitHashbytes32Calculated with:
calculateCommitHash(beneficiary, txListHash).

proposeBlock​

function proposeBlock(bytes[] inputs) external

Propose a MXC L2 block.

Parameters​

NameTypeDescription
inputsbytes[]A list of data input:
  • inputs[0] is abi-encoded BlockMetadata that the actual L2 block header must satisfy. Note the following fields in the provided meta object must be zeros -- their actual values will be provisioned by Ethereum.
    • id
    • l1Height
    • l1Hash
    • mixHash
    • timestamp
  • inputs[1] is a list of transactions in this block, encoded with RLP. Note, in the corresponding L2 block an anchor transaction will be the first transaction in the block -- if there are n transactions in txList, then there will be up to n+1 transactions in the L2 block. |

proveBlock​

function proveBlock(uint256 blockId, bytes[] inputs) external

Prove a block is valid with a zero-knowledge proof, a transaction merkel proof, and a receipt merkel proof.

Parameters​

NameTypeDescription
blockIduint256The index of the block to prove. This is also used
to select the right implementation version.
inputsbytes[]A list of data input:
  • inputs[0] is an abi-encoded object with various information regarding the block to be proven and the actual proofs.
  • inputs[1] is the actual anchor transaction in this L2 block. Note that the anchor transaction is always the first transaction in the block.
  • inputs[2] is the receipt of the anchor transaction. |

proveBlockInvalid​

function proveBlockInvalid(uint256 blockId, bytes[] inputs) external

Prove a block is invalid with a zero-knowledge proof and a receipt merkel proof.

Parameters​

NameTypeDescription
blockIduint256The index of the block to prove. This is also used to
select the right implementation version.
inputsbytes[]A list of data input:
  • inputs[0] An Evidence object with various information regarding the block to be proven and the actual proofs.
  • inputs[1] The target block to be proven invalid.
  • inputs[2] The receipt for the invalidBlock transaction on L2. Note that the invalidBlock transaction is supposed to be the only transaction in the L2 block. |

verifyBlocks​

function verifyBlocks(uint256 maxBlocks) external

Verify up to N blocks.

Parameters​

NameTypeDescription
maxBlocksuint256Max number of blocks to verify.

stake​

function stake(uint256 amount) external

unStake​

function unStake() external

getStakeAmount​

function getStakeAmount() external view returns (uint256)

withdrawBalance​

function withdrawBalance() external

getRewardBalance​

function getRewardBalance(address addr) public view returns (uint256)

getBlockFee​

function getBlockFee() public view returns (uint256)

getProofReward​

function getProofReward(uint64 provenAt, uint64 proposedAt) public view returns (uint256 reward)

isCommitValid​

function isCommitValid(uint256 commitSlot, uint256 commitHeight, bytes32 commitHash) public view returns (bool)

getProposedBlock​

function getProposedBlock(uint256 id) public view returns (struct MXCData.ProposedBlock)

getSyncedHeader​

function getSyncedHeader(uint256 number) public view returns (bytes32)

getLatestSyncedHeader​

function getLatestSyncedHeader() public view returns (bytes32)

getStateVariables​

function getStateVariables() public view returns (struct LibUtils.StateVariables)

signWithGoldenTouch​

function signWithGoldenTouch(bytes32 hash, uint8 k) public view returns (uint8 v, uint256 r, uint256 s)

getForkChoice​

function getForkChoice(uint256 id, bytes32 parentHash) public view returns (struct MXCData.ForkChoice)

getConfig​

function getConfig() public pure virtual returns (struct MXCData.Config)