From 9e1f8273cf2a43e8749f55afbed38ba9243c47a2 Mon Sep 17 00:00:00 2001 From: d1onys1us Date: Wed, 19 Jul 2023 08:58:58 +0000 Subject: [PATCH] Add auto-generated contract documentation --- .../contract-documentation/L1/TaikoConfig.md | 17 + .../contract-documentation/L1/TaikoData.md | 166 ++++++++++ .../contract-documentation/L1/TaikoErrors.md | 131 ++++++++ .../contract-documentation/L1/TaikoEvents.md | 87 +++++ .../contract-documentation/L1/TaikoL1.md | 149 +++++++++ .../contract-documentation/L1/TaikoToken.md | 165 ++++++++++ .../contract-documentation/L2/LibL2Consts.md | 11 + .../contract-documentation/L2/TaikoL2.md | 215 ++++++++++++ .../L2/TaikoL2Signer.md | 29 ++ .../contract-documentation/bridge/Bridge.md | 311 ++++++++++++++++++ .../bridge/BridgeErrors.md | 182 ++++++++++ .../bridge/BridgedERC20.md | 160 +++++++++ .../bridge/EtherVault.md | 118 +++++++ .../contract-documentation/bridge/IBridge.md | 113 +++++++ .../bridge/TokenVault.md | 246 ++++++++++++++ .../common/AddressManager.md | 113 +++++++ .../common/AddressResolver.md | 111 +++++++ .../common/ICrossChainSync.md | 55 ++++ .../common/IMintableERC20.md | 17 + .../contract-documentation/common/Proxied.md | 11 + .../gov/TaikoGovernor.md | 77 +++++ .../signal/ISignalService.md | 57 ++++ .../signal/SignalService.md | 117 +++++++ 23 files changed, 2658 insertions(+) create mode 100644 packages/website/pages/docs/reference/contract-documentation/L1/TaikoConfig.md create mode 100644 packages/website/pages/docs/reference/contract-documentation/L1/TaikoData.md create mode 100644 packages/website/pages/docs/reference/contract-documentation/L1/TaikoErrors.md create mode 100644 packages/website/pages/docs/reference/contract-documentation/L1/TaikoEvents.md create mode 100644 packages/website/pages/docs/reference/contract-documentation/L1/TaikoL1.md create mode 100644 packages/website/pages/docs/reference/contract-documentation/L1/TaikoToken.md create mode 100644 packages/website/pages/docs/reference/contract-documentation/L2/LibL2Consts.md create mode 100644 packages/website/pages/docs/reference/contract-documentation/L2/TaikoL2.md create mode 100644 packages/website/pages/docs/reference/contract-documentation/L2/TaikoL2Signer.md create mode 100644 packages/website/pages/docs/reference/contract-documentation/bridge/Bridge.md create mode 100644 packages/website/pages/docs/reference/contract-documentation/bridge/BridgeErrors.md create mode 100644 packages/website/pages/docs/reference/contract-documentation/bridge/BridgedERC20.md create mode 100644 packages/website/pages/docs/reference/contract-documentation/bridge/EtherVault.md create mode 100644 packages/website/pages/docs/reference/contract-documentation/bridge/IBridge.md create mode 100644 packages/website/pages/docs/reference/contract-documentation/bridge/TokenVault.md create mode 100644 packages/website/pages/docs/reference/contract-documentation/common/AddressManager.md create mode 100644 packages/website/pages/docs/reference/contract-documentation/common/AddressResolver.md create mode 100644 packages/website/pages/docs/reference/contract-documentation/common/ICrossChainSync.md create mode 100644 packages/website/pages/docs/reference/contract-documentation/common/IMintableERC20.md create mode 100644 packages/website/pages/docs/reference/contract-documentation/common/Proxied.md create mode 100644 packages/website/pages/docs/reference/contract-documentation/gov/TaikoGovernor.md create mode 100644 packages/website/pages/docs/reference/contract-documentation/signal/ISignalService.md create mode 100644 packages/website/pages/docs/reference/contract-documentation/signal/SignalService.md diff --git a/packages/website/pages/docs/reference/contract-documentation/L1/TaikoConfig.md b/packages/website/pages/docs/reference/contract-documentation/L1/TaikoConfig.md new file mode 100644 index 0000000000..1082417944 --- /dev/null +++ b/packages/website/pages/docs/reference/contract-documentation/L1/TaikoConfig.md @@ -0,0 +1,17 @@ +--- +title: TaikoConfig +--- + +## TaikoConfig + +### getConfig + +```solidity +function getConfig() internal pure returns (struct TaikoData.Config) +``` + +#### Return Values + +| Name | Type | Description | +| ---- | ----------------------- | ------------------------------------- | +| [0] | struct TaikoData.Config | config The Taiko configuration object | diff --git a/packages/website/pages/docs/reference/contract-documentation/L1/TaikoData.md b/packages/website/pages/docs/reference/contract-documentation/L1/TaikoData.md new file mode 100644 index 0000000000..b808389cc5 --- /dev/null +++ b/packages/website/pages/docs/reference/contract-documentation/L1/TaikoData.md @@ -0,0 +1,166 @@ +--- +title: TaikoData +--- + +## TaikoData + +### Config + +```solidity +struct Config { + uint256 chainId; + uint256 maxNumProposedBlocks; + uint256 ringBufferSize; + uint256 maxVerificationsPerTx; + uint64 blockMaxGasLimit; + uint64 maxTransactionsPerBlock; + uint64 maxBytesPerTxList; + uint256 txListCacheExpiry; + uint256 proofCooldownPeriod; + uint256 systemProofCooldownPeriod; + uint256 realProofSkipSize; + uint256 ethDepositGas; + uint256 ethDepositMaxFee; + uint256 ethDepositRingBufferSize; + uint64 ethDepositMinCountPerBlock; + uint64 ethDepositMaxCountPerBlock; + uint96 ethDepositMaxAmount; + uint96 ethDepositMinAmount; + bool relaySignalRoot; +} +``` + +### StateVariables + +```solidity +struct StateVariables { + uint64 blockFee; + uint64 genesisHeight; + uint64 genesisTimestamp; + uint64 numBlocks; + uint64 lastVerifiedBlockId; + uint64 nextEthDepositToProcess; + uint64 numEthDeposits; +} +``` + +### BlockMetadataInput + +```solidity +struct BlockMetadataInput { + bytes32 txListHash; + address beneficiary; + uint32 gasLimit; + uint24 txListByteStart; + uint24 txListByteEnd; + uint8 cacheTxListInfo; +} +``` + +### BlockMetadata + +```solidity +struct BlockMetadata { + uint64 id; + uint64 timestamp; + uint64 l1Height; + bytes32 l1Hash; + bytes32 mixHash; + bytes32 txListHash; + uint24 txListByteStart; + uint24 txListByteEnd; + uint32 gasLimit; + address beneficiary; + address treasury; + struct TaikoData.EthDeposit[] depositsProcessed; +} +``` + +### BlockEvidence + +```solidity +struct BlockEvidence { + bytes32 metaHash; + bytes32 parentHash; + bytes32 blockHash; + bytes32 signalRoot; + bytes32 graffiti; + address prover; + uint32 parentGasUsed; + uint32 gasUsed; + uint16 verifierId; + bytes proof; +} +``` + +### ForkChoice + +```solidity +struct ForkChoice { + bytes32 key; + bytes32 blockHash; + bytes32 signalRoot; + uint64 provenAt; + address prover; + uint32 gasUsed; +} +``` + +### Block + +```solidity +struct Block { + mapping(uint256 => struct TaikoData.ForkChoice) forkChoices; + uint64 blockId; + uint64 proposedAt; + uint24 nextForkChoiceId; + uint24 verifiedForkChoiceId; + bytes32 metaHash; + address proposer; +} +``` + +### TxListInfo + +```solidity +struct TxListInfo { + uint64 validSince; + uint24 size; +} +``` + +### EthDeposit + +```solidity +struct EthDeposit { + address recipient; + uint96 amount; + uint64 id; +} +``` + +### State + +```solidity +struct State { + mapping(uint256 => struct TaikoData.Block) blocks; + mapping(uint256 => mapping(bytes32 => mapping(uint32 => uint256))) forkChoiceIds; + mapping(address => uint256) taikoTokenBalances; + mapping(bytes32 => struct TaikoData.TxListInfo) txListInfo; + mapping(uint256 => uint256) ethDeposits; + uint64 genesisHeight; + uint64 genesisTimestamp; + uint16 __reserved70; + uint48 __reserved71; + uint64 __reserved72; + uint64 __reserved80; + uint64 numEthDeposits; + uint64 numBlocks; + uint64 nextEthDepositToProcess; + uint64 blockFee; + uint64 __reserved90; + uint64 lastVerifiedBlockId; + uint64 __reserved91; + uint256[42] __gap; +} +``` diff --git a/packages/website/pages/docs/reference/contract-documentation/L1/TaikoErrors.md b/packages/website/pages/docs/reference/contract-documentation/L1/TaikoErrors.md new file mode 100644 index 0000000000..d03d35973e --- /dev/null +++ b/packages/website/pages/docs/reference/contract-documentation/L1/TaikoErrors.md @@ -0,0 +1,131 @@ +--- +title: TaikoErrors +--- + +## TaikoErrors + +### L1_ALREADY_PROVEN + +```solidity +error L1_ALREADY_PROVEN() +``` + +### L1_BLOCK_ID + +```solidity +error L1_BLOCK_ID() +``` + +### L1_EVIDENCE_MISMATCH + +```solidity +error L1_EVIDENCE_MISMATCH(bytes32 expected, bytes32 actual) +``` + +### L1_FORK_CHOICE_NOT_FOUND + +```solidity +error L1_FORK_CHOICE_NOT_FOUND() +``` + +### L1_INVALID_CONFIG + +```solidity +error L1_INVALID_CONFIG() +``` + +### L1_INVALID_ETH_DEPOSIT + +```solidity +error L1_INVALID_ETH_DEPOSIT() +``` + +### L1_INVALID_EVIDENCE + +```solidity +error L1_INVALID_EVIDENCE() +``` + +### L1_INVALID_METADATA + +```solidity +error L1_INVALID_METADATA() +``` + +### L1_INVALID_PARAM + +```solidity +error L1_INVALID_PARAM() +``` + +### L1_INVALID_PROOF + +```solidity +error L1_INVALID_PROOF() +``` + +### L1_INVALID_PROOF_OVERWRITE + +```solidity +error L1_INVALID_PROOF_OVERWRITE() +``` + +### L1_NOT_SPECIAL_PROVER + +```solidity +error L1_NOT_SPECIAL_PROVER() +``` + +### L1_ORACLE_PROVER_DISABLED + +```solidity +error L1_ORACLE_PROVER_DISABLED() +``` + +### L1_SAME_PROOF + +```solidity +error L1_SAME_PROOF() +``` + +### L1_SYSTEM_PROVER_DISABLED + +```solidity +error L1_SYSTEM_PROVER_DISABLED() +``` + +### L1_SYSTEM_PROVER_PROHIBITED + +```solidity +error L1_SYSTEM_PROVER_PROHIBITED() +``` + +### L1_TOO_MANY_BLOCKS + +```solidity +error L1_TOO_MANY_BLOCKS() +``` + +### L1_TX_LIST_NOT_EXIST + +```solidity +error L1_TX_LIST_NOT_EXIST() +``` + +### L1_TX_LIST_HASH + +```solidity +error L1_TX_LIST_HASH() +``` + +### L1_TX_LIST_RANGE + +```solidity +error L1_TX_LIST_RANGE() +``` + +### L1_TX_LIST + +```solidity +error L1_TX_LIST() +``` diff --git a/packages/website/pages/docs/reference/contract-documentation/L1/TaikoEvents.md b/packages/website/pages/docs/reference/contract-documentation/L1/TaikoEvents.md new file mode 100644 index 0000000000..94cc759759 --- /dev/null +++ b/packages/website/pages/docs/reference/contract-documentation/L1/TaikoEvents.md @@ -0,0 +1,87 @@ +--- +title: TaikoEvents +--- + +## TaikoEvents + +### BlockProposed + +```solidity +event BlockProposed(uint256 id, struct TaikoData.BlockMetadata meta, uint64 blockFee) +``` + +_Emitted when a block is proposed_ + +#### Parameters + +| Name | Type | Description | +| -------- | ------------------------------ | ------------------------------------------ | +| id | uint256 | The ID of the proposed block | +| meta | struct TaikoData.BlockMetadata | The metadata of the proposed block | +| blockFee | uint64 | The fee associated with the proposed block | + +### BlockProven + +```solidity +event BlockProven(uint256 id, bytes32 parentHash, bytes32 blockHash, bytes32 signalRoot, address prover, uint32 parentGasUsed) +``` + +_Emitted when a block is proven_ + +#### Parameters + +| Name | Type | Description | +| ------------- | ------- | ----------------------------------- | +| id | uint256 | The ID of the proven block | +| parentHash | bytes32 | The hash of the parent block | +| blockHash | bytes32 | The hash of the proven block | +| signalRoot | bytes32 | The signal root of the proven block | +| prover | address | The address of the prover | +| parentGasUsed | uint32 | The gas used by the parent block | + +### BlockVerified + +```solidity +event BlockVerified(uint256 id, bytes32 blockHash, uint64 reward) +``` + +_Emitted when a block is verified_ + +#### Parameters + +| Name | Type | Description | +| --------- | ------- | ------------------------------------------------ | +| id | uint256 | The ID of the verified block | +| blockHash | bytes32 | The hash of the verified block | +| reward | uint64 | The amount of token rewarded to the verification | + +### EthDeposited + +```solidity +event EthDeposited(struct TaikoData.EthDeposit deposit) +``` + +_Emitted when an Ethereum deposit is made_ + +#### Parameters + +| Name | Type | Description | +| ------- | --------------------------- | ----------------------------------------- | +| deposit | struct TaikoData.EthDeposit | The information of the deposited Ethereum | + +### ProofParamsChanged + +```solidity +event ProofParamsChanged(uint64 proofTimeTarget, uint64 proofTimeIssued, uint64 blockFee, uint16 adjustmentQuotient) +``` + +_Emitted when the proof parameters are changed_ + +#### Parameters + +| Name | Type | Description | +| ------------------ | ------ | ------------------------------------------------------------------------------- | +| proofTimeTarget | uint64 | The target time of proof generation | +| proofTimeIssued | uint64 | The actual time of proof generation | +| blockFee | uint64 | The fee associated with the proposed block | +| adjustmentQuotient | uint16 | The quotient used for adjusting future proof generation time to the target time | diff --git a/packages/website/pages/docs/reference/contract-documentation/L1/TaikoL1.md b/packages/website/pages/docs/reference/contract-documentation/L1/TaikoL1.md new file mode 100644 index 0000000000..e340c6aaf1 --- /dev/null +++ b/packages/website/pages/docs/reference/contract-documentation/L1/TaikoL1.md @@ -0,0 +1,149 @@ +--- +title: TaikoL1 +--- + +## TaikoL1 + +### state + +```solidity +struct TaikoData.State state +``` + +### receive + +```solidity +receive() external payable +``` + +### init + +```solidity +function init(address _addressManager, bytes32 _genesisBlockHash, uint64 _initBlockFee) external +``` + +Initialize the rollup. + +#### Parameters + +| Name | Type | Description | +| ------------------ | ------- | ------------------------------------- | +| \_addressManager | address | The AddressManager address. | +| \_genesisBlockHash | bytes32 | The block hash of the genesis block. | +| \_initBlockFee | uint64 | Initial (reasonable) block fee value. | + +### proposeBlock + +```solidity +function proposeBlock(bytes input, bytes txList) external returns (struct TaikoData.BlockMetadata meta) +``` + +Propose a Taiko L2 block. + +#### Parameters + +| Name | Type | Description | +| ------ | ----- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| input | bytes | An abi-encoded BlockMetadataInput that the actual L2 block header must satisfy. | +| txList | bytes | 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 + +```solidity +function proveBlock(uint256 blockId, bytes input) external +``` + +Prove a block with a zero-knowledge proof. + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ---------------------------------------------------------------------------------------------- | +| blockId | uint256 | The index of the block to prove. This is also used to select the right implementation version. | +| input | bytes | An abi-encoded TaikoData.BlockEvidence object. | + +### verifyBlocks + +```solidity +function verifyBlocks(uint256 maxBlocks) external +``` + +Verify up to N blocks. + +#### Parameters + +| Name | Type | Description | +| --------- | ------- | ------------------------------- | +| maxBlocks | uint256 | Max number of blocks to verify. | + +### depositEtherToL2 + +```solidity +function depositEtherToL2(address recipient) public payable +``` + +### canDepositEthToL2 + +```solidity +function canDepositEthToL2(uint256 amount) public view returns (bool) +``` + +### getTaikoTokenBalance + +```solidity +function getTaikoTokenBalance(address addr) public view returns (uint256) +``` + +### getBlockFee + +```solidity +function getBlockFee() public view returns (uint64) +``` + +### getBlock + +```solidity +function getBlock(uint256 blockId) public view returns (bytes32 _metaHash, address _proposer, uint64 _proposedAt) +``` + +### getForkChoice + +```solidity +function getForkChoice(uint256 blockId, bytes32 parentHash, uint32 parentGasUsed) public view returns (struct TaikoData.ForkChoice) +``` + +### getCrossChainBlockHash + +```solidity +function getCrossChainBlockHash(uint256 blockId) public view returns (bytes32) +``` + +### getCrossChainSignalRoot + +```solidity +function getCrossChainSignalRoot(uint256 blockId) public view returns (bytes32) +``` + +### getStateVariables + +```solidity +function getStateVariables() public view returns (struct TaikoData.StateVariables) +``` + +### getConfig + +```solidity +function getConfig() public pure virtual returns (struct TaikoData.Config) +``` + +### getVerifierName + +```solidity +function getVerifierName(uint16 id) public pure returns (bytes32) +``` + +--- + +## title: ProxiedTaikoL1 + +## ProxiedTaikoL1 diff --git a/packages/website/pages/docs/reference/contract-documentation/L1/TaikoToken.md b/packages/website/pages/docs/reference/contract-documentation/L1/TaikoToken.md new file mode 100644 index 0000000000..a362df0036 --- /dev/null +++ b/packages/website/pages/docs/reference/contract-documentation/L1/TaikoToken.md @@ -0,0 +1,165 @@ +--- +title: LibTaikoTokenConfig +--- + +## LibTaikoTokenConfig + +### DECIMALS + +```solidity +uint8 DECIMALS +``` + +--- + +## title: TaikoToken + +## TaikoToken + +### Mint + +```solidity +event Mint(address account, uint256 amount) +``` + +### Burn + +```solidity +event Burn(address account, uint256 amount) +``` + +### TKO_INVALID_ADDR + +```solidity +error TKO_INVALID_ADDR() +``` + +### TKO_INVALID_PREMINT_PARAMS + +```solidity +error TKO_INVALID_PREMINT_PARAMS() +``` + +### TKO_MINT_DISALLOWED + +```solidity +error TKO_MINT_DISALLOWED() +``` + +### init + +```solidity +function init(address _addressManager, string _name, string _symbol, address[] _premintRecipients, uint256[] _premintAmounts) public +``` + +### snapshot + +```solidity +function snapshot() public +``` + +### pause + +```solidity +function pause() public +``` + +### unpause + +```solidity +function unpause() public +``` + +### mint + +```solidity +function mint(address to, uint256 amount) public +``` + +### burn + +```solidity +function burn(address from, uint256 amount) public +``` + +### transfer + +```solidity +function transfer(address to, uint256 amount) public returns (bool) +``` + +\_See {IERC20-transfer}. + +Requirements: + +- `to` cannot be the zero address. +- the caller must have a balance of at least `amount`.\_ + +### transferFrom + +```solidity +function transferFrom(address from, address to, uint256 amount) public returns (bool) +``` + +\_See {IERC20-transferFrom}. + +Emits an {Approval} event indicating the updated allowance. This is not +required by the EIP. See the note at the beginning of {ERC20}. + +NOTE: Does not update the allowance if the current allowance +is the maximum `uint256`. + +Requirements: + +- `from` and `to` cannot be the zero address. +- `from` must have a balance of at least `amount`. +- the caller must have allowance for `from`'s tokens of at least + `amount`.\_ + +### decimals + +```solidity +function decimals() public pure returns (uint8) +``` + +\_Returns the number of decimals used to get its user representation. +For example, if `decimals` equals `2`, a balance of `505` tokens should +be displayed to a user as `5.05` (`505 / 10 ** 2`). + +Tokens usually opt for a value of 18, imitating the relationship between +Ether and Wei. This is the value {ERC20} uses, unless this function is +overridden; + +NOTE: This information is only used for _display_ purposes: it in +no way affects any of the arithmetic of the contract, including +{IERC20-balanceOf} and {IERC20-transfer}.\_ + +### \_beforeTokenTransfer + +```solidity +function _beforeTokenTransfer(address from, address to, uint256 amount) internal +``` + +### \_afterTokenTransfer + +```solidity +function _afterTokenTransfer(address from, address to, uint256 amount) internal +``` + +### \_mint + +```solidity +function _mint(address to, uint256 amount) internal +``` + +### \_burn + +```solidity +function _burn(address from, uint256 amount) internal +``` + +--- + +## title: ProxiedTaikoToken + +## ProxiedTaikoToken diff --git a/packages/website/pages/docs/reference/contract-documentation/L2/LibL2Consts.md b/packages/website/pages/docs/reference/contract-documentation/L2/LibL2Consts.md new file mode 100644 index 0000000000..ab814286e0 --- /dev/null +++ b/packages/website/pages/docs/reference/contract-documentation/L2/LibL2Consts.md @@ -0,0 +1,11 @@ +--- +title: LibL2Consts +--- + +## LibL2Consts + +### ANCHOR_GAS_COST + +```solidity +uint64 ANCHOR_GAS_COST +``` diff --git a/packages/website/pages/docs/reference/contract-documentation/L2/TaikoL2.md b/packages/website/pages/docs/reference/contract-documentation/L2/TaikoL2.md new file mode 100644 index 0000000000..533e2c0650 --- /dev/null +++ b/packages/website/pages/docs/reference/contract-documentation/L2/TaikoL2.md @@ -0,0 +1,215 @@ +--- +title: TaikoL2 +--- + +## TaikoL2 + +### VerifiedBlock + +```solidity +struct VerifiedBlock { + bytes32 blockHash; + bytes32 signalRoot; +} +``` + +### EIP1559Params + +```solidity +struct EIP1559Params { + uint64 basefee; + uint64 gasIssuedPerSecond; + uint64 gasExcessMax; + uint64 gasTarget; + uint64 ratio2x1x; +} +``` + +### EIP1559Config + +```solidity +struct EIP1559Config { + uint128 yscale; + uint64 xscale; + uint64 gasIssuedPerSecond; +} +``` + +### publicInputHash + +```solidity +bytes32 publicInputHash +``` + +### parentTimestamp + +```solidity +uint64 parentTimestamp +``` + +### latestSyncedL1Height + +```solidity +uint64 latestSyncedL1Height +``` + +### gasExcess + +```solidity +uint64 gasExcess +``` + +### Anchored + +```solidity +event Anchored(uint64 number, uint64 basefee, uint64 gaslimit, uint64 timestamp, bytes32 parentHash, uint256 prevrandao, address coinbase, uint32 chainid) +``` + +### L2_BASEFEE_MISMATCH + +```solidity +error L2_BASEFEE_MISMATCH(uint64 expected, uint64 actual) +``` + +### L2_INVALID_1559_PARAMS + +```solidity +error L2_INVALID_1559_PARAMS() +``` + +### L2_INVALID_CHAIN_ID + +```solidity +error L2_INVALID_CHAIN_ID() +``` + +### L2_INVALID_SENDER + +```solidity +error L2_INVALID_SENDER() +``` + +### L2_PUBLIC_INPUT_HASH_MISMATCH + +```solidity +error L2_PUBLIC_INPUT_HASH_MISMATCH(bytes32 expected, bytes32 actual) +``` + +### L2_TOO_LATE + +```solidity +error L2_TOO_LATE() +``` + +### M1559_UNEXPECTED_CHANGE + +```solidity +error M1559_UNEXPECTED_CHANGE(uint64 expected, uint64 actual) +``` + +### M1559_OUT_OF_STOCK + +```solidity +error M1559_OUT_OF_STOCK() +``` + +### init + +```solidity +function init(address _addressManager, struct TaikoL2.EIP1559Params _param1559) external +``` + +### anchor + +```solidity +function anchor(bytes32 l1Hash, bytes32 l1SignalRoot, uint64 l1Height, uint64 parentGasUsed) external +``` + +Persist the latest L1 block height and hash to L2 for cross-layer +message verification (eg. bridging). This function will also check +certain block-level global variables because they are not part of the +Trie structure. + +A circuit will verify the integrity among: + +- l1Hash, l1SignalRoot, and l1SignalServiceAddress +- (l1Hash and l1SignalServiceAddress) are both hashed into of the + ZKP's instance. + +This transaction shall be the first transaction in every L2 block. + +#### Parameters + +| Name | Type | Description | +| ------------- | ------- | --------------------------------------------------------- | +| l1Hash | bytes32 | The latest L1 block hash when this block was proposed. | +| l1SignalRoot | bytes32 | The latest value of the L1 "signal service storage root". | +| l1Height | uint64 | The latest L1 block height when this block was proposed. | +| parentGasUsed | uint64 | the gas used in the parent block. | + +### getBasefee + +```solidity +function getBasefee(uint32 timeSinceParent, uint64 gasLimit, uint64 parentGasUsed) public view returns (uint256 _basefee) +``` + +### getCrossChainBlockHash + +```solidity +function getCrossChainBlockHash(uint256 number) public view returns (bytes32) +``` + +Returns the cross-chain block hash at the given block number. + +#### Parameters + +| Name | Type | Description | +| ------ | ------- | --------------------------------------------- | +| number | uint256 | The block number. Use 0 for the latest block. | + +#### Return Values + +| Name | Type | Description | +| ---- | ------- | --------------------------- | +| [0] | bytes32 | The cross-chain block hash. | + +### getCrossChainSignalRoot + +```solidity +function getCrossChainSignalRoot(uint256 number) public view returns (bytes32) +``` + +Returns the cross-chain signal service storage root at the given +block number. + +#### Parameters + +| Name | Type | Description | +| ------ | ------- | --------------------------------------------- | +| number | uint256 | The block number. Use 0 for the latest block. | + +#### Return Values + +| Name | Type | Description | +| ---- | ------- | -------------------------------------------- | +| [0] | bytes32 | The cross-chain signal service storage root. | + +### getBlockHash + +```solidity +function getBlockHash(uint256 number) public view returns (bytes32) +``` + +### getEIP1559Config + +```solidity +function getEIP1559Config() public view virtual returns (struct TaikoL2.EIP1559Config) +``` + +_Overide this funciton to return a constant EIP1559Config object_ + +--- + +## title: ProxiedTaikoL2 + +## ProxiedTaikoL2 diff --git a/packages/website/pages/docs/reference/contract-documentation/L2/TaikoL2Signer.md b/packages/website/pages/docs/reference/contract-documentation/L2/TaikoL2Signer.md new file mode 100644 index 0000000000..f918f32a6e --- /dev/null +++ b/packages/website/pages/docs/reference/contract-documentation/L2/TaikoL2Signer.md @@ -0,0 +1,29 @@ +--- +title: TaikoL2Signer +--- + +## TaikoL2Signer + +### GOLDEN_TOUCH_ADDRESS + +```solidity +address GOLDEN_TOUCH_ADDRESS +``` + +### GOLDEN_TOUCH_PRIVATEKEY + +```solidity +uint256 GOLDEN_TOUCH_PRIVATEKEY +``` + +### L2_INVALID_GOLDEN_TOUCH_K + +```solidity +error L2_INVALID_GOLDEN_TOUCH_K() +``` + +### signAnchor + +```solidity +function signAnchor(bytes32 digest, uint8 k) public view returns (uint8 v, uint256 r, uint256 s) +``` diff --git a/packages/website/pages/docs/reference/contract-documentation/bridge/Bridge.md b/packages/website/pages/docs/reference/contract-documentation/bridge/Bridge.md new file mode 100644 index 0000000000..5afa35c36b --- /dev/null +++ b/packages/website/pages/docs/reference/contract-documentation/bridge/Bridge.md @@ -0,0 +1,311 @@ +--- +title: Bridge +--- + +## Bridge + +This contract is a Bridge contract which is deployed on both L1 and L2. Mostly +a thin wrapper +which calls the library implementations. See _IBridge_ for more details. + +_The code hash for the same address on L1 and L2 may be different._ + +### MessageStatusChanged + +```solidity +event MessageStatusChanged(bytes32 msgHash, enum LibBridgeStatus.MessageStatus status, address transactor) +``` + +### DestChainEnabled + +```solidity +event DestChainEnabled(uint256 chainId, bool enabled) +``` + +### receive + +```solidity +receive() external payable +``` + +Allow Bridge to receive ETH from the TaikoL1, TokenVault or EtherVault. + +### init + +```solidity +function init(address _addressManager) external +``` + +Initializer to be called after being deployed behind a proxy. + +_Initializer function to setup the EssentialContract._ + +#### Parameters + +| Name | Type | Description | +| ---------------- | ------- | ------------------------------------------- | +| \_addressManager | address | The address of the AddressManager contract. | + +### sendMessage + +```solidity +function sendMessage(struct IBridge.Message message) external payable returns (bytes32 msgHash) +``` + +Sends a message from the current chain to the destination chain specified +in the message. + +_Sends a message by calling the LibBridgeSend.sendMessage library +function._ + +#### Parameters + +| Name | Type | Description | +| ------- | ---------------------- | ---------------------------------- | +| message | struct IBridge.Message | The message to send. (See IBridge) | + +#### Return Values + +| Name | Type | Description | +| ------- | ------- | -------------------------------------- | +| msgHash | bytes32 | The hash of the message that was sent. | + +### releaseEther + +```solidity +function releaseEther(struct IBridge.Message message, bytes proof) external +``` + +Releases the Ether locked in the bridge as part of a cross-chain +transfer. + +_Releases the Ether by calling the LibBridgeRelease.releaseEther +library function._ + +#### Parameters + +| Name | Type | Description | +| ------- | ---------------------- | ----------------------------------------------------------------------- | +| message | struct IBridge.Message | The message containing the details of the Ether transfer. (See IBridge) | +| proof | bytes | The proof of the cross-chain transfer. | + +### processMessage + +```solidity +function processMessage(struct IBridge.Message message, bytes proof) external +``` + +Processes a message received from another chain. + +_Processes the message by calling the LibBridgeProcess.processMessage +library function._ + +#### Parameters + +| Name | Type | Description | +| ------- | ---------------------- | -------------------------------------- | +| message | struct IBridge.Message | The message to process. | +| proof | bytes | The proof of the cross-chain transfer. | + +### retryMessage + +```solidity +function retryMessage(struct IBridge.Message message, bool isLastAttempt) external +``` + +Retries sending a message that previously failed to send. + +_Retries the message by calling the LibBridgeRetry.retryMessage +library function._ + +#### Parameters + +| Name | Type | Description | +| ------------- | ---------------------- | --------------------------------------------------------------- | +| message | struct IBridge.Message | The message to retry. | +| isLastAttempt | bool | Specifies whether this is the last attempt to send the message. | + +### isMessageSent + +```solidity +function isMessageSent(bytes32 msgHash) public view virtual returns (bool) +``` + +Check if the message with the given hash has been sent. + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ------------------------ | +| msgHash | bytes32 | The hash of the message. | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------------------------------------------------------- | +| [0] | bool | Returns true if the message has been sent, false otherwise. | + +### isMessageReceived + +```solidity +function isMessageReceived(bytes32 msgHash, uint256 srcChainId, bytes proof) public view virtual returns (bool) +``` + +Check if the message with the given hash has been received. + +#### Parameters + +| Name | Type | Description | +| ---------- | ------- | ----------------------------- | +| msgHash | bytes32 | The hash of the message. | +| srcChainId | uint256 | The source chain ID. | +| proof | bytes | The proof of message receipt. | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | --------------------------------------------------------------- | +| [0] | bool | Returns true if the message has been received, false otherwise. | + +### isMessageFailed + +```solidity +function isMessageFailed(bytes32 msgHash, uint256 destChainId, bytes proof) public view virtual returns (bool) +``` + +Check if the message with the given hash has failed. + +#### Parameters + +| Name | Type | Description | +| ----------- | ------- | ----------------------------- | +| msgHash | bytes32 | The hash of the message. | +| destChainId | uint256 | The destination chain ID. | +| proof | bytes | The proof of message failure. | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | -------------------------------------------------------- | +| [0] | bool | Returns true if the message has failed, false otherwise. | + +### getMessageStatus + +```solidity +function getMessageStatus(bytes32 msgHash) public view virtual returns (enum LibBridgeStatus.MessageStatus) +``` + +Get the status of the message with the given hash. + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ------------------------ | +| msgHash | bytes32 | The hash of the message. | + +#### Return Values + +| Name | Type | Description | +| ---- | ---------------------------------- | ---------------------------------- | +| [0] | enum LibBridgeStatus.MessageStatus | Returns the status of the message. | + +### context + +```solidity +function context() public view returns (struct IBridge.Context) +``` + +Get the current context + +#### Return Values + +| Name | Type | Description | +| ---- | ---------------------- | ---------------------------- | +| [0] | struct IBridge.Context | Returns the current context. | + +### isEtherReleased + +```solidity +function isEtherReleased(bytes32 msgHash) public view returns (bool) +``` + +Check if the Ether associated with the given message hash has been +released. + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ------------------------ | +| msgHash | bytes32 | The hash of the message. | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ------------------------------------------------------------- | +| [0] | bool | Returns true if the Ether has been released, false otherwise. | + +### isDestChainEnabled + +```solidity +function isDestChainEnabled(uint256 _chainId) public view returns (bool enabled) +``` + +Check if the destination chain with the given ID is enabled. + +#### Parameters + +| Name | Type | Description | +| --------- | ------- | -------------------- | +| \_chainId | uint256 | The ID of the chain. | + +#### Return Values + +| Name | Type | Description | +| ------- | ---- | ------------------------------------------------------------------ | +| enabled | bool | Returns true if the destination chain is enabled, false otherwise. | + +### hashMessage + +```solidity +function hashMessage(struct IBridge.Message message) public pure returns (bytes32) +``` + +Compute the hash of a given message. + +#### Parameters + +| Name | Type | Description | +| ------- | ---------------------- | ------------------------------------ | +| message | struct IBridge.Message | The message to compute the hash for. | + +#### Return Values + +| Name | Type | Description | +| ---- | ------- | -------------------------------- | +| [0] | bytes32 | Returns the hash of the message. | + +### getMessageStatusSlot + +```solidity +function getMessageStatusSlot(bytes32 msgHash) public pure returns (bytes32) +``` + +Get the slot associated with a given message hash status. + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ------------------------ | +| msgHash | bytes32 | The hash of the message. | + +#### Return Values + +| Name | Type | Description | +| ---- | ------- | --------------------------------------------------------------- | +| [0] | bytes32 | Returns the slot associated with the given message hash status. | + +--- + +## title: ProxiedBridge + +## ProxiedBridge diff --git a/packages/website/pages/docs/reference/contract-documentation/bridge/BridgeErrors.md b/packages/website/pages/docs/reference/contract-documentation/bridge/BridgeErrors.md new file mode 100644 index 0000000000..0ad96574b0 --- /dev/null +++ b/packages/website/pages/docs/reference/contract-documentation/bridge/BridgeErrors.md @@ -0,0 +1,182 @@ +--- +title: BridgeErrors +--- + +## BridgeErrors + +### B_CANNOT_RECEIVE + +```solidity +error B_CANNOT_RECEIVE() +``` + +Emitted when the contract is not intended to receive Ether + +### B_DENIED + +```solidity +error B_DENIED() +``` + +Emitted when an operation is denied due to incorrect permissions + +### B_ERC20_CANNOT_RECEIVE + +```solidity +error B_ERC20_CANNOT_RECEIVE() +``` + +Emitted when the contract is not designed to receive ERC20 tokens + +### B_ETHER_RELEASED_ALREADY + +```solidity +error B_ETHER_RELEASED_ALREADY() +``` + +Emitted when Ether has already been released as part of a transfer + +### B_EV_DO_NOT_BURN + +```solidity +error B_EV_DO_NOT_BURN() +``` + +Emitted when attempting to burn Ether in EtherVault + +### B_EV_NOT_AUTHORIZED + +```solidity +error B_EV_NOT_AUTHORIZED() +``` + +Emitted when an unauthorized action is attempted in EtherVault + +### B_EV_PARAM + +```solidity +error B_EV_PARAM() +``` + +Emitted when an incorrect parameter is passed in EtherVault + +### B_FAILED_TRANSFER + +```solidity +error B_FAILED_TRANSFER() +``` + +Emitted when an ERC20 token transfer fails + +### B_FORBIDDEN + +```solidity +error B_FORBIDDEN() +``` + +Emitted when an action is forbidden + +### B_GAS_LIMIT + +```solidity +error B_GAS_LIMIT() +``` + +Emitted when the gas limit for an operation is exceeded + +### B_INCORRECT_VALUE + +```solidity +error B_INCORRECT_VALUE() +``` + +Emitted when an incorrect value is used in an operation + +### B_INIT_PARAM_ERROR + +```solidity +error B_INIT_PARAM_ERROR() +``` + +Emitted when an incorrect parameter is passed during initialization + +### B_MSG_HASH_NULL + +```solidity +error B_MSG_HASH_NULL() +``` + +Emitted when a null message hash is used + +### B_MSG_NON_RETRIABLE + +```solidity +error B_MSG_NON_RETRIABLE() +``` + +Emitted when a non-retriable message is retried + +### B_MSG_NOT_FAILED + +```solidity +error B_MSG_NOT_FAILED() +``` + +Emitted when a message that hasn't failed is retried + +### B_NULL_APP_ADDR + +```solidity +error B_NULL_APP_ADDR() +``` + +Emitted when a null address is used in an application + +### B_OWNER_IS_NULL + +```solidity +error B_OWNER_IS_NULL() +``` + +Emitted when a null owner address is used + +### B_SIGNAL_NOT_RECEIVED + +```solidity +error B_SIGNAL_NOT_RECEIVED() +``` + +Emitted when a signal has not been received + +### B_STATUS_MISMATCH + +```solidity +error B_STATUS_MISMATCH() +``` + +Emitted when the status of an operation does not match the expected +status + +### B_WRONG_CHAIN_ID + +```solidity +error B_WRONG_CHAIN_ID() +``` + +Emitted when an incorrect chain ID is used + +### B_WRONG_TO_ADDRESS + +```solidity +error B_WRONG_TO_ADDRESS() +``` + +Emitted when an incorrect recipient address is used + +### B_ZERO_SIGNAL + +```solidity +error B_ZERO_SIGNAL() +``` + +Emitted when a signal of zero is used diff --git a/packages/website/pages/docs/reference/contract-documentation/bridge/BridgedERC20.md b/packages/website/pages/docs/reference/contract-documentation/bridge/BridgedERC20.md new file mode 100644 index 0000000000..d00e4948be --- /dev/null +++ b/packages/website/pages/docs/reference/contract-documentation/bridge/BridgedERC20.md @@ -0,0 +1,160 @@ +--- +title: BridgedERC20 +--- + +## BridgedERC20 + +This contract is an upgradeable ERC20 contract that represents tokens bridged +from another chain. + +### srcToken + +```solidity +address srcToken +``` + +### srcChainId + +```solidity +uint256 srcChainId +``` + +### BridgeMint + +```solidity +event BridgeMint(address account, uint256 amount) +``` + +### BridgeBurn + +```solidity +event BridgeBurn(address account, uint256 amount) +``` + +### init + +```solidity +function init(address _addressManager, address _srcToken, uint256 _srcChainId, uint8 _decimals, string _symbol, string _name) external +``` + +Initializes the contract. + +_Different BridgedERC20 Contract to be deployed +per unique \_srcToken i.e. one for USDC, one for USDT etc._ + +#### Parameters + +| Name | Type | Description | +| ---------------- | ------- | ------------------------------------------------- | +| \_addressManager | address | The address manager. | +| \_srcToken | address | The source token address. | +| \_srcChainId | uint256 | The source chain ID. | +| \_decimals | uint8 | The number of decimal places of the source token. | +| \_symbol | string | The symbol of the token. | +| \_name | string | The name of the token. | + +### bridgeMintTo + +```solidity +function bridgeMintTo(address account, uint256 amount) public +``` + +Mints tokens to an account. + +_Only a TokenVault can call this function._ + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ------------------------------ | +| account | address | The account to mint tokens to. | +| amount | uint256 | The amount of tokens to mint. | + +### bridgeBurnFrom + +```solidity +function bridgeBurnFrom(address account, uint256 amount) public +``` + +Burns tokens from an account. + +_Only a TokenVault can call this function._ + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | -------------------------------- | +| account | address | The account to burn tokens from. | +| amount | uint256 | The amount of tokens to burn. | + +### transfer + +```solidity +function transfer(address to, uint256 amount) public returns (bool) +``` + +Transfers tokens from the caller to another account. + +_Any address can call this. Caller must have at least 'amount' to +call this._ + +#### Parameters + +| Name | Type | Description | +| ------ | ------- | ---------------------------------- | +| to | address | The account to transfer tokens to. | +| amount | uint256 | The amount of tokens to transfer. | + +### transferFrom + +```solidity +function transferFrom(address from, address to, uint256 amount) public returns (bool) +``` + +Transfers tokens from one account to another account. + +_Any address can call this. Caller must have allowance of at least +'amount' for 'from's tokens._ + +#### Parameters + +| Name | Type | Description | +| ------ | ------- | ------------------------------------ | +| from | address | The account to transfer tokens from. | +| to | address | The account to transfer tokens to. | +| amount | uint256 | The amount of tokens to transfer. | + +### decimals + +```solidity +function decimals() public view returns (uint8) +``` + +Gets the number of decimal places of the token. + +#### Return Values + +| Name | Type | Description | +| ---- | ----- | ------------------------------------------ | +| [0] | uint8 | The number of decimal places of the token. | + +### source + +```solidity +function source() public view returns (address, uint256) +``` + +Gets the source token address and the source chain ID. + +#### Return Values + +| Name | Type | Description | +| ---- | ------- | ------------------------------------------------- | +| [0] | address | The source token address and the source chain ID. | +| [1] | uint256 | | + +--- + +## title: ProxiedBridgedERC20 + +## ProxiedBridgedERC20 diff --git a/packages/website/pages/docs/reference/contract-documentation/bridge/EtherVault.md b/packages/website/pages/docs/reference/contract-documentation/bridge/EtherVault.md new file mode 100644 index 0000000000..4530e4c27a --- /dev/null +++ b/packages/website/pages/docs/reference/contract-documentation/bridge/EtherVault.md @@ -0,0 +1,118 @@ +--- +title: EtherVault +--- + +## EtherVault + +This contract is initialized with 2^128 Ether and allows authorized addresses +to release Ether. + +_Only the contract owner can authorize or deauthorize addresses._ + +### Authorized + +```solidity +event Authorized(address addr, bool authorized) +``` + +### EtherReleased + +```solidity +event EtherReleased(address to, uint256 amount) +``` + +### onlyAuthorized + +```solidity +modifier onlyAuthorized() +``` + +### receive + +```solidity +receive() external payable +``` + +Function to receive Ether + +_Only authorized addresses can send Ether to the contract_ + +### init + +```solidity +function init(address addressManager) external +``` + +Initialize the contract with an address manager + +#### Parameters + +| Name | Type | Description | +| -------------- | ------- | ---------------------------------- | +| addressManager | address | The address of the address manager | + +### releaseEther + +```solidity +function releaseEther(uint256 amount) public +``` + +Transfer Ether from EtherVault to the sender, checking that the sender +is authorized. + +#### Parameters + +| Name | Type | Description | +| ------ | ------- | ------------------------ | +| amount | uint256 | Amount of Ether to send. | + +### releaseEther + +```solidity +function releaseEther(address recipient, uint256 amount) public +``` + +Transfer Ether from EtherVault to a designated address, checking that the +sender is authorized. + +#### Parameters + +| Name | Type | Description | +| --------- | ------- | ------------------------- | +| recipient | address | Address to receive Ether. | +| amount | uint256 | Amount of ether to send. | + +### authorize + +```solidity +function authorize(address addr, bool authorized) public +``` + +Set the authorized status of an address, only the owner can call this. + +#### Parameters + +| Name | Type | Description | +| ---------- | ------- | ---------------------------------------- | +| addr | address | Address to set the authorized status of. | +| authorized | bool | Authorized status to set. | + +### isAuthorized + +```solidity +function isAuthorized(address addr) public view returns (bool) +``` + +Get the authorized status of an address. + +#### Parameters + +| Name | Type | Description | +| ---- | ------- | ---------------------------------------- | +| addr | address | Address to get the authorized status of. | + +--- + +## title: ProxiedEtherVault + +## ProxiedEtherVault diff --git a/packages/website/pages/docs/reference/contract-documentation/bridge/IBridge.md b/packages/website/pages/docs/reference/contract-documentation/bridge/IBridge.md new file mode 100644 index 0000000000..c159a78bdc --- /dev/null +++ b/packages/website/pages/docs/reference/contract-documentation/bridge/IBridge.md @@ -0,0 +1,113 @@ +--- +title: IBridge +--- + +## IBridge + +Bridge interface. + +_Ether is held by Bridges on L1 and by the EtherVault on L2, +not TokenVaults._ + +### Message + +```solidity +struct Message { + uint256 id; + address sender; + uint256 srcChainId; + uint256 destChainId; + address owner; + address to; + address refundAddress; + uint256 depositValue; + uint256 callValue; + uint256 processingFee; + uint256 gasLimit; + bytes data; + string memo; +} +``` + +### Context + +```solidity +struct Context { + bytes32 msgHash; + address sender; + uint256 srcChainId; +} +``` + +### SignalSent + +```solidity +event SignalSent(address sender, bytes32 msgHash) +``` + +### MessageSent + +```solidity +event MessageSent(bytes32 msgHash, struct IBridge.Message message) +``` + +### EtherReleased + +```solidity +event EtherReleased(bytes32 msgHash, address to, uint256 amount) +``` + +### sendMessage + +```solidity +function sendMessage(struct IBridge.Message message) external payable returns (bytes32 msgHash) +``` + +Sends a message to the destination chain and takes custody +of Ether required in this contract. All extra Ether will be refunded. + +### releaseEther + +```solidity +function releaseEther(struct IBridge.Message message, bytes proof) external +``` + +### isMessageSent + +```solidity +function isMessageSent(bytes32 msgHash) external view returns (bool) +``` + +Checks if a msgHash has been stored on the bridge contract by the +current address. + +### isMessageReceived + +```solidity +function isMessageReceived(bytes32 msgHash, uint256 srcChainId, bytes proof) external view returns (bool) +``` + +Checks if a msgHash has been received on the destination chain and +sent by the src chain. + +### isMessageFailed + +```solidity +function isMessageFailed(bytes32 msgHash, uint256 destChainId, bytes proof) external view returns (bool) +``` + +Checks if a msgHash has been failed on the destination chain. + +### context + +```solidity +function context() external view returns (struct IBridge.Context context) +``` + +Returns the bridge state context. + +### hashMessage + +```solidity +function hashMessage(struct IBridge.Message message) external pure returns (bytes32) +``` diff --git a/packages/website/pages/docs/reference/contract-documentation/bridge/TokenVault.md b/packages/website/pages/docs/reference/contract-documentation/bridge/TokenVault.md new file mode 100644 index 0000000000..22a0eb5c08 --- /dev/null +++ b/packages/website/pages/docs/reference/contract-documentation/bridge/TokenVault.md @@ -0,0 +1,246 @@ +--- +title: TokenVault +--- + +## TokenVault + +This vault holds all ERC20 tokens (but not Ether) that users have deposited. +It also manages the mapping between canonical ERC20 tokens and their bridged +tokens. + +_Ether is held by Bridges on L1 and by the EtherVault on L2, not +TokenVaults._ + +### CanonicalERC20 + +```solidity +struct CanonicalERC20 { + uint256 chainId; + address addr; + uint8 decimals; + string symbol; + string name; +} +``` + +### MessageDeposit + +```solidity +struct MessageDeposit { + address token; + uint256 amount; +} +``` + +### isBridgedToken + +```solidity +mapping(address => bool) isBridgedToken +``` + +### bridgedToCanonical + +```solidity +mapping(address => struct TokenVault.CanonicalERC20) bridgedToCanonical +``` + +### canonicalToBridged + +```solidity +mapping(uint256 => mapping(address => address)) canonicalToBridged +``` + +### messageDeposits + +```solidity +mapping(bytes32 => struct TokenVault.MessageDeposit) messageDeposits +``` + +### BridgedERC20Deployed + +```solidity +event BridgedERC20Deployed(uint256 srcChainId, address canonicalToken, address bridgedToken, string canonicalTokenSymbol, string canonicalTokenName, uint8 canonicalTokenDecimal) +``` + +### EtherSent + +```solidity +event EtherSent(bytes32 msgHash, address from, address to, uint256 destChainId, uint256 amount) +``` + +### ERC20Sent + +```solidity +event ERC20Sent(bytes32 msgHash, address from, address to, uint256 destChainId, address token, uint256 amount) +``` + +### ERC20Released + +```solidity +event ERC20Released(bytes32 msgHash, address from, address token, uint256 amount) +``` + +### ERC20Received + +```solidity +event ERC20Received(bytes32 msgHash, address from, address to, uint256 srcChainId, address token, uint256 amount) +``` + +### TOKENVAULT_INVALID_TO + +```solidity +error TOKENVAULT_INVALID_TO() +``` + +Thrown when the `to` address in an operation is invalid. +This can happen if it's zero address or the address of the token vault. + +### TOKENVAULT_INVALID_VALUE + +```solidity +error TOKENVAULT_INVALID_VALUE() +``` + +Thrown when the value in a transaction is invalid. +The value can be an Ether amount or the amount of a token being +transferred. + +### TOKENVAULT_INVALID_TOKEN + +```solidity +error TOKENVAULT_INVALID_TOKEN() +``` + +Thrown when the token address in a transaction is invalid. +This could happen if the token address is zero or doesn't conform to the +ERC20 standard. + +### TOKENVAULT_INVALID_AMOUNT + +```solidity +error TOKENVAULT_INVALID_AMOUNT() +``` + +Thrown when the amount in a transaction is invalid. +This could happen if the amount is zero or exceeds the sender's balance. + +### TOKENVAULT_CANONICAL_TOKEN_NOT_FOUND + +```solidity +error TOKENVAULT_CANONICAL_TOKEN_NOT_FOUND() +``` + +Thrown when a canonical token address could not be found for a bridged +token. +This could happen when trying to send a bridged token back to its +original chain. + +### TOKENVAULT_INVALID_OWNER + +```solidity +error TOKENVAULT_INVALID_OWNER() +``` + +Thrown when the owner address in a message is invalid. +This could happen if the owner address is zero or doesn't match the +expected owner. + +### TOKENVAULT_INVALID_SRC_CHAIN_ID + +```solidity +error TOKENVAULT_INVALID_SRC_CHAIN_ID() +``` + +Thrown when the source chain ID in a message is invalid. +This could happen if the source chain ID doesn't match the current +chain's ID. + +### TOKENVAULT_MESSAGE_NOT_FAILED + +```solidity +error TOKENVAULT_MESSAGE_NOT_FAILED() +``` + +Thrown when a message has not failed. +This could happen if trying to release a message deposit without proof of +failure. + +### TOKENVAULT_INVALID_SENDER + +```solidity +error TOKENVAULT_INVALID_SENDER() +``` + +Thrown when the sender in a message context is invalid. +This could happen if the sender isn't the expected token vault on the +source chain. + +### init + +```solidity +function init(address addressManager) external +``` + +### sendERC20 + +```solidity +function sendERC20(uint256 destChainId, address to, address token, uint256 amount, uint256 gasLimit, uint256 processingFee, address refundAddress, string memo) external payable +``` + +Transfers ERC20 tokens to this vault and sends a message to the +destination chain so the user can receive the same amount of tokens +by invoking the message call. + +#### Parameters + +| Name | Type | Description | +| ------------- | ------- | -------------------------------------- | +| destChainId | uint256 | Chain ID of the destination chain | +| to | address | Address of the receiver | +| token | address | The address of the token to be sent. | +| amount | uint256 | The amount of token to be transferred. | +| gasLimit | uint256 | Gas limit for the transaction | +| processingFee | uint256 | Processing fee for the transaction | +| refundAddress | address | Address for refunds | +| memo | string | Any additional data or notes | + +### releaseERC20 + +```solidity +function releaseERC20(struct IBridge.Message message, bytes proof) external +``` + +Release deposited ERC20 back to the owner on the source TokenVault with +a proof that the message processing on the destination Bridge has failed. + +#### Parameters + +| Name | Type | Description | +| ------- | ---------------------- | ---------------------------------------------------------------------- | +| message | struct IBridge.Message | The message that corresponds to the ERC20 deposit on the source chain. | +| proof | bytes | The proof from the destination chain to show the message has failed. | + +### receiveERC20 + +```solidity +function receiveERC20(struct TokenVault.CanonicalERC20 canonicalToken, address from, address to, uint256 amount) external +``` + +This function can only be called by the bridge contract while +invoking a message call. See sendERC20, which sets the data to invoke +this function. + +#### Parameters + +| Name | Type | Description | +| -------------- | -------------------------------- | -------------------------------------------------------------------------------------------------------------------- | +| canonicalToken | struct TokenVault.CanonicalERC20 | The canonical ERC20 token which may or may not live on this chain. If not, a BridgedERC20 contract will be deployed. | +| from | address | The source address. | +| to | address | The destination address. | +| amount | uint256 | The amount of tokens to be sent. 0 is a valid value. | + +--- + +## title: ProxiedTokenVault + +## ProxiedTokenVault diff --git a/packages/website/pages/docs/reference/contract-documentation/common/AddressManager.md b/packages/website/pages/docs/reference/contract-documentation/common/AddressManager.md new file mode 100644 index 0000000000..9f4d1f555c --- /dev/null +++ b/packages/website/pages/docs/reference/contract-documentation/common/AddressManager.md @@ -0,0 +1,113 @@ +--- +title: IAddressManager +--- + +## IAddressManager + +Interface to set and get an address for a name. + +### setAddress + +```solidity +function setAddress(uint256 domain, bytes32 name, address newAddress) external +``` + +Changes the address associated with a particular name. + +#### Parameters + +| Name | Type | Description | +| ---------- | ------- | -------------------------------------------- | +| domain | uint256 | Uint256 domain to assiciate an address with. | +| name | bytes32 | Name to associate an address with. | +| newAddress | address | Address to associate with the name. | + +### getAddress + +```solidity +function getAddress(uint256 domain, bytes32 name) external view returns (address) +``` + +Retrieves the address associated with a given name. + +#### Parameters + +| Name | Type | Description | +| ------ | ------- | --------------------------------- | +| domain | uint256 | Class to retrieve an address for. | +| name | bytes32 | Name to retrieve an address for. | + +#### Return Values + +| Name | Type | Description | +| ---- | ------- | --------------------------------------- | +| [0] | address | Address associated with the given name. | + +--- + +## title: AddressManager + +## AddressManager + +### AddressSet + +```solidity +event AddressSet(uint256 _domain, bytes32 _name, address _newAddress, address _oldAddress) +``` + +### EOAOwnerAddressNotAllowed + +```solidity +error EOAOwnerAddressNotAllowed() +``` + +### init + +```solidity +function init() external +``` + +_Initializer to be called after being deployed behind a proxy._ + +### setAddress + +```solidity +function setAddress(uint256 domain, bytes32 name, address newAddress) external virtual +``` + +Changes the address associated with a particular name. + +#### Parameters + +| Name | Type | Description | +| ---------- | ------- | -------------------------------------------- | +| domain | uint256 | Uint256 domain to assiciate an address with. | +| name | bytes32 | Name to associate an address with. | +| newAddress | address | Address to associate with the name. | + +### getAddress + +```solidity +function getAddress(uint256 domain, bytes32 name) external view virtual returns (address addr) +``` + +Retrieves the address associated with a given name. + +#### Parameters + +| Name | Type | Description | +| ------ | ------- | --------------------------------- | +| domain | uint256 | Class to retrieve an address for. | +| name | bytes32 | Name to retrieve an address for. | + +#### Return Values + +| Name | Type | Description | +| ---- | ------- | --------------------------------------- | +| addr | address | Address associated with the given name. | + +--- + +## title: ProxiedAddressManager + +## ProxiedAddressManager diff --git a/packages/website/pages/docs/reference/contract-documentation/common/AddressResolver.md b/packages/website/pages/docs/reference/contract-documentation/common/AddressResolver.md new file mode 100644 index 0000000000..169e6f93ab --- /dev/null +++ b/packages/website/pages/docs/reference/contract-documentation/common/AddressResolver.md @@ -0,0 +1,111 @@ +--- +title: AddressResolver +--- + +## AddressResolver + +This abstract contract provides a name-to-address lookup. Under the hood, +it uses an AddressManager to manage the name-to-address mapping. + +### \_addressManager + +```solidity +contract IAddressManager _addressManager +``` + +### AddressManagerChanged + +```solidity +event AddressManagerChanged(address addressManager) +``` + +### RESOLVER_DENIED + +```solidity +error RESOLVER_DENIED() +``` + +### RESOLVER_INVALID_ADDR + +```solidity +error RESOLVER_INVALID_ADDR() +``` + +### RESOLVER_ZERO_ADDR + +```solidity +error RESOLVER_ZERO_ADDR(uint256 chainId, bytes32 name) +``` + +### onlyFromNamed + +```solidity +modifier onlyFromNamed(bytes32 name) +``` + +### resolve + +```solidity +function resolve(bytes32 name, bool allowZeroAddress) public view virtual returns (address payable) +``` + +Resolves a name to an address on the current chain. + +_This function will throw if the resolved address is `address(0)`._ + +#### Parameters + +| Name | Type | Description | +| ---------------- | ------- | ------------------------------------------ | +| name | bytes32 | The name to resolve. | +| allowZeroAddress | bool | True to allow zero address to be returned. | + +#### Return Values + +| Name | Type | Description | +| ---- | --------------- | --------------------------------- | +| [0] | address payable | The name's corresponding address. | + +### resolve + +```solidity +function resolve(uint256 chainId, bytes32 name, bool allowZeroAddress) public view virtual returns (address payable) +``` + +Resolves a name to an address on the specified chain. + +_This function will throw if the resolved address is `address(0)`._ + +#### Parameters + +| Name | Type | Description | +| ---------------- | ------- | ------------------------------------------ | +| chainId | uint256 | The chainId. | +| name | bytes32 | The name to resolve. | +| allowZeroAddress | bool | True to allow zero address to be returned. | + +#### Return Values + +| Name | Type | Description | +| ---- | --------------- | --------------------------------- | +| [0] | address payable | The name's corresponding address. | + +### addressManager + +```solidity +function addressManager() public view returns (address) +``` + +Returns the AddressManager's address. + +#### Return Values + +| Name | Type | Description | +| ---- | ------- | ----------------------------- | +| [0] | address | The AddressManager's address. | + +### \_init + +```solidity +function _init(address addressManager_) internal virtual +``` diff --git a/packages/website/pages/docs/reference/contract-documentation/common/ICrossChainSync.md b/packages/website/pages/docs/reference/contract-documentation/common/ICrossChainSync.md new file mode 100644 index 0000000000..b1c8ee28a1 --- /dev/null +++ b/packages/website/pages/docs/reference/contract-documentation/common/ICrossChainSync.md @@ -0,0 +1,55 @@ +--- +title: ICrossChainSync +--- + +## ICrossChainSync + +Interface implemented by both the TaikoL1 and TaikoL2 contracts. It exposes +the methods needed to access the block hashes of the other chain. + +### CrossChainSynced + +```solidity +event CrossChainSynced(uint256 srcHeight, bytes32 blockHash, bytes32 signalRoot) +``` + +### getCrossChainBlockHash + +```solidity +function getCrossChainBlockHash(uint256 number) external view returns (bytes32) +``` + +Returns the cross-chain block hash at the given block number. + +#### Parameters + +| Name | Type | Description | +| ------ | ------- | --------------------------------------------- | +| number | uint256 | The block number. Use 0 for the latest block. | + +#### Return Values + +| Name | Type | Description | +| ---- | ------- | --------------------------- | +| [0] | bytes32 | The cross-chain block hash. | + +### getCrossChainSignalRoot + +```solidity +function getCrossChainSignalRoot(uint256 number) external view returns (bytes32) +``` + +Returns the cross-chain signal service storage root at the given +block number. + +#### Parameters + +| Name | Type | Description | +| ------ | ------- | --------------------------------------------- | +| number | uint256 | The block number. Use 0 for the latest block. | + +#### Return Values + +| Name | Type | Description | +| ---- | ------- | -------------------------------------------- | +| [0] | bytes32 | The cross-chain signal service storage root. | diff --git a/packages/website/pages/docs/reference/contract-documentation/common/IMintableERC20.md b/packages/website/pages/docs/reference/contract-documentation/common/IMintableERC20.md new file mode 100644 index 0000000000..0c9d4cf636 --- /dev/null +++ b/packages/website/pages/docs/reference/contract-documentation/common/IMintableERC20.md @@ -0,0 +1,17 @@ +--- +title: IMintableERC20 +--- + +## IMintableERC20 + +### mint + +```solidity +function mint(address account, uint256 amount) external +``` + +### burn + +```solidity +function burn(address account, uint256 amount) external +``` diff --git a/packages/website/pages/docs/reference/contract-documentation/common/Proxied.md b/packages/website/pages/docs/reference/contract-documentation/common/Proxied.md new file mode 100644 index 0000000000..a3bdc134b3 --- /dev/null +++ b/packages/website/pages/docs/reference/contract-documentation/common/Proxied.md @@ -0,0 +1,11 @@ +--- +title: Proxied +--- + +## Proxied + +### constructor + +```solidity +constructor() internal +``` diff --git a/packages/website/pages/docs/reference/contract-documentation/gov/TaikoGovernor.md b/packages/website/pages/docs/reference/contract-documentation/gov/TaikoGovernor.md new file mode 100644 index 0000000000..06df08d5a6 --- /dev/null +++ b/packages/website/pages/docs/reference/contract-documentation/gov/TaikoGovernor.md @@ -0,0 +1,77 @@ +--- +title: TaikoGovernor +--- + +## TaikoGovernor + +### init + +```solidity +function init(address _addressManager, contract IVotesUpgradeable _token, contract TimelockControllerUpgradeable _timelock) public +``` + +### propose + +```solidity +function propose(address[] targets, uint256[] values, bytes[] calldatas, string description) public returns (uint256) +``` + +### votingDelay + +```solidity +function votingDelay() public view returns (uint256) +``` + +### votingPeriod + +```solidity +function votingPeriod() public view returns (uint256) +``` + +### quorum + +```solidity +function quorum(uint256 blockNumber) public view returns (uint256) +``` + +### state + +```solidity +function state(uint256 proposalId) public view returns (enum IGovernorUpgradeable.ProposalState) +``` + +### proposalThreshold + +```solidity +function proposalThreshold() public view returns (uint256) +``` + +### supportsInterface + +```solidity +function supportsInterface(bytes4 interfaceId) public view returns (bool) +``` + +### \_execute + +```solidity +function _execute(uint256 proposalId, address[] targets, uint256[] values, bytes[] calldatas, bytes32 descriptionHash) internal +``` + +### \_cancel + +```solidity +function _cancel(address[] targets, uint256[] values, bytes[] calldatas, bytes32 descriptionHash) internal returns (uint256) +``` + +### \_executor + +```solidity +function _executor() internal view returns (address) +``` + +--- + +## title: ProxiedTaikoGovernor + +## ProxiedTaikoGovernor diff --git a/packages/website/pages/docs/reference/contract-documentation/signal/ISignalService.md b/packages/website/pages/docs/reference/contract-documentation/signal/ISignalService.md new file mode 100644 index 0000000000..3f342e78a4 --- /dev/null +++ b/packages/website/pages/docs/reference/contract-documentation/signal/ISignalService.md @@ -0,0 +1,57 @@ +--- +title: ISignalService +--- + +## ISignalService + +### sendSignal + +```solidity +function sendSignal(bytes32 signal) external returns (bytes32 storageSlot) +``` + +Send a signal by storing the key with a value of 1. + +#### Parameters + +| Name | Type | Description | +| ------ | ------- | ------------------- | +| signal | bytes32 | The signal to send. | + +#### Return Values + +| Name | Type | Description | +| ----------- | ------- | -------------------------------------------------- | +| storageSlot | bytes32 | The slot in storage that this signal is persisted. | + +### isSignalSent + +```solidity +function isSignalSent(address app, bytes32 signal) external view returns (bool) +``` + +Check if a signal has been sent (key stored with a value of 1). + +#### Parameters + +| Name | Type | Description | +| ------ | ------- | ----------------------------------- | +| app | address | The address that sent this message. | +| signal | bytes32 | The signal to check. | + +### isSignalReceived + +```solidity +function isSignalReceived(uint256 srcChainId, address app, bytes32 signal, bytes proof) external view returns (bool) +``` + +Check if signal has been received on the destination chain (current). + +#### Parameters + +| Name | Type | Description | +| ---------- | ------- | ------------------------------------------------------- | +| srcChainId | uint256 | The source chain ID. | +| app | address | The address that sent this message. | +| signal | bytes32 | The signal to check. | +| proof | bytes | The proof of the signal being sent on the source chain. | diff --git a/packages/website/pages/docs/reference/contract-documentation/signal/SignalService.md b/packages/website/pages/docs/reference/contract-documentation/signal/SignalService.md new file mode 100644 index 0000000000..5b70469788 --- /dev/null +++ b/packages/website/pages/docs/reference/contract-documentation/signal/SignalService.md @@ -0,0 +1,117 @@ +--- +title: SignalService +--- + +## SignalService + +### SignalProof + +```solidity +struct SignalProof { + uint256 height; + bytes proof; +} +``` + +### B_ZERO_SIGNAL + +```solidity +error B_ZERO_SIGNAL() +``` + +### B_NULL_APP_ADDR + +```solidity +error B_NULL_APP_ADDR() +``` + +### B_WRONG_CHAIN_ID + +```solidity +error B_WRONG_CHAIN_ID() +``` + +### init + +```solidity +function init(address _addressManager) external +``` + +_Initializer to be called after being deployed behind a proxy._ + +### sendSignal + +```solidity +function sendSignal(bytes32 signal) public returns (bytes32 storageSlot) +``` + +Send a signal by storing the key with a value of 1. + +#### Parameters + +| Name | Type | Description | +| ------ | ------- | ------------------- | +| signal | bytes32 | The signal to send. | + +#### Return Values + +| Name | Type | Description | +| ----------- | ------- | -------------------------------------------------- | +| storageSlot | bytes32 | The slot in storage that this signal is persisted. | + +### isSignalSent + +```solidity +function isSignalSent(address app, bytes32 signal) public view returns (bool) +``` + +Check if a signal has been sent (key stored with a value of 1). + +#### Parameters + +| Name | Type | Description | +| ------ | ------- | ----------------------------------- | +| app | address | The address that sent this message. | +| signal | bytes32 | The signal to check. | + +### isSignalReceived + +```solidity +function isSignalReceived(uint256 srcChainId, address app, bytes32 signal, bytes proof) public view returns (bool) +``` + +Check if signal has been received on the destination chain (current). + +#### Parameters + +| Name | Type | Description | +| ---------- | ------- | ------------------------------------------------------- | +| srcChainId | uint256 | The source chain ID. | +| app | address | The address that sent this message. | +| signal | bytes32 | The signal to check. | +| proof | bytes | The proof of the signal being sent on the source chain. | + +### getSignalSlot + +```solidity +function getSignalSlot(address app, bytes32 signal) public pure returns (bytes32 signalSlot) +``` + +#### Parameters + +| Name | Type | Description | +| ------ | ------- | ------------------------------------------- | +| app | address | The srcAddress of the app (eg. the Bridge). | +| signal | bytes32 | The signal to store. | + +#### Return Values + +| Name | Type | Description | +| ---------- | ------- | ----------------------------------------------------- | +| signalSlot | bytes32 | The storage key for the signal on the signal service. | + +--- + +## title: ProxiedSignalService + +## ProxiedSignalService