diff --git a/.gitignore b/.gitignore index d0bf13c1..0447d637 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,16 @@ node_modules/ build/ -.idea -pids -logs +out/ .idea/ -contracts/flattened/*.sol \ No newline at end of file +pids/ +logs/ +cache/ + +contracts/flattened/*.sol + +# foundry lib +lib/forge-std/ + +.env +package-lock.json +yarn.lock diff --git a/.soliumignore b/.soliumignore deleted file mode 100644 index 9894f8e2..00000000 --- a/.soliumignore +++ /dev/null @@ -1,9 +0,0 @@ -node_modules -contracts/Migrations.sol -contracts/Seriality -contracts/tool -contracts/flattened -contracts/interface -contracts/mock -contracts/test -contracts/lib \ No newline at end of file diff --git a/.soliumrc.json b/.soliumrc.json deleted file mode 100644 index 008b565d..00000000 --- a/.soliumrc.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "solium:recommended", - "plugins": ["security"], - "rules": { - "quotes": ["error", "double"], - "indentation": ["error", 2], - "linebreak-style": ["error", "unix"] - } -} diff --git a/BLSkeystore.json b/BLSkeystore.json new file mode 100644 index 00000000..908cffe2 --- /dev/null +++ b/BLSkeystore.json @@ -0,0 +1,45 @@ +{ + "public_key": [ + "8f2bc5decb56ad5f88d4c704f6ad616d5038cf1bc068419f4d7f3457a853d74048b1ba3531185d6d36d6bd6881034505", + "83126cd32592a6be5e9658805c5da32db2f5d39f2f294a230cf1689b52f8b8be2135802f6b6ca6b11765331de2bb8def", + "b9cafd2354b57acadd88992fd9dc38986ec29d8efd793acb693f0d0f6b8397cb2a9f8d66e01253579c7d38242d3760f6", + "b373f6a4dfc54e625c2796da0789cbb243e6a285329c3c075ab1a9268db45951a2d6c2a2aafd558efc8c5857bd71dbc0", + "ac0646a7851a75f2d0d8239e717ed1874ed83906eff3845cc7a29abd6064adb8a48c221c3d12624f136292b19c0d92de", + "992354e0ff65e8cb4088a72a241992bf68a192ea685f810bda7a193dc056af3be4bf1f65073cf5e906676d32f2eabe60", + "95d8bb8660a34a374a05a3b9c59609f4a6f5598bba8240b59ef61e94ed6161e00108bac0b817bcb4cf13001924d19539", + "b4c030c9c012ab39aea3117fc96203b18ffb5e979ae44f17de64e212a1a97975d419e2060294940a285778e2100ff023", + "ac1e598ae0ccbeeaafa31bc6faefa85c2ae3138699cac79169cd718f1a38445201454ec092a86f200e08a15266bdc6e9", + "af3ca3f530c61bf7e6b82db58dc6bd4c75192044128004510290289330ae1d33269ec873e0a8e890c2619cf3868c8880", + "987c6c786c2d293f4b5337344c8d29ab0264f80851d5698e597e201f7743af3f848a1ffb7c4802a73e06696d99f95e45", + "97d9423cb780f6a09e759a7327fc5e2542ddc54f9d2cd1b836abf30948f45059709510e8421df03ceccf2ef2ecc9c594", + "b71f0d38cc1d05995126fa0ba311541f0ed3c5c7df64e33c8037afa5d72a5a38a83103433b204f1512502748656cf06f", + "b800c8a040b76946ca14470e7a67c9ca76bf9868730336be57235505e1786f3417a969587be2ac7e6aad1ab21db9cff9", + "a625e9aa0681a842091d9cbc26daa9497a9d305acc36d04f2cb42e9aed90a561514f607625fbf84b23f98ce4baadadb5", + "98a7250b7492047cdb0b388e094db5dc073bba5a4bfc9ed2fc0ec68cba5cec1aad06d72a91ed03211f583f52e5e5d221", + "a8fa139e60271c25de8d5c83a4d0d15107152c193897d2307d334425c40d31104b6ee507e5eb3402419bca0625b58835", + "905024253dae51eb1836a3da59e5883f48d768bb73b4c8be76fd3a124af6ed252941653619ab1e429253fc2586c65383", + "a52c02e1279cbadb974a02404d7cece18d70a2835d004a4e7a25c9e120d794f62e76b9728a13ee84bc6567716238c59f", + "aacd7b81831bc19de3a26f013d2bba8cf5a76cf3c6acee742bace02e2a809a96f72245fb6cb54874b72d300a42b14fe3", + "8f16d65d4898459265d237328b419fad130b2cf2ee381e0a0fc3d5898e81b577a0157d0b99b92eda8891b46ff62c9ea9", + "90ddfd09c9af4d0b693a4013b7e42595ea7bb60ee7fb942a8460d63cd5f0e4c3138467b7c2a50518fa26fe9a2450dbc0", + "a2ec2a7e46bb5d99e7307c39b9ba96e0ef245e2588658b5ccb9a8c2f682a111de5775fec6e7508d19e06be40a260cc7d", + "86d0488587c7dd682988d13c7db0bf9994dd21fa886244a1ddd24aea753de38d32d0c762bd6fbeb137b1ae3118c65885", + "b3e34b6aff02bf146faf47e27d813e3c1bcf2a9a424c2ec95da39ea9dd974aeb239e47bd183ac75e8502ca6e610caf7c", + "b45752f376347597826c52202dd5a4695b7f73b4a111d9a39f8bd43220984ecd428280779befa314f4b24ce537b7448b", + "83c96f5cab6a2d0fb3c4c96c7a1bf992c776f10aa6e321157df8b07359bbfdc111587f529d3ed867b1c69a98f57fea6b", + "9107b995298a0a2becc7a1feecc6d8a0cae95d66384ef08adb9dc74023357fb5c1dac1ce9de936eb4015d276150a4933", + "aa7049b3ce18e503b8546b08ef48056780cfeb4a48e50f30d0da8a2b6261e77ed19c40bc8050df874e992072db591575", + "b28f8221b85d07f04d6037a56d96e621d4c25bf3aaff3e745231bcf102dfa34508ca92814854019487b6dcecdaa0bab0", + "a75e47260f047889767fc8cc7121440afa2b4fc372ebc1ef39f72912247ad2efa1e0dc4022d4c44ecab95032fa30df49", + "a76daaa9e8741e7d9a5970f10bc585ce42a3e5ce4e53faadf3327a3b7759223e35aeb30214c0ecf2bca46a2ea1c45855", + "a031dcf5b47643630aba6e0625c21da9e0f76388ea6bcdd33ede31f51a1d080ba322ba0c9aaa5137b18fd3c47453aec9", + "a9be92a80b0909c491cd9475001cc34ee1a766b95109cdc32c8cdfcf7135c8d0e862b8612d0ea79e74d02a09d5403993", + "b490893e8eb5f101b5178e6ff8279fe14eb78b764290095e6e595dfcc11371925dc0af4b9d4bce8e69ac83ce57984e3a", + "89ca38e186e1378b0778cb8d4f0f6d4eef4a15db97a4596a44621548090dfb893f833689b580b0f60a934fd31c271bb3", + "8b20e24ad933b9af0a55a6d34a08e10b832a10f389154dc0dec79b63a38b79ea2f0d9f4fa664b3c06b1b2437cb58236f", + "a1484f2b97137fb957daad064ca6cbe5b99549249ceb51f42e928ec091f94fed642ddffe3a9916769538decd0a9937bf", + "89abcc45efe76bec679ca35c27adbd66fb9712a278e3c8530ab25cfaf997765aee574f5c5745dbb873dbf7e961684347", + "8addebd6ef7609df215e006987040d0a643858f3a4d791beaa77177d67529160e645fac54f0d8acdcd5a088393cb6681", + "85e6972fc98cd3c81d64d40e325acfed44365b97a7567a27939c14dbc7512ddcf54cb1284eb637cfa308ae4e00cb5588" + ] +} \ No newline at end of file diff --git a/README.md b/README.md index f10b0dae..b37ba89c 100644 --- a/README.md +++ b/README.md @@ -1,49 +1,65 @@ # bsc-genesis-contracts -This repo hold all the genesis contracts on Binance Smart chain. More details in [doc-site](https://github.com/binance-chain/docs-site/blob/add-bsc/docs/smart-chain/guides/concepts/system-contract.md). +This repo hold all the genesis contracts on Binance Smart chain. More details in [doc-site](https://docs.bnbchain.org/docs/learn/system-contract). ## Prepare -Install dependency: +Install node.js dependency: ```shell script npm install -``` - -## unit test +``` -Generate contracts for testing: +Install foundry: ```shell script -# the first account of ganache -node generate-system.js --mock true -node generate-systemReward.js --mock true -node generate-validatorset.js --mock true -node generate-system.js --mock true -node generate-slash.js --mock true -node generate-crosschain.js --mock true -node generate-tokenhub.js --mock true -node generate-tendermintlightclient.js --mock true -node generate-relayerincentivizecontract.js --roundSize 30 --maximumWeight 3 --mock true -``` - -Start ganache: -```shell script -ganache-cli --mnemonic 'clock radar mass judge dismiss just intact mind resemble fringe diary casino' --gasLimit 13000000 -e 10000 +curl -L https://foundry.paradigm.xyz | bash +foundryup +forge install --no-git --no-commit foundry-rs/forge-std@v1.1.1 +``` + +Please make sure your dependency version is as follows: + +Node: v12.18.3 + +Truffle: v5.1.31 + +Solc: 0.6.4+commit.1dca32f3 + +Tips: You can manage multi version of Solc and Node: +```Shell +## Install solc-select and solc +pip3 install solc-select +solc-select install 0.6.4 && solc-select use 0.6.4 + +## Install nvm and node +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash +nvm install 12.18.3 && nvm use 12.18.3 +``` + +## Unit test + +Add follow line to .env file in project dir, replace `archive_node` with a valid bsc mainnet node url which should be in archive mode: + +```text +RPC_BSC=${archive_node} ``` -Run truffle test: +You can get a free archive node endpoint from https://nodereal.io/. + +Run forge test: ```shell script -truffle compile -truffle migrate -truffle test +forge test ``` -Flatten all system contracts: +## Flatten all system contracts + ```shell script npm run flatten ``` -## how to generate genesis file. - +All system contracts will be flattened and output into `${workspace}/contracts/flattened/`. + +## How to generate genesis file + 1. Edit `init_holders.js` file to alloc the initial BNB holder. 2. Edit `validators.js` file to alloc the initial validator set. 3. Edit `generate-validatorset.js` file to change `fromChainId` and `toChainId`, @@ -51,6 +67,25 @@ npm run flatten 5. Edit `generate-tendermintlightclient.js` file to change `chainID` and `initConsensusStateBytes`. 6. run ` node generate-genesis.js` will generate genesis.json +## How to generate mainnet/testnet/QA genesis file + +```shell +npm run generate-mainnet +npm run generate-testnet +npm run generate-QA +``` +Check the `genesis.json` file and you can get the exact compiled bytecode for different network. + +## How to update contract interface for test + +```shell script +// get metadata +forge build + +// generate interface +cast interface ${workspace}/out/{contract_name}.sol/${contract_name}.json -p ^0.8.10 -n ${contract_name} > ${workspace}/lib/interface/I${contract_name}.sol +``` + ## License The library is licensed under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0), diff --git a/abi/README.md b/abi/README.md index e41b9d7d..dbbf341d 100644 --- a/abi/README.md +++ b/abi/README.md @@ -1,14 +1,15 @@ # ABI Files for Build-In System Contracts -| Contract Name | Address | ABI file name | -| ----------------------|-------------------------------------------|--------------------------------------------------- | -| BSCValidatorSet |0x0000000000000000000000000000000000001000 | [bscvalidatorset](bscvalidatorset.abi) | -| SlashIndicator |0x0000000000000000000000000000000000001001 | [slashindicator](slashindicator.abi) | -| SystemReward |0x0000000000000000000000000000000000001002 | [systemreward](systemreward.abi) | -| TendermintLightClient |0x0000000000000000000000000000000000001003 | [tendermintlightclient](tendermintlightclient.abi) | -| TokenHub |0x0000000000000000000000000000000000001004 | [tokenhub](tokenhub.abi) | -| RelayerIncentivize |0x0000000000000000000000000000000000001005 | [relayerincentivize](relayerincentivize.abi) | -| RelayerHub |0x0000000000000000000000000000000000001006 | [relayerhub](relayerhub.abi) | -| GovHub |0x0000000000000000000000000000000000001007 | [govhub](govhub.abi) | -| TokenManager |0x0000000000000000000000000000000000001008 | [tokenmanager](tokenmanager.abi) | -| CrossChain |0x0000000000000000000000000000000000002000 | [crosschain](crosschain.abi) | \ No newline at end of file +| Contract Name | Address | ABI file name | +|-----------------------|--------------------------------------------|----------------------------------------------------| +| BSCValidatorSet | 0x0000000000000000000000000000000000001000 | [bscvalidatorset](bscvalidatorset.abi) | +| SlashIndicator | 0x0000000000000000000000000000000000001001 | [slashindicator](slashindicator.abi) | +| SystemReward | 0x0000000000000000000000000000000000001002 | [systemreward](systemreward.abi) | +| TendermintLightClient | 0x0000000000000000000000000000000000001003 | [tendermintlightclient](tendermintlightclient.abi) | +| TokenHub | 0x0000000000000000000000000000000000001004 | [tokenhub](tokenhub.abi) | +| RelayerIncentivize | 0x0000000000000000000000000000000000001005 | [relayerincentivize](relayerincentivize.abi) | +| RelayerHub | 0x0000000000000000000000000000000000001006 | [relayerhub](relayerhub.abi) | +| GovHub | 0x0000000000000000000000000000000000001007 | [govhub](govhub.abi) | +| TokenManager | 0x0000000000000000000000000000000000001008 | [tokenmanager](tokenmanager.abi) | +| CrossChain | 0x0000000000000000000000000000000000002000 | [crosschain](crosschain.abi) | +| Staking | 0x0000000000000000000000000000000000002001 | [staking](staking.abi) | \ No newline at end of file diff --git a/abi/bscvalidatorset.abi b/abi/bscvalidatorset.abi index c3194b70..207effaf 100644 --- a/abi/bscvalidatorset.abi +++ b/abi/bscvalidatorset.abi @@ -1,1016 +1,1451 @@ [ - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "batchTransfer", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "string", - "name": "reason", - "type": "string" - } - ], - "name": "batchTransferFailed", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "reason", - "type": "bytes" - } - ], - "name": "batchTransferLowerFailed", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "validator", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "deprecatedDeposit", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address payable", - "name": "validator", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "directTransfer", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address payable", - "name": "validator", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "directTransferFail", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "string", - "name": "message", - "type": "string" - } - ], - "name": "failReasonWithStr", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "string", - "name": "key", - "type": "string" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "value", - "type": "bytes" - } - ], - "name": "paramChange", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "systemTransfer", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint8", - "name": "channelId", - "type": "uint8" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "msgBytes", - "type": "bytes" - } - ], - "name": "unexpectedPackage", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "validator", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "validatorDeposit", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "validator", - "type": "address" - } - ], - "name": "validatorEmptyJailed", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "validator", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "validatorFelony", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "validator", - "type": "address" - } - ], - "name": "validatorJailed", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "validator", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "validatorMisdemeanor", - "type": "event" - }, - { - "anonymous": false, - "inputs": [], - "name": "validatorSetUpdated", - "type": "event" - }, - { - "constant": true, - "inputs": [], - "name": "BIND_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "CODE_OK", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "CROSS_CHAIN_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "DUSTY_INCOMING", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "ERROR_FAIL_CHECK_VALIDATORS", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "ERROR_FAIL_DECODE", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "ERROR_LEN_OF_VAL_MISMATCH", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "ERROR_RELAYFEE_TOO_LARGE", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "ERROR_UNKNOWN_PACKAGE_TYPE", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "EXPIRE_TIME_SECOND_GAP", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "GOV_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "GOV_HUB_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "INCENTIVIZE_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "INIT_VALIDATORSET_BYTES", - "outputs": [ - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "JAIL_MESSAGE_TYPE", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "LIGHT_CLIENT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "MAX_NUM_OF_VALIDATORS", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "PRECISION", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "RELAYERHUB_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SLASH_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SLASH_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "STAKING_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SYSTEM_REWARD_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TOKEN_HUB_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TOKEN_MANAGER_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TRANSFER_IN_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TRANSFER_OUT_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "VALIDATORS_UPDATE_MESSAGE_TYPE", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "VALIDATOR_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "alreadyInit", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "bscChainID", - "outputs": [ - { - "internalType": "uint16", - "name": "", - "type": "uint16" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "currentValidatorSet", - "outputs": [ - { - "internalType": "address", - "name": "consensusAddress", - "type": "address" - }, - { - "internalType": "address payable", - "name": "feeAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "BBCFeeAddress", - "type": "address" - }, - { - "internalType": "uint64", - "name": "votingPower", - "type": "uint64" - }, - { - "internalType": "bool", - "name": "jailed", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "incoming", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "currentValidatorSetMap", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "expireTimeSecondGap", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "numOfJailed", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "totalInComing", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [], - "name": "init", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - }, - { - "internalType": "bytes", - "name": "msgBytes", - "type": "bytes" - } - ], - "name": "handleSynPackage", - "outputs": [ - { - "internalType": "bytes", - "name": "responsePayload", - "type": "bytes" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "uint8", - "name": "channelId", - "type": "uint8" - }, - { - "internalType": "bytes", - "name": "msgBytes", - "type": "bytes" - } - ], - "name": "handleAckPackage", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "uint8", - "name": "channelId", - "type": "uint8" - }, - { - "internalType": "bytes", - "name": "msgBytes", - "type": "bytes" - } - ], - "name": "handleFailAckPackage", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "valAddr", - "type": "address" - } - ], - "name": "deposit", - "outputs": [], - "payable": true, - "stateMutability": "payable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getValidators", - "outputs": [ - { - "internalType": "address[]", - "name": "", - "type": "address[]" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "validator", - "type": "address" - } - ], - "name": "getIncoming", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "validator", - "type": "address" - } - ], - "name": "misdemeanor", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "validator", - "type": "address" - } - ], - "name": "felony", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "string", - "name": "key", - "type": "string" - }, - { - "internalType": "bytes", - "name": "value", - "type": "bytes" - } - ], - "name": "updateParam", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - } + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "batchTransfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "string", + "name": "reason", + "type": "string" + } + ], + "name": "batchTransferFailed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "reason", + "type": "bytes" + } + ], + "name": "batchTransferLowerFailed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "validator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "deprecatedDeposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "validator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "deprecatedFinalityRewardDeposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address payable", + "name": "validator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "directTransfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address payable", + "name": "validator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "directTransferFail", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "message", + "type": "string" + } + ], + "name": "failReasonWithStr", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "feeBurned", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "validator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "finalityRewardDeposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "key", + "type": "string" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "paramChange", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "systemTransfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "channelId", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "msgBytes", + "type": "bytes" + } + ], + "name": "unexpectedPackage", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "validator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "validatorDeposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "validator", + "type": "address" + } + ], + "name": "validatorEmptyJailed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "validator", + "type": "address" + } + ], + "name": "validatorEnterMaintenance", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "validator", + "type": "address" + } + ], + "name": "validatorExitMaintenance", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "validator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "validatorFelony", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "validator", + "type": "address" + } + ], + "name": "validatorJailed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "validator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "validatorMisdemeanor", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "validatorSetUpdated", + "type": "event" + }, + { + "inputs": [], + "name": "BIND_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "BURN_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "BURN_RATIO_SCALE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CODE_OK", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CROSS_CHAIN_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CROSS_STAKE_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "DUSTY_INCOMING", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "EPOCH", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ERROR_FAIL_CHECK_VALIDATORS", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ERROR_FAIL_DECODE", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ERROR_LEN_OF_VAL_MISMATCH", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ERROR_RELAYFEE_TOO_LARGE", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ERROR_UNKNOWN_PACKAGE_TYPE", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "EXPIRE_TIME_SECOND_GAP", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "GOV_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "GOV_HUB_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INCENTIVIZE_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INIT_BURN_RATIO", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INIT_FINALITY_REWARD_RATIO", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INIT_MAINTAIN_SLASH_SCALE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INIT_MAX_NUM_OF_MAINTAINING", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INIT_NUM_OF_CABINETS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INIT_VALIDATORSET_BYTES", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "JAIL_MESSAGE_TYPE", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "LIGHT_CLIENT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_NUM_OF_VALIDATORS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PRECISION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RELAYERHUB_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SLASH_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SLASH_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKING_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKING_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SYSTEM_REWARD_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TOKEN_HUB_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TOKEN_MANAGER_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_IN_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_OUT_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "VALIDATORS_UPDATE_MESSAGE_TYPE", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "VALIDATOR_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "alreadyInit", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "bscChainID", + "outputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "burnRatio", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "burnRatioInitialized", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "canEnterMaintenance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "currentValidatorSet", + "outputs": [ + { + "internalType": "address", + "name": "consensusAddress", + "type": "address" + }, + { + "internalType": "address payable", + "name": "feeAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "BBCFeeAddress", + "type": "address" + }, + { + "internalType": "uint64", + "name": "votingPower", + "type": "uint64" + }, + { + "internalType": "bool", + "name": "jailed", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "incoming", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "currentValidatorSetMap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "valAddr", + "type": "address" + } + ], + "name": "deposit", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "valAddrs", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "weights", + "type": "uint256[]" + } + ], + "name": "distributeFinalityReward", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "enterMaintenance", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "exitMaintenance", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "expireTimeSecondGap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "validator", + "type": "address" + } + ], + "name": "felony", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "finalityRewardRatio", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_validator", + "type": "address" + } + ], + "name": "getCurrentValidatorIndex", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "validator", + "type": "address" + } + ], + "name": "getIncoming", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getLivingValidators", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + }, + { + "internalType": "bytes[]", + "name": "", + "type": "bytes[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getMiningValidators", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + }, + { + "internalType": "bytes[]", + "name": "", + "type": "bytes[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getValidators", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getWorkingValidatorCount", + "outputs": [ + { + "internalType": "uint256", + "name": "workingValidatorCount", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "channelId", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "msgBytes", + "type": "bytes" + } + ], + "name": "handleAckPackage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "channelId", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "msgBytes", + "type": "bytes" + } + ], + "name": "handleFailAckPackage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "msgBytes", + "type": "bytes" + } + ], + "name": "handleSynPackage", + "outputs": [ + { + "internalType": "bytes", + "name": "responsePayload", + "type": "bytes" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "init", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "validator", + "type": "address" + } + ], + "name": "isCurrentValidator", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "isWorkingValidator", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maintainSlashScale", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxNumOfCandidates", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxNumOfMaintaining", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxNumOfWorkingCandidates", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "validator", + "type": "address" + } + ], + "name": "misdemeanor", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "numOfCabinets", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "numOfJailed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "numOfMaintaining", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "previousHeight", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalInComing", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "key", + "type": "string" + }, + { + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "updateParam", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "validatorExtraSet", + "outputs": [ + { + "internalType": "uint256", + "name": "enterMaintenanceHeight", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "isMaintaining", + "type": "bool" + }, + { + "internalType": "bytes", + "name": "voteAddress", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } ] \ No newline at end of file diff --git a/abi/crosschain.abi b/abi/crosschain.abi index 815d0054..f8291385 100644 --- a/abi/crosschain.abi +++ b/abi/crosschain.abi @@ -1,864 +1,829 @@ [ - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint8", - "name": "channelId", - "type": "uint8" - }, - { - "indexed": true, - "internalType": "address", - "name": "contractAddr", - "type": "address" - } - ], - "name": "addChannel", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint16", - "name": "chainId", - "type": "uint16" - }, - { - "indexed": true, - "internalType": "uint64", - "name": "oracleSequence", - "type": "uint64" - }, - { - "indexed": true, - "internalType": "uint64", - "name": "packageSequence", - "type": "uint64" - }, - { - "indexed": true, - "internalType": "uint8", - "name": "channelId", - "type": "uint8" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "payload", - "type": "bytes" - } - ], - "name": "crossChainPackage", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint8", - "name": "channelId", - "type": "uint8" - }, - { - "indexed": false, - "internalType": "bool", - "name": "isEnable", - "type": "bool" - } - ], - "name": "enableOrDisableChannel", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "string", - "name": "key", - "type": "string" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "value", - "type": "bytes" - } - ], - "name": "paramChange", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint8", - "name": "packageType", - "type": "uint8" - }, - { - "indexed": true, - "internalType": "uint64", - "name": "packageSequence", - "type": "uint64" - }, - { - "indexed": true, - "internalType": "uint8", - "name": "channelId", - "type": "uint8" - } - ], - "name": "receivedPackage", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "contractAddr", - "type": "address" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "lowLevelData", - "type": "bytes" - } - ], - "name": "unexpectedFailureAssertionInPackageHandler", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "contractAddr", - "type": "address" - }, - { - "indexed": false, - "internalType": "string", - "name": "reason", - "type": "string" - } - ], - "name": "unexpectedRevertInPackageHandler", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint64", - "name": "packageSequence", - "type": "uint64" - }, - { - "indexed": true, - "internalType": "uint8", - "name": "channelId", - "type": "uint8" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "payload", - "type": "bytes" - } - ], - "name": "unsupportedPackage", - "type": "event" - }, - { - "constant": true, - "inputs": [], - "name": "ACK_PACKAGE", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "BIND_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "CODE_OK", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "CROSS_CHAIN_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "CROSS_CHAIN_KEY_PREFIX", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "ERROR_FAIL_DECODE", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "FAIL_ACK_PACKAGE", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "GOV_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "GOV_HUB_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "INCENTIVIZE_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "INIT_BATCH_SIZE", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "LIGHT_CLIENT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "RELAYERHUB_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SLASH_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SLASH_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "STAKING_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "STORE_NAME", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SYN_PACKAGE", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SYSTEM_REWARD_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TOKEN_HUB_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TOKEN_MANAGER_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TRANSFER_IN_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TRANSFER_OUT_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "VALIDATOR_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "alreadyInit", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "batchSizeForOracle", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "bscChainID", - "outputs": [ - { - "internalType": "uint16", - "name": "", - "type": "uint16" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "name": "channelHandlerContractMap", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "name": "channelReceiveSequenceMap", - "outputs": [ - { - "internalType": "uint64", - "name": "", - "type": "uint64" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "name": "channelSendSequenceMap", - "outputs": [ - { - "internalType": "uint64", - "name": "", - "type": "uint64" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "name": "isRelayRewardFromSystemReward", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "oracleSequence", - "outputs": [ - { - "internalType": "int64", - "name": "", - "type": "int64" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "previousTxHeight", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "name": "registeredContractChannelMap", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "txCounter", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [], - "name": "init", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "uint8", - "name": "packageType", - "type": "uint8" - }, - { - "internalType": "uint256", - "name": "relayFee", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "msgBytes", - "type": "bytes" - } - ], - "name": "encodePayload", - "outputs": [ - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "payable": false, - "stateMutability": "pure", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "bytes", - "name": "payload", - "type": "bytes" - }, - { - "internalType": "bytes", - "name": "proof", - "type": "bytes" - }, - { - "internalType": "uint64", - "name": "height", - "type": "uint64" - }, - { - "internalType": "uint64", - "name": "packageSequence", - "type": "uint64" - }, - { - "internalType": "uint8", - "name": "channelId", - "type": "uint8" - } - ], - "name": "handlePackage", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "uint8", - "name": "channelId", - "type": "uint8" - }, - { - "internalType": "bytes", - "name": "msgBytes", - "type": "bytes" - }, - { - "internalType": "uint256", - "name": "relayFee", - "type": "uint256" - } - ], - "name": "sendSynPackage", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "string", - "name": "key", - "type": "string" - }, - { - "internalType": "bytes", - "name": "value", - "type": "bytes" - } - ], - "name": "updateParam", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - } + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint8", + "name": "channelId", + "type": "uint8" + }, + { + "indexed": true, + "internalType": "address", + "name": "contractAddr", + "type": "address" + } + ], + "name": "addChannel", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint16", + "name": "chainId", + "type": "uint16" + }, + { + "indexed": true, + "internalType": "uint64", + "name": "oracleSequence", + "type": "uint64" + }, + { + "indexed": true, + "internalType": "uint64", + "name": "packageSequence", + "type": "uint64" + }, + { + "indexed": true, + "internalType": "uint8", + "name": "channelId", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "payload", + "type": "bytes" + } + ], + "name": "crossChainPackage", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint8", + "name": "channelId", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isEnable", + "type": "bool" + } + ], + "name": "enableOrDisableChannel", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "key", + "type": "string" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "paramChange", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "packageType", + "type": "uint8" + }, + { + "indexed": true, + "internalType": "uint64", + "name": "packageSequence", + "type": "uint64" + }, + { + "indexed": true, + "internalType": "uint8", + "name": "channelId", + "type": "uint8" + } + ], + "name": "receivedPackage", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "contractAddr", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "lowLevelData", + "type": "bytes" + } + ], + "name": "unexpectedFailureAssertionInPackageHandler", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "contractAddr", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "reason", + "type": "string" + } + ], + "name": "unexpectedRevertInPackageHandler", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint64", + "name": "packageSequence", + "type": "uint64" + }, + { + "indexed": true, + "internalType": "uint8", + "name": "channelId", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "payload", + "type": "bytes" + } + ], + "name": "unsupportedPackage", + "type": "event" + }, + { + "inputs": [], + "name": "ACK_PACKAGE", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "BIND_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CODE_OK", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CROSS_CHAIN_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CROSS_CHAIN_KEY_PREFIX", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CROSS_STAKE_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ERROR_FAIL_DECODE", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "FAIL_ACK_PACKAGE", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "GOV_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "GOV_HUB_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INCENTIVIZE_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INIT_BATCH_SIZE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "LIGHT_CLIENT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RELAYERHUB_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SLASH_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SLASH_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKING_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKING_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STORE_NAME", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SYN_PACKAGE", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SYSTEM_REWARD_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TOKEN_HUB_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TOKEN_MANAGER_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_IN_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_OUT_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "VALIDATOR_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "alreadyInit", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "batchSizeForOracle", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "bscChainID", + "outputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "name": "channelHandlerContractMap", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "name": "channelReceiveSequenceMap", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "name": "channelSendSequenceMap", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "name": "channelSyncedHeaderMap", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "packageType", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "relayFee", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "msgBytes", + "type": "bytes" + } + ], + "name": "encodePayload", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "payload", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "proof", + "type": "bytes" + }, + { + "internalType": "uint64", + "name": "height", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "packageSequence", + "type": "uint64" + }, + { + "internalType": "uint8", + "name": "channelId", + "type": "uint8" + } + ], + "name": "handlePackage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "init", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "name": "isRelayRewardFromSystemReward", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "oracleSequence", + "outputs": [ + { + "internalType": "int64", + "name": "", + "type": "int64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "previousTxHeight", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "name": "registeredContractChannelMap", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "channelId", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "msgBytes", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "relayFee", + "type": "uint256" + } + ], + "name": "sendSynPackage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "txCounter", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "key", + "type": "string" + }, + { + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "updateParam", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } ] \ No newline at end of file diff --git a/abi/govhub.abi b/abi/govhub.abi index 981fd424..cbd6ff0a 100644 --- a/abi/govhub.abi +++ b/abi/govhub.abi @@ -1,458 +1,432 @@ [ - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes", - "name": "message", - "type": "bytes" - } - ], - "name": "failReasonWithBytes", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "string", - "name": "message", - "type": "string" - } - ], - "name": "failReasonWithStr", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "string", - "name": "key", - "type": "string" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "value", - "type": "bytes" - } - ], - "name": "paramChange", - "type": "event" - }, - { - "constant": true, - "inputs": [], - "name": "BIND_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "CODE_OK", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "CROSS_CHAIN_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "ERROR_FAIL_DECODE", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "ERROR_TARGET_CONTRACT_FAIL", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "ERROR_TARGET_NOT_CONTRACT", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "GOV_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "GOV_HUB_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "INCENTIVIZE_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "LIGHT_CLIENT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "PARAM_UPDATE_MESSAGE_TYPE", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "RELAYERHUB_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SLASH_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SLASH_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "STAKING_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SYSTEM_REWARD_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TOKEN_HUB_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TOKEN_MANAGER_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TRANSFER_IN_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TRANSFER_OUT_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "VALIDATOR_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "alreadyInit", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "bscChainID", - "outputs": [ - { - "internalType": "uint16", - "name": "", - "type": "uint16" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - }, - { - "internalType": "bytes", - "name": "msgBytes", - "type": "bytes" - } - ], - "name": "handleSynPackage", - "outputs": [ - { - "internalType": "bytes", - "name": "responsePayload", - "type": "bytes" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - }, - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "name": "handleAckPackage", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - }, - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "name": "handleFailAckPackage", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - } + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes", + "name": "message", + "type": "bytes" + } + ], + "name": "failReasonWithBytes", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "message", + "type": "string" + } + ], + "name": "failReasonWithStr", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "key", + "type": "string" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "paramChange", + "type": "event" + }, + { + "inputs": [], + "name": "BIND_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CODE_OK", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CROSS_CHAIN_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CROSS_STAKE_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ERROR_FAIL_DECODE", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ERROR_TARGET_CONTRACT_FAIL", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ERROR_TARGET_NOT_CONTRACT", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "GOV_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "GOV_HUB_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INCENTIVIZE_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "LIGHT_CLIENT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PARAM_UPDATE_MESSAGE_TYPE", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RELAYERHUB_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SLASH_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SLASH_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKING_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKING_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SYSTEM_REWARD_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TOKEN_HUB_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TOKEN_MANAGER_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_IN_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_OUT_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "VALIDATOR_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "alreadyInit", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "bscChainID", + "outputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "handleAckPackage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "handleFailAckPackage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "msgBytes", + "type": "bytes" + } + ], + "name": "handleSynPackage", + "outputs": [ + { + "internalType": "bytes", + "name": "responsePayload", + "type": "bytes" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } ] \ No newline at end of file diff --git a/abi/relayerhub.abi b/abi/relayerhub.abi index 719c4cc6..b712a5c7 100644 --- a/abi/relayerhub.abi +++ b/abi/relayerhub.abi @@ -1,475 +1,443 @@ [ - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "string", - "name": "key", - "type": "string" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "value", - "type": "bytes" - } - ], - "name": "paramChange", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "_relayer", - "type": "address" - } - ], - "name": "relayerRegister", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "_relayer", - "type": "address" - } - ], - "name": "relayerUnRegister", - "type": "event" - }, - { - "constant": true, - "inputs": [], - "name": "BIND_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "CODE_OK", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "CROSS_CHAIN_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "ERROR_FAIL_DECODE", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "GOV_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "GOV_HUB_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "INCENTIVIZE_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "INIT_DUES", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "INIT_REQUIRED_DEPOSIT", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "LIGHT_CLIENT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "RELAYERHUB_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SLASH_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SLASH_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "STAKING_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SYSTEM_REWARD_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TOKEN_HUB_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TOKEN_MANAGER_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TRANSFER_IN_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TRANSFER_OUT_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "VALIDATOR_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "alreadyInit", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "bscChainID", - "outputs": [ - { - "internalType": "uint16", - "name": "", - "type": "uint16" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "dues", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "requiredDeposit", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [], - "name": "init", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [], - "name": "register", - "outputs": [], - "payable": true, - "stateMutability": "payable", - "type": "function" - }, - { - "constant": false, - "inputs": [], - "name": "unregister", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "string", - "name": "key", - "type": "string" - }, - { - "internalType": "bytes", - "name": "value", - "type": "bytes" - } - ], - "name": "updateParam", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "isRelayer", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - } + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "key", + "type": "string" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "paramChange", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_relayer", + "type": "address" + } + ], + "name": "relayerRegister", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_relayer", + "type": "address" + } + ], + "name": "relayerUnRegister", + "type": "event" + }, + { + "inputs": [], + "name": "BIND_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CODE_OK", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CROSS_CHAIN_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CROSS_STAKE_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ERROR_FAIL_DECODE", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "GOV_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "GOV_HUB_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INCENTIVIZE_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INIT_DUES", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INIT_REQUIRED_DEPOSIT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "LIGHT_CLIENT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RELAYERHUB_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SLASH_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SLASH_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKING_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKING_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SYSTEM_REWARD_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TOKEN_HUB_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TOKEN_MANAGER_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_IN_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_OUT_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "VALIDATOR_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "alreadyInit", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "bscChainID", + "outputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "dues", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "init", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "isRelayer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "register", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "requiredDeposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "unregister", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "key", + "type": "string" + }, + { + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "updateParam", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } ] \ No newline at end of file diff --git a/abi/relayerincentivize.abi b/abi/relayerincentivize.abi index b389ff6b..4cc97425 100644 --- a/abi/relayerincentivize.abi +++ b/abi/relayerincentivize.abi @@ -1,807 +1,755 @@ [ - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "sequence", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "roundRewardForHeaderRelayer", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "roundRewardForTransferRelayer", - "type": "uint256" - } - ], - "name": "distributeCollectedReward", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "string", - "name": "key", - "type": "string" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "value", - "type": "bytes" - } - ], - "name": "paramChange", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "relayer", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "rewardToRelayer", - "type": "event" - }, - { - "payable": true, - "stateMutability": "payable", - "type": "fallback" - }, - { - "constant": true, - "inputs": [], - "name": "BIND_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "CALLER_COMPENSATION_DENOMINATOR", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "CALLER_COMPENSATION_MOLECULE", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "CODE_OK", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "CROSS_CHAIN_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "ERROR_FAIL_DECODE", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "GOV_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "GOV_HUB_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "HEADER_RELAYER_REWARD_RATE_DENOMINATOR", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "HEADER_RELAYER_REWARD_RATE_MOLECULE", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "INCENTIVIZE_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "LIGHT_CLIENT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "MAXIMUM_WEIGHT", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "RELAYERHUB_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "ROUND_SIZE", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SLASH_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SLASH_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "STAKING_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SYSTEM_REWARD_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TOKEN_HUB_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TOKEN_MANAGER_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TRANSFER_IN_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TRANSFER_OUT_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "VALIDATOR_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "alreadyInit", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "bscChainID", - "outputs": [ - { - "internalType": "uint16", - "name": "", - "type": "uint16" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "callerCompensationDenominator", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "callerCompensationMolecule", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "collectedRewardForHeaderRelayer", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "collectedRewardForTransferRelayer", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "countInRound", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "headerRelayerAddressRecord", - "outputs": [ - { - "internalType": "address payable", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "headerRelayerRewardRateDenominator", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "headerRelayerRewardRateMolecule", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "headerRelayersSubmitCount", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "packageRelayerAddressRecord", - "outputs": [ - { - "internalType": "address payable", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "packageRelayersSubmitCount", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "relayerRewardVault", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "roundSequence", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [], - "name": "init", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address payable", - "name": "headerRelayerAddr", - "type": "address" - }, - { - "internalType": "address payable", - "name": "packageRelayer", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "fromSystemReward", - "type": "bool" - } - ], - "name": "addReward", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "relayerAddr", - "type": "address" - } - ], - "name": "claimRelayerReward", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "uint256", - "name": "count", - "type": "uint256" - } - ], - "name": "calculateTransferRelayerWeight", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "pure", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "uint256", - "name": "count", - "type": "uint256" - } - ], - "name": "calculateHeaderRelayerWeight", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "pure", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "string", - "name": "key", - "type": "string" - }, - { - "internalType": "bytes", - "name": "value", - "type": "bytes" - } - ], - "name": "updateParam", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - } + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "sequence", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "roundRewardForHeaderRelayer", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "roundRewardForTransferRelayer", + "type": "uint256" + } + ], + "name": "distributeCollectedReward", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "key", + "type": "string" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "paramChange", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "relayer", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "rewardToRelayer", + "type": "event" + }, + { + "inputs": [], + "name": "BIND_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CALLER_COMPENSATION_DENOMINATOR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CALLER_COMPENSATION_MOLECULE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CODE_OK", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CROSS_CHAIN_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CROSS_STAKE_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ERROR_FAIL_DECODE", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "GOV_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "GOV_HUB_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "HEADER_RELAYER_REWARD_RATE_DENOMINATOR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "HEADER_RELAYER_REWARD_RATE_MOLECULE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INCENTIVIZE_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "LIGHT_CLIENT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAXIMUM_WEIGHT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RELAYERHUB_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ROUND_SIZE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SLASH_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SLASH_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKING_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKING_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SYSTEM_REWARD_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TOKEN_HUB_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TOKEN_MANAGER_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_IN_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_OUT_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "VALIDATOR_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "headerRelayerAddr", + "type": "address" + }, + { + "internalType": "address payable", + "name": "packageRelayer", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "fromSystemReward", + "type": "bool" + } + ], + "name": "addReward", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "alreadyInit", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "bscChainID", + "outputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "count", + "type": "uint256" + } + ], + "name": "calculateHeaderRelayerWeight", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "count", + "type": "uint256" + } + ], + "name": "calculateTransferRelayerWeight", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "callerCompensationDenominator", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "callerCompensationMolecule", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "relayerAddr", + "type": "address" + } + ], + "name": "claimRelayerReward", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "collectedRewardForHeaderRelayer", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "collectedRewardForTransferRelayer", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "countInRound", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "dynamicExtraIncentiveAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "headerRelayerAddressRecord", + "outputs": [ + { + "internalType": "address payable", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "headerRelayerRewardRateDenominator", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "headerRelayerRewardRateMolecule", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "headerRelayersSubmitCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "init", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "packageRelayerAddressRecord", + "outputs": [ + { + "internalType": "address payable", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "packageRelayersSubmitCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "relayerRewardVault", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "roundSequence", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "key", + "type": "string" + }, + { + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "updateParam", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } ] \ No newline at end of file diff --git a/abi/slashindicator.abi b/abi/slashindicator.abi index 60eb3d90..99a044f5 100644 --- a/abi/slashindicator.abi +++ b/abi/slashindicator.abi @@ -1,674 +1,767 @@ [ - { - "anonymous": false, - "inputs": [], - "name": "crashResponse", - "type": "event" - }, - { - "anonymous": false, - "inputs": [], - "name": "indicatorCleaned", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint32", - "name": "code", - "type": "uint32" - } - ], - "name": "knownResponse", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "string", - "name": "key", - "type": "string" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "value", - "type": "bytes" - } - ], - "name": "paramChange", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint32", - "name": "code", - "type": "uint32" - } - ], - "name": "unKnownResponse", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "validator", - "type": "address" - } - ], - "name": "validatorSlashed", - "type": "event" - }, - { - "constant": true, - "inputs": [], - "name": "BIND_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "BSC_RELAYER_REWARD", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "CODE_OK", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "CROSS_CHAIN_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "DECREASE_RATE", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "ERROR_FAIL_DECODE", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "FELONY_THRESHOLD", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "GOV_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "GOV_HUB_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "INCENTIVIZE_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "LIGHT_CLIENT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "MISDEMEANOR_THRESHOLD", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "RELAYERHUB_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SLASH_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SLASH_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "STAKING_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SYSTEM_REWARD_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TOKEN_HUB_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TOKEN_MANAGER_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TRANSFER_IN_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TRANSFER_OUT_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "VALIDATOR_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "alreadyInit", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "bscChainID", - "outputs": [ - { - "internalType": "uint16", - "name": "", - "type": "uint16" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "felonyThreshold", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "indicators", - "outputs": [ - { - "internalType": "uint256", - "name": "height", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "count", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "exist", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "misdemeanorThreshold", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "previousHeight", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "validators", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [], - "name": "init", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - }, - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "name": "handleSynPackage", - "outputs": [ - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - }, - { - "internalType": "bytes", - "name": "msgBytes", - "type": "bytes" - } - ], - "name": "handleAckPackage", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - }, - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "name": "handleFailAckPackage", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "validator", - "type": "address" - } - ], - "name": "slash", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [], - "name": "clean", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "string", - "name": "key", - "type": "string" - }, - { - "internalType": "bytes", - "name": "value", - "type": "bytes" - } - ], - "name": "updateParam", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "validator", - "type": "address" - } - ], - "name": "getSlashIndicator", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - } + { + "anonymous": false, + "inputs": [], + "name": "crashResponse", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "indicatorCleaned", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint32", + "name": "code", + "type": "uint32" + } + ], + "name": "knownResponse", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "key", + "type": "string" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "paramChange", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint32", + "name": "code", + "type": "uint32" + } + ], + "name": "unKnownResponse", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "validator", + "type": "address" + } + ], + "name": "validatorSlashed", + "type": "event" + }, + { + "inputs": [], + "name": "BIND_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "BSC_RELAYER_REWARD", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CODE_OK", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CROSS_CHAIN_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CROSS_STAKE_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "DECREASE_RATE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ERROR_FAIL_DECODE", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "FELONY_THRESHOLD", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "GOV_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "GOV_HUB_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INCENTIVIZE_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INIT_FINALITY_SLASH_REWARD_RATIO", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "LIGHT_CLIENT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MISDEMEANOR_THRESHOLD", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RELAYERHUB_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SLASH_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SLASH_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKING_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKING_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SYSTEM_REWARD_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TOKEN_HUB_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TOKEN_MANAGER_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_IN_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_OUT_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "VALIDATOR_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "alreadyInit", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "bscChainID", + "outputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "clean", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "felonyThreshold", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "finalitySlashRewardRatio", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "validator", + "type": "address" + } + ], + "name": "getSlashIndicator", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getSlashThresholds", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "msgBytes", + "type": "bytes" + } + ], + "name": "handleAckPackage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "handleFailAckPackage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "handleSynPackage", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "indicators", + "outputs": [ + { + "internalType": "uint256", + "name": "height", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "count", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "exist", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "init", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "misdemeanorThreshold", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "previousHeight", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "validator", + "type": "address" + } + ], + "name": "sendFelonyPackage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "validator", + "type": "address" + } + ], + "name": "slash", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "components": [ + { + "internalType": "uint256", + "name": "srcNum", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "srcHash", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "tarNum", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "tarHash", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "sig", + "type": "bytes" + } + ], + "internalType": "struct SlashIndicator.VoteData", + "name": "voteA", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "srcNum", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "srcHash", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "tarNum", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "tarHash", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "sig", + "type": "bytes" + } + ], + "internalType": "struct SlashIndicator.VoteData", + "name": "voteB", + "type": "tuple" + }, + { + "internalType": "bytes", + "name": "voteAddr", + "type": "bytes" + } + ], + "internalType": "struct SlashIndicator.FinalityEvidence", + "name": "_evidence", + "type": "tuple" + } + ], + "name": "submitFinalityViolationEvidence", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "key", + "type": "string" + }, + { + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "updateParam", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "validators", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } ] \ No newline at end of file diff --git a/abi/staking.abi b/abi/staking.abi new file mode 100644 index 00000000..495bd05b --- /dev/null +++ b/abi/staking.abi @@ -0,0 +1,1280 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint8", + "name": "eventType", + "type": "uint8" + } + ], + "name": "crashResponse", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "validator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint8", + "name": "errCode", + "type": "uint8" + } + ], + "name": "delegateFailed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "validator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "relayerFee", + "type": "uint256" + } + ], + "name": "delegateSubmitted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "validator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "delegateSuccess", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint8", + "name": "eventType", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "errCode", + "type": "uint256" + } + ], + "name": "failedSynPackage", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "key", + "type": "string" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "paramChange", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "valSrc", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "valDst", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint8", + "name": "errCode", + "type": "uint8" + } + ], + "name": "redelegateFailed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "validatorSrc", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "validatorDst", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "relayerFee", + "type": "uint256" + } + ], + "name": "redelegateSubmitted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "valSrc", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "valDst", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "redelegateSuccess", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "rewardClaimed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "rewardReceived", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "validator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint8", + "name": "errCode", + "type": "uint8" + } + ], + "name": "undelegateFailed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "validator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "relayerFee", + "type": "uint256" + } + ], + "name": "undelegateSubmitted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "validator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "undelegateSuccess", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "undelegatedClaimed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "validator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "undelegatedReceived", + "type": "event" + }, + { + "inputs": [], + "name": "BIND_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CODE_FAILED", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CODE_OK", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CODE_SUCCESS", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CROSS_CHAIN_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CROSS_STAKE_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ERROR_FAIL_DECODE", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ERROR_WITHDRAW_BNB", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "EVENT_DELEGATE", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "EVENT_DISTRIBUTE_REWARD", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "EVENT_DISTRIBUTE_UNDELEGATED", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "EVENT_REDELEGATE", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "EVENT_UNDELEGATE", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "GOV_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "GOV_HUB_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INCENTIVIZE_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INIT_BSC_RELAYER_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INIT_MIN_DELEGATION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INIT_RELAYER_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INIT_TRANSFER_GAS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "LIGHT_CLIENT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "LOCK_TIME", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RELAYERHUB_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SLASH_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SLASH_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKING_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKING_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SYSTEM_REWARD_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TEN_DECIMALS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TOKEN_HUB_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TOKEN_MANAGER_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_IN_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_OUT_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "VALIDATOR_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "alreadyInit", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "bSCRelayerFee", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "bscChainID", + "outputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "claimReward", + "outputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "claimUndelegated", + "outputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "validator", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "delegate", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "delegator", + "type": "address" + }, + { + "internalType": "address", + "name": "validator", + "type": "address" + } + ], + "name": "getDelegated", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "delegator", + "type": "address" + } + ], + "name": "getDistributedReward", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getMinDelegation", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "delegator", + "type": "address" + }, + { + "internalType": "address", + "name": "valSrc", + "type": "address" + }, + { + "internalType": "address", + "name": "valDst", + "type": "address" + } + ], + "name": "getPendingRedelegateTime", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "delegator", + "type": "address" + }, + { + "internalType": "address", + "name": "validator", + "type": "address" + } + ], + "name": "getPendingUndelegateTime", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getRelayerFee", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "delegator", + "type": "address" + } + ], + "name": "getRequestInFly", + "outputs": [ + { + "internalType": "uint256[3]", + "name": "", + "type": "uint256[3]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "delegator", + "type": "address" + } + ], + "name": "getTotalDelegated", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "delegator", + "type": "address" + } + ], + "name": "getUndelegated", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "msgBytes", + "type": "bytes" + } + ], + "name": "handleAckPackage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "msgBytes", + "type": "bytes" + } + ], + "name": "handleFailAckPackage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "msgBytes", + "type": "bytes" + } + ], + "name": "handleSynPackage", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "minDelegation", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "validatorSrc", + "type": "address" + }, + { + "internalType": "address", + "name": "validatorDst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "redelegate", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "relayerFee", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "transferGas", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "validator", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "undelegate", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "key", + "type": "string" + }, + { + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "updateParam", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } +] \ No newline at end of file diff --git a/abi/systemreward.abi b/abi/systemreward.abi index aca3233f..43865ac3 100644 --- a/abi/systemreward.abi +++ b/abi/systemreward.abi @@ -1,428 +1,455 @@ [ - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "receiveDeposit", - "type": "event" - }, - { - "anonymous": false, - "inputs": [], - "name": "rewardEmpty", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "rewardTo", - "type": "event" - }, - { - "payable": true, - "stateMutability": "payable", - "type": "fallback" - }, - { - "constant": true, - "inputs": [], - "name": "BIND_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "CODE_OK", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "CROSS_CHAIN_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "ERROR_FAIL_DECODE", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "GOV_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "GOV_HUB_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "INCENTIVIZE_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "LIGHT_CLIENT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "MAX_REWARDS", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "RELAYERHUB_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SLASH_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SLASH_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "STAKING_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SYSTEM_REWARD_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TOKEN_HUB_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TOKEN_MANAGER_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TRANSFER_IN_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TRANSFER_OUT_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "VALIDATOR_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "alreadyInit", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "bscChainID", - "outputs": [ - { - "internalType": "uint16", - "name": "", - "type": "uint16" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "numOperator", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address payable", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "claimRewards", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "addr", - "type": "address" - } - ], - "name": "isOperator", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - } + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "key", + "type": "string" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "paramChange", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "receiveDeposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "rewardEmpty", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "rewardTo", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" + } + ], + "name": "updateOperator", + "type": "event" + }, + { + "inputs": [], + "name": "BIND_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CODE_OK", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CROSS_CHAIN_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CROSS_STAKE_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ERROR_FAIL_DECODE", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "GOV_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "GOV_HUB_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INCENTIVIZE_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "LIGHT_CLIENT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_REWARDS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RELAYERHUB_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SLASH_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SLASH_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKING_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKING_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SYSTEM_REWARD_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TOKEN_HUB_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TOKEN_MANAGER_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_IN_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_OUT_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "VALIDATOR_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "alreadyInit", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "bscChainID", + "outputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "claimRewards", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + } + ], + "name": "isOperator", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "numOperator", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "key", + "type": "string" + }, + { + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "updateParam", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } ] \ No newline at end of file diff --git a/abi/tendermintlightclient.abi b/abi/tendermintlightclient.abi index 8ed2dc61..93dc47fc 100644 --- a/abi/tendermintlightclient.abi +++ b/abi/tendermintlightclient.abi @@ -1,657 +1,586 @@ [ - { - "inputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint64", - "name": "initHeight", - "type": "uint64" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "appHash", - "type": "bytes32" - } - ], - "name": "initConsensusState", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "string", - "name": "key", - "type": "string" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "value", - "type": "bytes" - } - ], - "name": "paramChange", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint64", - "name": "height", - "type": "uint64" - }, - { - "indexed": false, - "internalType": "uint64", - "name": "preValidatorSetChangeHeight", - "type": "uint64" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "appHash", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "bool", - "name": "validatorChanged", - "type": "bool" - } - ], - "name": "syncConsensusState", - "type": "event" - }, - { - "constant": true, - "inputs": [], - "name": "BIND_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "CODE_OK", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "CROSS_CHAIN_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "ERROR_FAIL_DECODE", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "GOV_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "GOV_HUB_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "INCENTIVIZE_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "INIT_CONSENSUS_STATE_BYTES", - "outputs": [ - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "INIT_REWARD_FOR_VALIDATOR_SER_CHANGE", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "LIGHT_CLIENT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "RELAYERHUB_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SLASH_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SLASH_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "STAKING_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SYSTEM_REWARD_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TOKEN_HUB_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TOKEN_MANAGER_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TRANSFER_IN_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TRANSFER_OUT_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "VALIDATOR_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "alreadyInit", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "bscChainID", - "outputs": [ - { - "internalType": "uint16", - "name": "", - "type": "uint16" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "chainID", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "initialHeight", - "outputs": [ - { - "internalType": "uint64", - "name": "", - "type": "uint64" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "latestHeight", - "outputs": [ - { - "internalType": "uint64", - "name": "", - "type": "uint64" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "uint64", - "name": "", - "type": "uint64" - } - ], - "name": "lightClientConsensusStates", - "outputs": [ - { - "internalType": "uint64", - "name": "preValidatorSetChangeHeight", - "type": "uint64" - }, - { - "internalType": "bytes32", - "name": "appHash", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "curValidatorSetHash", - "type": "bytes32" - }, - { - "internalType": "bytes", - "name": "nextValidatorSet", - "type": "bytes" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "rewardForValidatorSetChange", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "uint64", - "name": "", - "type": "uint64" - } - ], - "name": "submitters", - "outputs": [ - { - "internalType": "address payable", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [], - "name": "init", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "bytes", - "name": "header", - "type": "bytes" - }, - { - "internalType": "uint64", - "name": "height", - "type": "uint64" - } - ], - "name": "syncTendermintHeader", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "uint64", - "name": "height", - "type": "uint64" - } - ], - "name": "isHeaderSynced", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "uint64", - "name": "height", - "type": "uint64" - } - ], - "name": "getAppHash", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "uint64", - "name": "height", - "type": "uint64" - } - ], - "name": "getSubmitter", - "outputs": [ - { - "internalType": "address payable", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getChainID", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "string", - "name": "key", - "type": "string" - }, - { - "internalType": "bytes", - "name": "value", - "type": "bytes" - } - ], - "name": "updateParam", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - } + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", + "name": "initHeight", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "appHash", + "type": "bytes32" + } + ], + "name": "initConsensusState", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "key", + "type": "string" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "paramChange", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", + "name": "height", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "preValidatorSetChangeHeight", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "appHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bool", + "name": "validatorChanged", + "type": "bool" + } + ], + "name": "syncConsensusState", + "type": "event" + }, + { + "inputs": [], + "name": "BIND_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CODE_OK", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CROSS_CHAIN_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ERROR_FAIL_DECODE", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "GOV_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "GOV_HUB_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INCENTIVIZE_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INIT_CONSENSUS_STATE_BYTES", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INIT_REWARD_FOR_VALIDATOR_SER_CHANGE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "LIGHT_CLIENT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RELAYERHUB_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SLASH_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SLASH_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKING_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SYSTEM_REWARD_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TOKEN_HUB_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TOKEN_MANAGER_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_IN_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_OUT_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "VALIDATOR_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "alreadyInit", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "bscChainID", + "outputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "chainID", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "initialHeight", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "latestHeight", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "name": "lightClientConsensusStates", + "outputs": [ + { + "internalType": "uint64", + "name": "preValidatorSetChangeHeight", + "type": "uint64" + }, + { + "internalType": "bytes32", + "name": "appHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "curValidatorSetHash", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "nextValidatorSet", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rewardForValidatorSetChange", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "name": "submitters", + "outputs": [ + { + "internalType": "address payable", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "init", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "header", + "type": "bytes" + }, + { + "internalType": "uint64", + "name": "height", + "type": "uint64" + } + ], + "name": "syncTendermintHeader", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint64", + "name": "height", + "type": "uint64" + } + ], + "name": "isHeaderSynced", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint64", + "name": "height", + "type": "uint64" + } + ], + "name": "getAppHash", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint64", + "name": "height", + "type": "uint64" + } + ], + "name": "getSubmitter", + "outputs": [ + { + "internalType": "address payable", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getChainID", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "key", + "type": "string" + }, + { + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "updateParam", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } ] \ No newline at end of file diff --git a/abi/tokenhub.abi b/abi/tokenhub.abi index b6fd77de..f4f8e88e 100644 --- a/abi/tokenhub.abi +++ b/abi/tokenhub.abi @@ -1,1120 +1,1057 @@ [ - { - "inputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "string", - "name": "key", - "type": "string" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "value", - "type": "bytes" - } - ], - "name": "paramChange", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "receiveDeposit", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "bep20Addr", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "refundAddr", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint32", - "name": "status", - "type": "uint32" - } - ], - "name": "refundFailure", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "bep20Addr", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "refundAddr", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint32", - "name": "status", - "type": "uint32" - } - ], - "name": "refundSuccess", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "rewardTo", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "bep20Addr", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "refundAddr", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "transferInSuccess", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "bep20Addr", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "senderAddr", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "relayFee", - "type": "uint256" - } - ], - "name": "transferOutSuccess", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint8", - "name": "channelId", - "type": "uint8" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "msgBytes", - "type": "bytes" - } - ], - "name": "unexpectedPackage", - "type": "event" - }, - { - "payable": true, - "stateMutability": "payable", - "type": "fallback" - }, - { - "constant": true, - "inputs": [], - "name": "BEP2_TOKEN_DECIMALS", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "BEP2_TOKEN_SYMBOL_FOR_BNB", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "BIND_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "CODE_OK", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "CROSS_CHAIN_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "ERROR_FAIL_DECODE", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "GOV_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "GOV_HUB_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "INCENTIVIZE_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "INIT_MINIMUM_RELAY_FEE", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "LIGHT_CLIENT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "MAXIMUM_BEP20_SYMBOL_LEN", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "MAX_BEP2_TOTAL_SUPPLY", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "MAX_GAS_FOR_CALLING_BEP20", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "MAX_GAS_FOR_TRANSFER_BNB", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "MINIMUM_BEP20_SYMBOL_LEN", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "RELAYERHUB_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "REWARD_UPPER_LIMIT", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SLASH_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SLASH_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "STAKING_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SYSTEM_REWARD_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TEN_DECIMALS", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TOKEN_HUB_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TOKEN_MANAGER_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TRANSFER_IN_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TRANSFER_IN_FAILURE_INSUFFICIENT_BALANCE", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TRANSFER_IN_FAILURE_NON_PAYABLE_RECIPIENT", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TRANSFER_IN_FAILURE_TIMEOUT", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TRANSFER_IN_FAILURE_UNBOUND_TOKEN", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TRANSFER_IN_FAILURE_UNKNOWN", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TRANSFER_IN_SUCCESS", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TRANSFER_OUT_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "VALIDATOR_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "alreadyInit", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "bep20ContractDecimals", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "bscChainID", - "outputs": [ - { - "internalType": "uint16", - "name": "", - "type": "uint16" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "relayFee", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [], - "name": "init", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address payable", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "claimRewards", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getMiniRelayFee", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "uint8", - "name": "channelId", - "type": "uint8" - }, - { - "internalType": "bytes", - "name": "msgBytes", - "type": "bytes" - } - ], - "name": "handleSynPackage", - "outputs": [ - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "uint8", - "name": "channelId", - "type": "uint8" - }, - { - "internalType": "bytes", - "name": "msgBytes", - "type": "bytes" - } - ], - "name": "handleAckPackage", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "uint8", - "name": "channelId", - "type": "uint8" - }, - { - "internalType": "bytes", - "name": "msgBytes", - "type": "bytes" - } - ], - "name": "handleFailAckPackage", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "contractAddr", - "type": "address" - }, - { - "internalType": "address", - "name": "recipient", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "internalType": "uint64", - "name": "expireTime", - "type": "uint64" - } - ], - "name": "transferOut", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": true, - "stateMutability": "payable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address[]", - "name": "recipientAddrs", - "type": "address[]" - }, - { - "internalType": "uint256[]", - "name": "amounts", - "type": "uint256[]" - }, - { - "internalType": "address[]", - "name": "refundAddrs", - "type": "address[]" - }, - { - "internalType": "uint64", - "name": "expireTime", - "type": "uint64" - } - ], - "name": "batchTransferOutBNB", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": true, - "stateMutability": "payable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "string", - "name": "key", - "type": "string" - }, - { - "internalType": "bytes", - "name": "value", - "type": "bytes" - } - ], - "name": "updateParam", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "bytes32", - "name": "bep2Symbol", - "type": "bytes32" - } - ], - "name": "getContractAddrByBEP2Symbol", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "contractAddr", - "type": "address" - } - ], - "name": "getBep2SymbolByContractAddr", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "bytes32", - "name": "bep2Symbol", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "contractAddr", - "type": "address" - }, - { - "internalType": "uint256", - "name": "decimals", - "type": "uint256" - } - ], - "name": "bindToken", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "bytes32", - "name": "bep2Symbol", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "contractAddr", - "type": "address" - } - ], - "name": "unbindToken", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "string", - "name": "bep2Symbol", - "type": "string" - } - ], - "name": "getBoundContract", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "contractAddr", - "type": "address" - } - ], - "name": "getBoundBep2Symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - } + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "key", + "type": "string" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "paramChange", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "receiveDeposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "bep20Addr", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "refundAddr", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "status", + "type": "uint32" + } + ], + "name": "refundFailure", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "bep20Addr", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "refundAddr", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "status", + "type": "uint32" + } + ], + "name": "refundSuccess", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "rewardTo", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "bep20Addr", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "refundAddr", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferInSuccess", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "bep20Addr", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "senderAddr", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "relayFee", + "type": "uint256" + } + ], + "name": "transferOutSuccess", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "channelId", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "msgBytes", + "type": "bytes" + } + ], + "name": "unexpectedPackage", + "type": "event" + }, + { + "inputs": [], + "name": "BEP2_TOKEN_DECIMALS", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "BEP2_TOKEN_SYMBOL_FOR_BNB", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "BIND_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CODE_OK", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CROSS_CHAIN_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CROSS_STAKE_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ERROR_FAIL_DECODE", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "GOV_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "GOV_HUB_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INCENTIVIZE_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INIT_MINIMUM_RELAY_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "LIGHT_CLIENT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAXIMUM_BEP20_SYMBOL_LEN", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_BEP2_TOTAL_SUPPLY", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_GAS_FOR_CALLING_BEP20", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_GAS_FOR_TRANSFER_BNB", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MINIMUM_BEP20_SYMBOL_LEN", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RELAYERHUB_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "REWARD_UPPER_LIMIT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SLASH_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SLASH_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKING_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKING_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SYSTEM_REWARD_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TEN_DECIMALS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TOKEN_HUB_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TOKEN_MANAGER_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_IN_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_IN_FAILURE_INSUFFICIENT_BALANCE", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_IN_FAILURE_NON_PAYABLE_RECIPIENT", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_IN_FAILURE_TIMEOUT", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_IN_FAILURE_UNBOUND_TOKEN", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_IN_FAILURE_UNKNOWN", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_IN_SUCCESS", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_OUT_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "VALIDATOR_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "alreadyInit", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "recipientAddrs", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + }, + { + "internalType": "address[]", + "name": "refundAddrs", + "type": "address[]" + }, + { + "internalType": "uint64", + "name": "expireTime", + "type": "uint64" + } + ], + "name": "batchTransferOutBNB", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "bep20ContractDecimals", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "bep2Symbol", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "contractAddr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "decimals", + "type": "uint256" + } + ], + "name": "bindToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "bscChainID", + "outputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "claimRewards", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "contractAddr", + "type": "address" + } + ], + "name": "getBep2SymbolByContractAddr", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "contractAddr", + "type": "address" + } + ], + "name": "getBoundBep2Symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "bep2Symbol", + "type": "string" + } + ], + "name": "getBoundContract", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "bep2Symbol", + "type": "bytes32" + } + ], + "name": "getContractAddrByBEP2Symbol", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getMiniRelayFee", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "channelId", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "msgBytes", + "type": "bytes" + } + ], + "name": "handleAckPackage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "channelId", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "msgBytes", + "type": "bytes" + } + ], + "name": "handleFailAckPackage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "channelId", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "msgBytes", + "type": "bytes" + } + ], + "name": "handleSynPackage", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "init", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "relayFee", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "contractAddr", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "expireTime", + "type": "uint64" + } + ], + "name": "transferOut", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "bep2Symbol", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "contractAddr", + "type": "address" + } + ], + "name": "unbindToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "key", + "type": "string" + }, + { + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "updateParam", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "withdrawStakingBNB", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } ] \ No newline at end of file diff --git a/abi/tokenmanager.abi b/abi/tokenmanager.abi index 1d03235b..11d7ea2a 100644 --- a/abi/tokenmanager.abi +++ b/abi/tokenmanager.abi @@ -1,1202 +1,1081 @@ [ - { - "inputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "contractAddr", - "type": "address" - }, - { - "indexed": false, - "internalType": "string", - "name": "bep2Symbol", - "type": "string" - }, - { - "indexed": false, - "internalType": "uint32", - "name": "failedReason", - "type": "uint32" - } - ], - "name": "bindFailure", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "contractAddr", - "type": "address" - }, - { - "indexed": false, - "internalType": "string", - "name": "bep2Symbol", - "type": "string" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "totalSupply", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "peggyAmount", - "type": "uint256" - } - ], - "name": "bindSuccess", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "bep20Addr", - "type": "address" - }, - { - "indexed": false, - "internalType": "string", - "name": "reason", - "type": "string" - } - ], - "name": "mirrorFailure", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "bep20Addr", - "type": "address" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "bep2Symbol", - "type": "bytes32" - } - ], - "name": "mirrorSuccess", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "string", - "name": "key", - "type": "string" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "value", - "type": "bytes" - } - ], - "name": "paramChange", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "bep20Addr", - "type": "address" - }, - { - "indexed": false, - "internalType": "string", - "name": "reason", - "type": "string" - } - ], - "name": "syncFailure", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "bep20Addr", - "type": "address" - } - ], - "name": "syncSuccess", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint8", - "name": "channelId", - "type": "uint8" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "msgBytes", - "type": "bytes" - } - ], - "name": "unexpectedPackage", - "type": "event" - }, - { - "constant": true, - "inputs": [], - "name": "BEP2_TOKEN_DECIMALS", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "BIND_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "BIND_PACKAGE", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "BIND_STATUS_ALREADY_BOUND_TOKEN", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "BIND_STATUS_DECIMALS_MISMATCH", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "BIND_STATUS_REJECTED", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "BIND_STATUS_SUCCESS", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "BIND_STATUS_SYMBOL_MISMATCH", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "BIND_STATUS_TIMEOUT", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "BIND_STATUS_TOO_MUCH_TOKENHUB_BALANCE", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "BIND_STATUS_TOTAL_SUPPLY_MISMATCH", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "CODE_OK", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "CROSS_CHAIN_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "ERROR_FAIL_DECODE", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "GOV_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "GOV_HUB_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "INCENTIVIZE_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "LIGHT_CLIENT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "MAXIMUM_BEP20_SYMBOL_LEN", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "MAX_BEP2_TOTAL_SUPPLY", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "MAX_GAS_FOR_TRANSFER_BNB", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "MINIMUM_BEP20_SYMBOL_LEN", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "MIRROR_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "MIRROR_STATUS_ALREADY_BOUND", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "MIRROR_STATUS_DUPLICATED_BEP2_SYMBOL", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "MIRROR_STATUS_SUCCESS", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "MIRROR_STATUS_TIMEOUT", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "RELAYERHUB_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SLASH_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SLASH_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "STAKING_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SYNC_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SYNC_STATUS_NOT_BOUND_MIRROR", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SYNC_STATUS_SUCCESS", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SYNC_STATUS_TIMEOUT", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SYSTEM_REWARD_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TEN_DECIMALS", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TOKEN_HUB_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TOKEN_MANAGER_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TRANSFER_IN_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "TRANSFER_OUT_CHANNELID", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "UNBIND_PACKAGE", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "VALIDATOR_CONTRACT_ADDR", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "alreadyInit", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "contractAddr", - "type": "address" - }, - { - "internalType": "string", - "name": "bep2Symbol", - "type": "string" - } - ], - "name": "approveBind", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": true, - "stateMutability": "payable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "name": "bindPackageRecord", - "outputs": [ - { - "internalType": "uint8", - "name": "packageType", - "type": "uint8" - }, - { - "internalType": "bytes32", - "name": "bep2TokenSymbol", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "contractAddr", - "type": "address" - }, - { - "internalType": "uint256", - "name": "totalSupply", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "peggyAmount", - "type": "uint256" - }, - { - "internalType": "uint8", - "name": "bep20Decimals", - "type": "uint8" - }, - { - "internalType": "uint64", - "name": "expireTime", - "type": "uint64" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "boundByMirror", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "bscChainID", - "outputs": [ - { - "internalType": "uint16", - "name": "", - "type": "uint16" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "string", - "name": "bep2Symbol", - "type": "string" - } - ], - "name": "expireBind", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": true, - "stateMutability": "payable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "uint8", - "name": "channelId", - "type": "uint8" - }, - { - "internalType": "bytes", - "name": "msgBytes", - "type": "bytes" - } - ], - "name": "handleAckPackage", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "uint8", - "name": "channelId", - "type": "uint8" - }, - { - "internalType": "bytes", - "name": "msgBytes", - "type": "bytes" - } - ], - "name": "handleFailAckPackage", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "uint8", - "name": "channelId", - "type": "uint8" - }, - { - "internalType": "bytes", - "name": "msgBytes", - "type": "bytes" - } - ], - "name": "handleSynPackage", - "outputs": [ - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "bep20Addr", - "type": "address" - }, - { - "internalType": "uint64", - "name": "expireTime", - "type": "uint64" - } - ], - "name": "mirror", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": true, - "stateMutability": "payable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "mirrorFee", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "mirrorPendingRecord", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "string", - "name": "symbol", - "type": "string" - } - ], - "name": "queryRequiredLockAmountForBind", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "contractAddr", - "type": "address" - }, - { - "internalType": "string", - "name": "bep2Symbol", - "type": "string" - } - ], - "name": "rejectBind", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": true, - "stateMutability": "payable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "bep20Addr", - "type": "address" - }, - { - "internalType": "uint64", - "name": "expireTime", - "type": "uint64" - } - ], - "name": "sync", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": true, - "stateMutability": "payable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "syncFee", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "string", - "name": "key", - "type": "string" - }, - { - "internalType": "bytes", - "name": "value", - "type": "bytes" - } - ], - "name": "updateParam", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - } + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "contractAddr", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "bep2Symbol", + "type": "string" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "failedReason", + "type": "uint32" + } + ], + "name": "bindFailure", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "contractAddr", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "bep2Symbol", + "type": "string" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalSupply", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "peggyAmount", + "type": "uint256" + } + ], + "name": "bindSuccess", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "bep20Addr", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint8", + "name": "errCode", + "type": "uint8" + } + ], + "name": "mirrorFailure", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "bep20Addr", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "bep2Symbol", + "type": "bytes32" + } + ], + "name": "mirrorSuccess", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "key", + "type": "string" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "paramChange", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "bep20Addr", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint8", + "name": "errCode", + "type": "uint8" + } + ], + "name": "syncFailure", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "bep20Addr", + "type": "address" + } + ], + "name": "syncSuccess", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "channelId", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "msgBytes", + "type": "bytes" + } + ], + "name": "unexpectedPackage", + "type": "event" + }, + { + "inputs": [], + "name": "BEP2_TOKEN_DECIMALS", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "BIND_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "BIND_PACKAGE", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "BIND_STATUS_ALREADY_BOUND_TOKEN", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "BIND_STATUS_DECIMALS_MISMATCH", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "BIND_STATUS_REJECTED", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "BIND_STATUS_SYMBOL_MISMATCH", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "BIND_STATUS_TIMEOUT", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "BIND_STATUS_TOO_MUCH_TOKENHUB_BALANCE", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "BIND_STATUS_TOTAL_SUPPLY_MISMATCH", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CODE_OK", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CROSS_CHAIN_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CROSS_STAKE_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ERROR_FAIL_DECODE", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "GOV_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "GOV_HUB_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INCENTIVIZE_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "LIGHT_CLIENT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "LOG_MAX_UINT256", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAXIMUM_BEP20_SYMBOL_LEN", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_BEP2_TOTAL_SUPPLY", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_GAS_FOR_TRANSFER_BNB", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MINIMUM_BEP20_SYMBOL_LEN", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MIRROR_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MIRROR_STATUS_ALREADY_BOUND", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MIRROR_STATUS_DUPLICATED_BEP2_SYMBOL", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MIRROR_STATUS_TIMEOUT", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RELAYERHUB_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SLASH_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SLASH_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKING_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKING_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SYNC_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SYNC_STATUS_NOT_BOUND_MIRROR", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SYNC_STATUS_TIMEOUT", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SYSTEM_REWARD_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TEN_DECIMALS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TOKEN_HUB_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TOKEN_MANAGER_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_IN_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_OUT_CHANNELID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "UNBIND_PACKAGE", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "VALIDATOR_CONTRACT_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "alreadyInit", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "contractAddr", + "type": "address" + }, + { + "internalType": "string", + "name": "bep2Symbol", + "type": "string" + } + ], + "name": "approveBind", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "name": "bindPackageRecord", + "outputs": [ + { + "internalType": "uint8", + "name": "packageType", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "bep2TokenSymbol", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "contractAddr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "totalSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "peggyAmount", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "bep20Decimals", + "type": "uint8" + }, + { + "internalType": "uint64", + "name": "expireTime", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "boundByMirror", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "bscChainID", + "outputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "bep2Symbol", + "type": "string" + } + ], + "name": "expireBind", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "channelId", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "msgBytes", + "type": "bytes" + } + ], + "name": "handleAckPackage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "channelId", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "msgBytes", + "type": "bytes" + } + ], + "name": "handleFailAckPackage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "channelId", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "msgBytes", + "type": "bytes" + } + ], + "name": "handleSynPackage", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "bep20Addr", + "type": "address" + }, + { + "internalType": "uint64", + "name": "expireTime", + "type": "uint64" + } + ], + "name": "mirror", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "mirrorFee", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "mirrorPendingRecord", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "symbol", + "type": "string" + } + ], + "name": "queryRequiredLockAmountForBind", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "contractAddr", + "type": "address" + }, + { + "internalType": "string", + "name": "bep2Symbol", + "type": "string" + } + ], + "name": "rejectBind", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "bep20Addr", + "type": "address" + }, + { + "internalType": "uint64", + "name": "expireTime", + "type": "uint64" + } + ], + "name": "sync", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "syncFee", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "key", + "type": "string" + }, + { + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "updateParam", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } ] \ No newline at end of file diff --git a/contracts/BSCValidatorSet.sol b/contracts/BSCValidatorSet.sol index a1ca3c17..11cc15ad 100644 --- a/contracts/BSCValidatorSet.sol +++ b/contracts/BSCValidatorSet.sol @@ -1,4 +1,5 @@ pragma solidity 0.6.4; +pragma experimental ABIEncoderV2; import "./System.sol"; import "./lib/BytesToTypes.sol"; @@ -32,13 +33,15 @@ contract BSCValidatorSet is IBSCValidatorSet, System, IParamSubscriber, IApplica uint256 public constant EXPIRE_TIME_SECOND_GAP = 1000; uint256 public constant MAX_NUM_OF_VALIDATORS = 41; - bytes public constant INIT_VALIDATORSET_BYTES = hex"f84580f842f840949fb29aac15b9a4b7f17c3385939b007540f4d791949fb29aac15b9a4b7f17c3385939b007540f4d791949fb29aac15b9a4b7f17c3385939b007540f4d79164"; + bytes public constant INIT_VALIDATORSET_BYTES = hex"f87680f873f871949fb29aac15b9a4b7f17c3385939b007540f4d791949fb29aac15b9a4b7f17c3385939b007540f4d791949fb29aac15b9a4b7f17c3385939b007540f4d79164b085e6972fc98cd3c81d64d40e325acfed44365b97a7567a27939c14dbc7512ddcf54cb1284eb637cfa308ae4e00cb5588"; uint32 public constant ERROR_UNKNOWN_PACKAGE_TYPE = 101; uint32 public constant ERROR_FAIL_CHECK_VALIDATORS = 102; uint32 public constant ERROR_LEN_OF_VAL_MISMATCH = 103; uint32 public constant ERROR_RELAYFEE_TOO_LARGE = 104; + uint256 public constant INIT_NUM_OF_CABINETS = 21; + uint256 public constant EPOCH = 200; /*********************** state of the contract **************************/ Validator[] public currentValidatorSet; @@ -56,7 +59,29 @@ contract BSCValidatorSet is IBSCValidatorSet, System, IParamSubscriber, IApplica uint256 public burnRatio; bool public burnRatioInitialized; - struct Validator{ + // BEP-127 Temporary Maintenance + uint256 public constant INIT_MAX_NUM_OF_MAINTAINING = 3; + uint256 public constant INIT_MAINTAIN_SLASH_SCALE = 2; + + uint256 public maxNumOfMaintaining; + uint256 public numOfMaintaining; + uint256 public maintainSlashScale; + + // Corresponds strictly to currentValidatorSet + // validatorExtraSet[index] = the `ValidatorExtra` info of currentValidatorSet[index] + ValidatorExtra[] public validatorExtraSet; + // BEP-131 candidate validator + uint256 public numOfCabinets; + uint256 public maxNumOfCandidates; + uint256 public maxNumOfWorkingCandidates; + + // BEP-126 Fast Finality + uint256 public constant INIT_FINALITY_REWARD_RATIO = 10; + + uint256 public finalityRewardRatio; + uint256 public previousHeight; + + struct Validator { address consensusAddress; address payable feeAddress; address BBCFeeAddress; @@ -67,10 +92,23 @@ contract BSCValidatorSet is IBSCValidatorSet, System, IParamSubscriber, IApplica uint256 incoming; } + struct ValidatorExtra { + // BEP-127 Temporary Maintenance + uint256 enterMaintenanceHeight; // the height from where the validator enters Maintenance + bool isMaintaining; + + // BEP-126 Fast Finality + bytes voteAddress; + + // reserve for future use + uint256[19] slots; + } + /*********************** cross chain package **************************/ struct IbcValidatorSetPackage { uint8 packageType; Validator[] validatorSet; + bytes[] voteAddrs; } /*********************** modifiers **************************/ @@ -79,6 +117,25 @@ contract BSCValidatorSet is IBSCValidatorSet, System, IParamSubscriber, IApplica _; } + modifier initValidatorExtraSet() { + if (validatorExtraSet.length == 0) { + ValidatorExtra memory validatorExtra; + // init validatorExtraSet + uint256 validatorsNum = currentValidatorSet.length; + for (uint i; i < validatorsNum; ++i) { + validatorExtraSet.push(validatorExtra); + } + } + + _; + } + + modifier oncePerBlock() { + require(block.number > previousHeight, "can not do this twice in one block"); + _; + previousHeight = block.number; + } + /*********************** events **************************/ event validatorSetUpdated(); event validatorJailed(address indexed validator); @@ -97,12 +154,16 @@ contract BSCValidatorSet is IBSCValidatorSet, System, IParamSubscriber, IApplica event unexpectedPackage(uint8 channelId, bytes msgBytes); event paramChange(string key, bytes value); event feeBurned(uint256 amount); + event validatorEnterMaintenance(address indexed validator); + event validatorExitMaintenance(address indexed validator); + event finalityRewardDeposit(address indexed validator, uint256 amount); + event deprecatedFinalityRewardDeposit(address indexed validator, uint256 amount); /*********************** init **************************/ function init() external onlyNotInit{ (IbcValidatorSetPackage memory validatorSetPkg, bool valid)= decodeValidatorSetSynPackage(INIT_VALIDATORSET_BYTES); require(valid, "failed to parse init validatorSet"); - for (uint i = 0;i= DUSTY_INCOMING) { - crossSize ++; - } else if (currentValidatorSet[i].incoming > 0) { - directSize ++; - } - } - - //cross transfer - address[] memory crossAddrs = new address[](crossSize); - uint256[] memory crossAmounts = new uint256[](crossSize); - uint256[] memory crossIndexes = new uint256[](crossSize); - address[] memory crossRefundAddrs = new address[](crossSize); - uint256 crossTotal; - // direct transfer - address payable[] memory directAddrs = new address payable[](directSize); - uint256[] memory directAmounts = new uint256[](directSize); - crossSize = 0; - directSize = 0; - Validator[] memory validatorSetTemp = validatorSet; // fix error: stack too deep, try removing local variables - uint256 relayFee = ITokenHub(TOKEN_HUB_ADDR).getMiniRelayFee(); - if (relayFee > DUSTY_INCOMING) { - emit failReasonWithStr("fee is larger than DUSTY_INCOMING"); - return ERROR_RELAYFEE_TOO_LARGE; - } - for (uint i = 0;i= DUSTY_INCOMING) { - crossAddrs[crossSize] = currentValidatorSet[i].BBCFeeAddress; - uint256 value = currentValidatorSet[i].incoming - currentValidatorSet[i].incoming % PRECISION; - crossAmounts[crossSize] = value.sub(relayFee); - crossRefundAddrs[crossSize] = currentValidatorSet[i].BBCFeeAddress; - crossIndexes[crossSize] = i; - crossTotal = crossTotal.add(value); - crossSize ++; - } else if (currentValidatorSet[i].incoming > 0) { - directAddrs[directSize] = currentValidatorSet[i].feeAddress; - directAmounts[directSize] = currentValidatorSet[i].incoming; - directSize ++; - } - } - - //step 2: do cross chain transfer - bool failCross = false; - if (crossTotal > 0) { - try ITokenHub(TOKEN_HUB_ADDR).batchTransferOutBNB{value:crossTotal}(crossAddrs, crossAmounts, crossRefundAddrs, uint64(block.timestamp + expireTimeSecondGap)) returns (bool success) { - if (success) { - emit batchTransfer(crossTotal); - } else { - emit batchTransferFailed(crossTotal, "batch transfer return false"); + function updateValidatorSet(Validator[] memory validatorSet, bytes[] memory voteAddrs) internal returns (uint32) { + { + // do verify. + if (validatorSet.length > MAX_NUM_OF_VALIDATORS) { + emit failReasonWithStr("the number of validators exceed the limit"); + return ERROR_FAIL_CHECK_VALIDATORS; + } + for (uint i; i < validatorSet.length; ++i) { + for (uint j; j < i; ++j) { + if (validatorSet[i].consensusAddress == validatorSet[j].consensusAddress) { + emit failReasonWithStr("duplicate consensus address of validatorSet"); + return ERROR_FAIL_CHECK_VALIDATORS; + } } - }catch Error(string memory reason) { - failCross = true; - emit batchTransferFailed(crossTotal, reason); - }catch (bytes memory lowLevelData) { - failCross = true; - emit batchTransferLowerFailed(crossTotal, lowLevelData); } } - if (failCross) { - for (uint i = 0; i< crossIndexes.length;i++) { - uint idx = crossIndexes[i]; - bool success = currentValidatorSet[idx].feeAddress.send(currentValidatorSet[idx].incoming); - if (success) { - emit directTransfer(currentValidatorSet[idx].feeAddress, currentValidatorSet[idx].incoming); - } else { - emit directTransferFail(currentValidatorSet[idx].feeAddress, currentValidatorSet[idx].incoming); + // step 0: force all maintaining validators to exit `Temporary Maintenance` + // - 1. validators exit maintenance + // - 2. clear all maintainInfo + // - 3. get unjailed validators from validatorSet + (Validator[] memory validatorSetTemp, bytes[] memory voteAddrsTemp) = _forceMaintainingValidatorsExit(validatorSet, voteAddrs); + + { + //step 1: do calculate distribution, do not make it as an internal function for saving gas. + uint crossSize; + uint directSize; + uint validatorsNum = currentValidatorSet.length; + for (uint i; i < validatorsNum; ++i) { + if (currentValidatorSet[i].incoming >= DUSTY_INCOMING) { + crossSize ++; + } else if (currentValidatorSet[i].incoming > 0) { + directSize ++; } } - } - // step 3: direct transfer - if (directAddrs.length>0) { - for (uint i = 0;i DUSTY_INCOMING) { + emit failReasonWithStr("fee is larger than DUSTY_INCOMING"); + return ERROR_RELAYFEE_TOO_LARGE; + } + for (uint i; i < validatorsNum; ++i) { + if (currentValidatorSet[i].incoming >= DUSTY_INCOMING) { + crossAddrs[crossSize] = currentValidatorSet[i].BBCFeeAddress; + uint256 value = currentValidatorSet[i].incoming - currentValidatorSet[i].incoming % PRECISION; + crossAmounts[crossSize] = value.sub(relayFee); + crossRefundAddrs[crossSize] = currentValidatorSet[i].BBCFeeAddress; + crossIndexes[crossSize] = i; + crossTotal = crossTotal.add(value); + crossSize ++; + } else if (currentValidatorSet[i].incoming > 0) { + directAddrs[directSize] = currentValidatorSet[i].feeAddress; + directAmounts[directSize] = currentValidatorSet[i].incoming; + directSize ++; + } + } + + //step 2: do cross chain transfer + bool failCross = false; + if (crossTotal > 0) { + try ITokenHub(TOKEN_HUB_ADDR).batchTransferOutBNB{value : crossTotal}(crossAddrs, crossAmounts, crossRefundAddrs, uint64(block.timestamp + expireTimeSecondGap)) returns (bool success) { + if (success) { + emit batchTransfer(crossTotal); + } else { + emit batchTransferFailed(crossTotal, "batch transfer return false"); + } + }catch Error(string memory reason) { + failCross = true; + emit batchTransferFailed(crossTotal, reason); + }catch (bytes memory lowLevelData) { + failCross = true; + emit batchTransferLowerFailed(crossTotal, lowLevelData); + } + } + + if (failCross) { + for (uint i; i< crossIndexes.length;++i) { + uint idx = crossIndexes[i]; + bool success = currentValidatorSet[idx].feeAddress.send(currentValidatorSet[idx].incoming); + if (success) { + emit directTransfer(currentValidatorSet[idx].feeAddress, currentValidatorSet[idx].incoming); + } else { + emit directTransferFail(currentValidatorSet[idx].feeAddress, currentValidatorSet[idx].incoming); + } + } + } + + // step 3: direct transfer + if (directAddrs.length>0) { + for (uint i;i0) { - doUpdateState(validatorSetTemp); + doUpdateState(validatorSetTemp, voteAddrsTemp); } // step 6: clean slash contract @@ -312,25 +392,114 @@ contract BSCValidatorSet is IBSCValidatorSet, System, IParamSubscriber, IApplica return CODE_OK; } - function getValidators()external view returns(address[] memory) { + function shuffle(address[] memory validators, bytes[] memory voteAddrs, uint256 epochNumber, uint startIdx, uint offset, uint limit, uint modNumber) internal pure { + for (uint i; i 0) { + uint256 epochNumber = block.number / EPOCH; + shuffle(validators, voteAddrs, epochNumber, _numOfCabinets-_maxNumOfWorkingCandidates, 0, _maxNumOfWorkingCandidates, _numOfCabinets); + shuffle(validators, voteAddrs, epochNumber, _numOfCabinets-_maxNumOfWorkingCandidates, _numOfCabinets-_maxNumOfWorkingCandidates, + _maxNumOfWorkingCandidates, validators.length - _numOfCabinets+_maxNumOfWorkingCandidates); + } + address[] memory miningValidators = new address[](_numOfCabinets); + bytes[] memory miningVoteAddrs = new bytes[](_numOfCabinets); + for (uint i; i<_numOfCabinets; ++i) { + miningValidators[i] = validators[i]; + miningVoteAddrs[i] = voteAddrs[i]; + } + return (miningValidators, miningVoteAddrs); + } + + function getValidators() public view returns(address[] memory) { + uint n = currentValidatorSet.length; + uint valid = 0; + for (uint i; i= currentValidatorSet.length) { + return false; + } + + // validatorExtraSet[index] should not be used before it has been init. + if (index >= validatorExtraSet.length) { + return !currentValidatorSet[index].jailed; + } + + return !currentValidatorSet[index].jailed && !validatorExtraSet[index].isMaintaining; + } + function getIncoming(address validator)external view returns(uint256) { uint256 index = currentValidatorSetMap[validator]; if (index<=0) { @@ -339,65 +508,145 @@ contract BSCValidatorSet is IBSCValidatorSet, System, IParamSubscriber, IApplica return currentValidatorSet[index-1].incoming; } - /*********************** For slash **************************/ - function misdemeanor(address validator)external onlySlash override{ + function isCurrentValidator(address validator) external view override returns (bool) { uint256 index = currentValidatorSetMap[validator]; if (index <= 0) { - return; + return false; } - // the actually index + + // the actual index index = index - 1; - uint256 income = currentValidatorSet[index].incoming; - currentValidatorSet[index].incoming = 0; - uint256 rest = currentValidatorSet.length - 1; - emit validatorMisdemeanor(validator,income); - if (rest==0) { - // should not happen, but still protect + return isWorkingValidator(index); + } + + function distributeFinalityReward(address[] calldata valAddrs, uint256[] calldata weights) external onlyCoinbase oncePerBlock onlyInit { + if (finalityRewardRatio == 0) { + finalityRewardRatio = INIT_FINALITY_REWARD_RATIO; + } + + uint256 totalValue; + totalValue = (address(SYSTEM_REWARD_ADDR).balance * finalityRewardRatio) / 100; + totalValue = ISystemReward(SYSTEM_REWARD_ADDR).claimRewards(payable(address(this)), totalValue); + if (totalValue == 0) { return; } - uint256 averageDistribute = income/rest; - if (averageDistribute!=0) { - for (uint i=0;i 0) { + Validator storage validator = currentValidatorSet[index - 1]; + if (validator.jailed) { + emit deprecatedFinalityRewardDeposit(valAddr, value); + } else { + totalInComing = totalInComing.add(value); + validator.incoming = validator.incoming.add(value); + emit finalityRewardDeposit(valAddr, value); + } + } else { + // get incoming from deprecated validator; + emit deprecatedFinalityRewardDeposit(valAddr, value); } } - // averageDistribute*rest may less than income, but it is ok, the dust income will go to system reward eventually. + } - function felony(address validator)external onlySlash override{ + function getWorkingValidatorCount() public view returns(uint256 workingValidatorCount) { + workingValidatorCount = getValidators().length; + uint256 _numOfCabinets = numOfCabinets > 0 ? numOfCabinets : INIT_NUM_OF_CABINETS; + if (workingValidatorCount > _numOfCabinets) { + workingValidatorCount = _numOfCabinets; + } + if (workingValidatorCount == 0) { + workingValidatorCount = 1; + } + } + /*********************** For slash **************************/ + function misdemeanor(address validator) external onlySlash initValidatorExtraSet override { + uint256 validatorIndex = _misdemeanor(validator); + if (canEnterMaintenance(validatorIndex)) { + _enterMaintenance(validator, validatorIndex); + } + } + + function felony(address validator)external onlySlash initValidatorExtraSet override{ uint256 index = currentValidatorSetMap[validator]; if (index <= 0) { return; } - // the actually index + // the actual index index = index - 1; - uint256 income = currentValidatorSet[index].incoming; - uint256 rest = currentValidatorSet.length - 1; - if (rest==0) { - // will not remove the validator if it is the only one validator. - currentValidatorSet[index].incoming = 0; - return; + + bool isMaintaining = validatorExtraSet[index].isMaintaining; + if (_felony(validator, index) && isMaintaining) { + numOfMaintaining--; } - emit validatorFelony(validator,income); - delete currentValidatorSetMap[validator]; - // It is ok that the validatorSet is not in order. - if (index != currentValidatorSet.length-1) { - currentValidatorSet[index] = currentValidatorSet[currentValidatorSet.length-1]; - currentValidatorSetMap[currentValidatorSet[index].consensusAddress] = index + 1; + } + + /*********************** For Temporary Maintenance **************************/ + function getCurrentValidatorIndex(address _validator) public view returns (uint256) { + uint256 index = currentValidatorSetMap[_validator]; + require(index > 0, "only current validators"); + + // the actual index + return index - 1; + } + + function canEnterMaintenance(uint256 index) public view returns (bool) { + if (index >= currentValidatorSet.length) { + return false; } - currentValidatorSet.pop(); - uint256 averageDistribute = income/rest; - if (averageDistribute!=0) { - uint n = currentValidatorSet.length; - for (uint i=0;i= maxNumOfMaintaining // - 2. check if reached upper limit + || !isWorkingValidator(index) // - 3. check if not working(not jailed and not maintaining) + || validatorExtraSet[index].enterMaintenanceHeight > 0 // - 5. check if has Maintained during current 24-hour period + // current validators are selected every 24 hours(from 00:00:00 UTC to 23:59:59 UTC) + // for more details, refer to https://github.com/bnb-chain/docs-site/blob/master/docs/smart-chain/validator/Binance%20Smart%20Chain%20Validator%20FAQs%20-%20Updated.md + || getValidators().length <= 1 // - 6. check num of remaining working validators + ) { + return false; } - // averageDistribute*rest may less than income, but it is ok, the dust income will go to system reward eventually. + + return true; + } + + function enterMaintenance() external initValidatorExtraSet { + // check maintain config + if (maxNumOfMaintaining == 0) { + maxNumOfMaintaining = INIT_MAX_NUM_OF_MAINTAINING; + } + if (maintainSlashScale == 0) { + maintainSlashScale = INIT_MAINTAIN_SLASH_SCALE; + } + + uint256 index = getCurrentValidatorIndex(msg.sender); + require(canEnterMaintenance(index), "can not enter Temporary Maintenance"); + _enterMaintenance(msg.sender, index); + } + + function exitMaintenance() external { + uint256 index = getCurrentValidatorIndex(msg.sender); + + // jailed validators are allowed to exit maintenance + require(validatorExtraSet[index].isMaintaining, "not in maintenance"); + uint256 workingValidatorCount = getWorkingValidatorCount(); + _exitMaintenance(msg.sender, index, workingValidatorCount); } /*********************** Param update ********************************/ @@ -413,6 +662,43 @@ contract BSCValidatorSet is IBSCValidatorSet, System, IParamSubscriber, IApplica require(newBurnRatio <= BURN_RATIO_SCALE, "the burnRatio must be no greater than 10000"); burnRatio = newBurnRatio; burnRatioInitialized = true; + } else if (Memory.compareStrings(key, "maxNumOfMaintaining")) { + require(value.length == 32, "length of maxNumOfMaintaining mismatch"); + uint256 newMaxNumOfMaintaining = BytesToTypes.bytesToUint256(32, value); + uint256 _numOfCabinets = numOfCabinets; + if (_numOfCabinets == 0) { + _numOfCabinets = INIT_NUM_OF_CABINETS; + } + require(newMaxNumOfMaintaining < _numOfCabinets, "the maxNumOfMaintaining must be less than numOfCabinets"); + maxNumOfMaintaining = newMaxNumOfMaintaining; + } else if (Memory.compareStrings(key, "maintainSlashScale")) { + require(value.length == 32, "length of maintainSlashScale mismatch"); + uint256 newMaintainSlashScale = BytesToTypes.bytesToUint256(32, value); + require(newMaintainSlashScale > 0, "the maintainSlashScale must be greater than 0"); + maintainSlashScale = newMaintainSlashScale; + } else if (Memory.compareStrings(key, "maxNumOfWorkingCandidates")) { + require(value.length == 32, "length of maxNumOfWorkingCandidates mismatch"); + uint256 newMaxNumOfWorkingCandidates = BytesToTypes.bytesToUint256(32, value); + require(newMaxNumOfWorkingCandidates <= maxNumOfCandidates, "the maxNumOfWorkingCandidates must be not greater than maxNumOfCandidates"); + maxNumOfWorkingCandidates = newMaxNumOfWorkingCandidates; + } else if (Memory.compareStrings(key, "maxNumOfCandidates")) { + require(value.length == 32, "length of maxNumOfCandidates mismatch"); + uint256 newMaxNumOfCandidates = BytesToTypes.bytesToUint256(32, value); + maxNumOfCandidates = newMaxNumOfCandidates; + if (maxNumOfWorkingCandidates > maxNumOfCandidates) { + maxNumOfWorkingCandidates = maxNumOfCandidates; + } + } else if (Memory.compareStrings(key, "numOfCabinets")) { + require(value.length == 32, "length of numOfCabinets mismatch"); + uint256 newNumOfCabinets = BytesToTypes.bytesToUint256(32, value); + require(newNumOfCabinets > 0, "the numOfCabinets must be greater than 0"); + require(newNumOfCabinets <= MAX_NUM_OF_VALIDATORS, "the numOfCabinets must be less than MAX_NUM_OF_VALIDATORS"); + numOfCabinets = newNumOfCabinets; + } else if (Memory.compareStrings(key, "finalityRewardRatio")) { + require(value.length == 32, "length of finalityRewardRatio mismatch"); + uint256 newFinalityRewardRatio = BytesToTypes.bytesToUint256(32, value); + require(newFinalityRewardRatio >= 1 && newFinalityRewardRatio < 100, "the finalityRewardRatio is out of range"); + finalityRewardRatio = newFinalityRewardRatio; } else { require(false, "unknown param"); } @@ -420,67 +706,222 @@ contract BSCValidatorSet is IBSCValidatorSet, System, IParamSubscriber, IApplica } /*********************** Internal Functions **************************/ + function doUpdateState(Validator[] memory validatorSet, bytes[] memory voteAddrs) private { + uint n = currentValidatorSet.length; + uint m = validatorSet.length; - function checkValidatorSet(Validator[] memory validatorSet) private pure returns(bool, string memory) { - if (validatorSet.length > MAX_NUM_OF_VALIDATORS){ - return (false, "the number of validators exceed the limit"); + for (uint i; i < n; ++i) { + Validator memory oldValidator = currentValidatorSet[i]; + delete currentValidatorSetMap[oldValidator.consensusAddress]; } - for (uint i = 0;im) { + for (uint i = m; i < n; ++i) { + currentValidatorSet.pop(); + validatorExtraSet.pop(); + } + } + uint k = n < m ? n:m; + for (uint i; i < k; ++i) { + currentValidatorSetMap[validatorSet[i].consensusAddress] = i+1; + currentValidatorSet[i] = validatorSet[i]; + validatorExtraSet[i].voteAddress = voteAddrs[i]; + validatorExtraSet[i].isMaintaining = false; + validatorExtraSet[i].enterMaintenanceHeight = 0; + } + if (m>n) { + ValidatorExtra memory _validatorExtra; + for (uint i = n; i < m; i++) { + _validatorExtra.voteAddress = voteAddrs[i]; + currentValidatorSet.push(validatorSet[i]); + validatorExtraSet.push(_validatorExtra); + currentValidatorSetMap[validatorSet[i].consensusAddress] = i+1; } } - return (true,""); + + // make sure all new validators are cleared maintainInfo + // should not happen, still protect + numOfMaintaining = 0; + n = currentValidatorSet.length; + for (uint i; i < n; ++i) { + validatorExtraSet[i].isMaintaining = false; + validatorExtraSet[i].enterMaintenanceHeight = 0; + } } - function doUpdateState(Validator[] memory validatorSet) private{ + function getVoteAddresses(address[] memory validators) internal view returns(bytes[] memory) { uint n = currentValidatorSet.length; - uint m = validatorSet.length; + uint length = validators.length; + bytes[] memory voteAddrs = new bytes[](length); - for (uint i = 0;im) { - for (uint i = m;i 0; --index) { + i = index - 1; // the actual index + if (!validatorExtraSet[i].isMaintaining) { + continue; + } + + // only maintaining validators + validator = currentValidatorSet[i].consensusAddress; + + // exit maintenance + isFelony = _exitMaintenance(validator, i, workingValidatorCount); + if (!isFelony || numOfFelony >= _validatorSet.length - 1) { + continue; + } + + // record the jailed validator in validatorSet + for (uint k; k < _validatorSet.length; ++k) { + if (_validatorSet[k].consensusAddress == validator) { + _validatorSet[k].jailed = true; + numOfFelony++; + break; + } } } - if (m>n) { - for (uint i = n;i= felonyThreshold) { + _felony(validator, index); + ISlashIndicator(SLASH_CONTRACT_ADDR).sendFelonyPackage(validator); + isFelony = true; + } else if (slashCount >= misdemeanorThreshold) { + _misdemeanor(validator); + } + + emit validatorExitMaintenance(validator); } //rlp encode & decode function - function decodeValidatorSetSynPackage(bytes memory msgBytes) internal pure returns (IbcValidatorSetPackage memory, bool) { + function decodeValidatorSetSynPackage(bytes memory msgBytes) internal pure returns(IbcValidatorSetPackage memory, bool) { IbcValidatorSetPackage memory validatorSetPkg; RLPDecode.Iterator memory iter = msgBytes.toRLPItem().iterator(); @@ -491,13 +932,15 @@ contract BSCValidatorSet is IBSCValidatorSet, System, IParamSubscriber, IApplica validatorSetPkg.packageType = uint8(iter.next().toUint()); } else if (idx == 1) { RLPDecode.RLPItem[] memory items = iter.next().toList(); - validatorSetPkg.validatorSet =new Validator[](items.length); - for (uint j = 0;j previousHeight, "can not do this twice in one block"); + _; + previousHeight = block.number; + } + /*********************** events **************************/ event validatorSetUpdated(); event validatorJailed(address indexed validator); @@ -97,12 +154,16 @@ contract BSCValidatorSet is IBSCValidatorSet, System, IParamSubscriber, IApplica event unexpectedPackage(uint8 channelId, bytes msgBytes); event paramChange(string key, bytes value); event feeBurned(uint256 amount); + event validatorEnterMaintenance(address indexed validator); + event validatorExitMaintenance(address indexed validator); + event finalityRewardDeposit(address indexed validator, uint256 amount); + event deprecatedFinalityRewardDeposit(address indexed validator, uint256 amount); /*********************** init **************************/ function init() external onlyNotInit{ (IbcValidatorSetPackage memory validatorSetPkg, bool valid)= decodeValidatorSetSynPackage(INIT_VALIDATORSET_BYTES); require(valid, "failed to parse init validatorSet"); - for (uint i = 0;i= DUSTY_INCOMING) { - crossSize ++; - } else if (currentValidatorSet[i].incoming > 0) { - directSize ++; - } - } - - //cross transfer - address[] memory crossAddrs = new address[](crossSize); - uint256[] memory crossAmounts = new uint256[](crossSize); - uint256[] memory crossIndexes = new uint256[](crossSize); - address[] memory crossRefundAddrs = new address[](crossSize); - uint256 crossTotal; - // direct transfer - address payable[] memory directAddrs = new address payable[](directSize); - uint256[] memory directAmounts = new uint256[](directSize); - crossSize = 0; - directSize = 0; - Validator[] memory validatorSetTemp = validatorSet; // fix error: stack too deep, try removing local variables - uint256 relayFee = ITokenHub(TOKEN_HUB_ADDR).getMiniRelayFee(); - if (relayFee > DUSTY_INCOMING) { - emit failReasonWithStr("fee is larger than DUSTY_INCOMING"); - return ERROR_RELAYFEE_TOO_LARGE; - } - for (uint i = 0;i= DUSTY_INCOMING) { - crossAddrs[crossSize] = currentValidatorSet[i].BBCFeeAddress; - uint256 value = currentValidatorSet[i].incoming - currentValidatorSet[i].incoming % PRECISION; - crossAmounts[crossSize] = value.sub(relayFee); - crossRefundAddrs[crossSize] = currentValidatorSet[i].BBCFeeAddress; - crossIndexes[crossSize] = i; - crossTotal = crossTotal.add(value); - crossSize ++; - } else if (currentValidatorSet[i].incoming > 0) { - directAddrs[directSize] = currentValidatorSet[i].feeAddress; - directAmounts[directSize] = currentValidatorSet[i].incoming; - directSize ++; - } - } - - //step 2: do cross chain transfer - bool failCross = false; - if (crossTotal > 0) { - try ITokenHub(TOKEN_HUB_ADDR).batchTransferOutBNB{value:crossTotal}(crossAddrs, crossAmounts, crossRefundAddrs, uint64(block.timestamp + expireTimeSecondGap)) returns (bool success) { - if (success) { - emit batchTransfer(crossTotal); - } else { - emit batchTransferFailed(crossTotal, "batch transfer return false"); + function updateValidatorSet(Validator[] memory validatorSet, bytes[] memory voteAddrs) internal returns (uint32) { + { + // do verify. + if (validatorSet.length > MAX_NUM_OF_VALIDATORS) { + emit failReasonWithStr("the number of validators exceed the limit"); + return ERROR_FAIL_CHECK_VALIDATORS; + } + for (uint i; i < validatorSet.length; ++i) { + for (uint j; j < i; ++j) { + if (validatorSet[i].consensusAddress == validatorSet[j].consensusAddress) { + emit failReasonWithStr("duplicate consensus address of validatorSet"); + return ERROR_FAIL_CHECK_VALIDATORS; + } } - }catch Error(string memory reason) { - failCross = true; - emit batchTransferFailed(crossTotal, reason); - }catch (bytes memory lowLevelData) { - failCross = true; - emit batchTransferLowerFailed(crossTotal, lowLevelData); } } - if (failCross) { - for (uint i = 0; i< crossIndexes.length;i++) { - uint idx = crossIndexes[i]; - bool success = currentValidatorSet[idx].feeAddress.send(currentValidatorSet[idx].incoming); - if (success) { - emit directTransfer(currentValidatorSet[idx].feeAddress, currentValidatorSet[idx].incoming); - } else { - emit directTransferFail(currentValidatorSet[idx].feeAddress, currentValidatorSet[idx].incoming); + // step 0: force all maintaining validators to exit `Temporary Maintenance` + // - 1. validators exit maintenance + // - 2. clear all maintainInfo + // - 3. get unjailed validators from validatorSet + (Validator[] memory validatorSetTemp, bytes[] memory voteAddrsTemp) = _forceMaintainingValidatorsExit(validatorSet, voteAddrs); + + { + //step 1: do calculate distribution, do not make it as an internal function for saving gas. + uint crossSize; + uint directSize; + uint validatorsNum = currentValidatorSet.length; + for (uint i; i < validatorsNum; ++i) { + if (currentValidatorSet[i].incoming >= DUSTY_INCOMING) { + crossSize ++; + } else if (currentValidatorSet[i].incoming > 0) { + directSize ++; } } - } - // step 3: direct transfer - if (directAddrs.length>0) { - for (uint i = 0;i DUSTY_INCOMING) { + emit failReasonWithStr("fee is larger than DUSTY_INCOMING"); + return ERROR_RELAYFEE_TOO_LARGE; + } + for (uint i; i < validatorsNum; ++i) { + if (currentValidatorSet[i].incoming >= DUSTY_INCOMING) { + crossAddrs[crossSize] = currentValidatorSet[i].BBCFeeAddress; + uint256 value = currentValidatorSet[i].incoming - currentValidatorSet[i].incoming % PRECISION; + crossAmounts[crossSize] = value.sub(relayFee); + crossRefundAddrs[crossSize] = currentValidatorSet[i].BBCFeeAddress; + crossIndexes[crossSize] = i; + crossTotal = crossTotal.add(value); + crossSize ++; + } else if (currentValidatorSet[i].incoming > 0) { + directAddrs[directSize] = currentValidatorSet[i].feeAddress; + directAmounts[directSize] = currentValidatorSet[i].incoming; + directSize ++; + } + } + + //step 2: do cross chain transfer + bool failCross = false; + if (crossTotal > 0) { + try ITokenHub(TOKEN_HUB_ADDR).batchTransferOutBNB{value : crossTotal}(crossAddrs, crossAmounts, crossRefundAddrs, uint64(block.timestamp + expireTimeSecondGap)) returns (bool success) { + if (success) { + emit batchTransfer(crossTotal); + } else { + emit batchTransferFailed(crossTotal, "batch transfer return false"); + } + }catch Error(string memory reason) { + failCross = true; + emit batchTransferFailed(crossTotal, reason); + }catch (bytes memory lowLevelData) { + failCross = true; + emit batchTransferLowerFailed(crossTotal, lowLevelData); + } + } + + if (failCross) { + for (uint i; i< crossIndexes.length;++i) { + uint idx = crossIndexes[i]; + bool success = currentValidatorSet[idx].feeAddress.send(currentValidatorSet[idx].incoming); + if (success) { + emit directTransfer(currentValidatorSet[idx].feeAddress, currentValidatorSet[idx].incoming); + } else { + emit directTransferFail(currentValidatorSet[idx].feeAddress, currentValidatorSet[idx].incoming); + } + } + } + + // step 3: direct transfer + if (directAddrs.length>0) { + for (uint i;i0) { - doUpdateState(validatorSetTemp); + doUpdateState(validatorSetTemp, voteAddrsTemp); } // step 6: clean slash contract @@ -312,34 +392,114 @@ contract BSCValidatorSet is IBSCValidatorSet, System, IParamSubscriber, IApplica return CODE_OK; } - function getValidators()external view returns(address[] memory) { + function shuffle(address[] memory validators, bytes[] memory voteAddrs, uint256 epochNumber, uint startIdx, uint offset, uint limit, uint modNumber) internal pure { + for (uint i; i 0) { + uint256 epochNumber = block.number / EPOCH; + shuffle(validators, voteAddrs, epochNumber, _numOfCabinets-_maxNumOfWorkingCandidates, 0, _maxNumOfWorkingCandidates, _numOfCabinets); + shuffle(validators, voteAddrs, epochNumber, _numOfCabinets-_maxNumOfWorkingCandidates, _numOfCabinets-_maxNumOfWorkingCandidates, + _maxNumOfWorkingCandidates, validators.length - _numOfCabinets+_maxNumOfWorkingCandidates); + } + address[] memory miningValidators = new address[](_numOfCabinets); + bytes[] memory miningVoteAddrs = new bytes[](_numOfCabinets); + for (uint i; i<_numOfCabinets; ++i) { + miningValidators[i] = validators[i]; + miningVoteAddrs[i] = voteAddrs[i]; + } + return (miningValidators, miningVoteAddrs); + } + + function getValidators() public view returns(address[] memory) { + uint n = currentValidatorSet.length; + uint valid = 0; + for (uint i; i= currentValidatorSet.length) { return false; } - return true; + + // validatorExtraSet[index] should not be used before it has been init. + if (index >= validatorExtraSet.length) { + return !currentValidatorSet[index].jailed; + } + + return !currentValidatorSet[index].jailed && !validatorExtraSet[index].isMaintaining; } - {% endif %} + function getIncoming(address validator)external view returns(uint256) { uint256 index = currentValidatorSetMap[validator]; if (index<=0) { @@ -348,65 +508,145 @@ contract BSCValidatorSet is IBSCValidatorSet, System, IParamSubscriber, IApplica return currentValidatorSet[index-1].incoming; } - /*********************** For slash **************************/ - function misdemeanor(address validator)external onlySlash override{ + function isCurrentValidator(address validator) external view override returns (bool) { uint256 index = currentValidatorSetMap[validator]; if (index <= 0) { - return; + return false; } - // the actually index + + // the actual index index = index - 1; - uint256 income = currentValidatorSet[index].incoming; - currentValidatorSet[index].incoming = 0; - uint256 rest = currentValidatorSet.length - 1; - emit validatorMisdemeanor(validator,income); - if (rest==0) { - // should not happen, but still protect + return isWorkingValidator(index); + } + + function distributeFinalityReward(address[] calldata valAddrs, uint256[] calldata weights) external onlyCoinbase oncePerBlock onlyInit { + if (finalityRewardRatio == 0) { + finalityRewardRatio = INIT_FINALITY_REWARD_RATIO; + } + + uint256 totalValue; + totalValue = (address(SYSTEM_REWARD_ADDR).balance * finalityRewardRatio) / 100; + totalValue = ISystemReward(SYSTEM_REWARD_ADDR).claimRewards(payable(address(this)), totalValue); + if (totalValue == 0) { return; } - uint256 averageDistribute = income/rest; - if (averageDistribute!=0) { - for (uint i=0;i 0) { + Validator storage validator = currentValidatorSet[index - 1]; + if (validator.jailed) { + emit deprecatedFinalityRewardDeposit(valAddr, value); + } else { + totalInComing = totalInComing.add(value); + validator.incoming = validator.incoming.add(value); + emit finalityRewardDeposit(valAddr, value); + } + } else { + // get incoming from deprecated validator; + emit deprecatedFinalityRewardDeposit(valAddr, value); } } - // averageDistribute*rest may less than income, but it is ok, the dust income will go to system reward eventually. + + } + + function getWorkingValidatorCount() public view returns(uint256 workingValidatorCount) { + workingValidatorCount = getValidators().length; + uint256 _numOfCabinets = numOfCabinets > 0 ? numOfCabinets : INIT_NUM_OF_CABINETS; + if (workingValidatorCount > _numOfCabinets) { + workingValidatorCount = _numOfCabinets; + } + if (workingValidatorCount == 0) { + workingValidatorCount = 1; + } + } + /*********************** For slash **************************/ + function misdemeanor(address validator) external onlySlash initValidatorExtraSet override { + uint256 validatorIndex = _misdemeanor(validator); + if (canEnterMaintenance(validatorIndex)) { + _enterMaintenance(validator, validatorIndex); + } } - function felony(address validator)external onlySlash override{ + function felony(address validator)external onlySlash initValidatorExtraSet override{ uint256 index = currentValidatorSetMap[validator]; if (index <= 0) { return; } - // the actually index + // the actual index index = index - 1; - uint256 income = currentValidatorSet[index].incoming; - uint256 rest = currentValidatorSet.length - 1; - if (rest==0) { - // will not remove the validator if it is the only one validator. - currentValidatorSet[index].incoming = 0; - return; + + bool isMaintaining = validatorExtraSet[index].isMaintaining; + if (_felony(validator, index) && isMaintaining) { + numOfMaintaining--; } - emit validatorFelony(validator,income); - delete currentValidatorSetMap[validator]; - // It is ok that the validatorSet is not in order. - if (index != currentValidatorSet.length-1) { - currentValidatorSet[index] = currentValidatorSet[currentValidatorSet.length-1]; - currentValidatorSetMap[currentValidatorSet[index].consensusAddress] = index + 1; + } + + /*********************** For Temporary Maintenance **************************/ + function getCurrentValidatorIndex(address _validator) public view returns (uint256) { + uint256 index = currentValidatorSetMap[_validator]; + require(index > 0, "only current validators"); + + // the actual index + return index - 1; + } + + function canEnterMaintenance(uint256 index) public view returns (bool) { + if (index >= currentValidatorSet.length) { + return false; } - currentValidatorSet.pop(); - uint256 averageDistribute = income/rest; - if (averageDistribute!=0) { - uint n = currentValidatorSet.length; - for (uint i=0;i= maxNumOfMaintaining // - 2. check if reached upper limit + || !isWorkingValidator(index) // - 3. check if not working(not jailed and not maintaining) + || validatorExtraSet[index].enterMaintenanceHeight > 0 // - 5. check if has Maintained during current 24-hour period + // current validators are selected every 24 hours(from 00:00:00 UTC to 23:59:59 UTC) + // for more details, refer to https://github.com/bnb-chain/docs-site/blob/master/docs/smart-chain/validator/Binance%20Smart%20Chain%20Validator%20FAQs%20-%20Updated.md + || getValidators().length <= 1 // - 6. check num of remaining working validators + ) { + return false; } - // averageDistribute*rest may less than income, but it is ok, the dust income will go to system reward eventually. + + return true; + } + + function enterMaintenance() external initValidatorExtraSet { + // check maintain config + if (maxNumOfMaintaining == 0) { + maxNumOfMaintaining = INIT_MAX_NUM_OF_MAINTAINING; + } + if (maintainSlashScale == 0) { + maintainSlashScale = INIT_MAINTAIN_SLASH_SCALE; + } + + uint256 index = getCurrentValidatorIndex(msg.sender); + require(canEnterMaintenance(index), "can not enter Temporary Maintenance"); + _enterMaintenance(msg.sender, index); + } + + function exitMaintenance() external { + uint256 index = getCurrentValidatorIndex(msg.sender); + + // jailed validators are allowed to exit maintenance + require(validatorExtraSet[index].isMaintaining, "not in maintenance"); + uint256 workingValidatorCount = getWorkingValidatorCount(); + _exitMaintenance(msg.sender, index, workingValidatorCount); } /*********************** Param update ********************************/ @@ -422,6 +662,43 @@ contract BSCValidatorSet is IBSCValidatorSet, System, IParamSubscriber, IApplica require(newBurnRatio <= BURN_RATIO_SCALE, "the burnRatio must be no greater than 10000"); burnRatio = newBurnRatio; burnRatioInitialized = true; + } else if (Memory.compareStrings(key, "maxNumOfMaintaining")) { + require(value.length == 32, "length of maxNumOfMaintaining mismatch"); + uint256 newMaxNumOfMaintaining = BytesToTypes.bytesToUint256(32, value); + uint256 _numOfCabinets = numOfCabinets; + if (_numOfCabinets == 0) { + _numOfCabinets = INIT_NUM_OF_CABINETS; + } + require(newMaxNumOfMaintaining < _numOfCabinets, "the maxNumOfMaintaining must be less than numOfCabinets"); + maxNumOfMaintaining = newMaxNumOfMaintaining; + } else if (Memory.compareStrings(key, "maintainSlashScale")) { + require(value.length == 32, "length of maintainSlashScale mismatch"); + uint256 newMaintainSlashScale = BytesToTypes.bytesToUint256(32, value); + require(newMaintainSlashScale > 0, "the maintainSlashScale must be greater than 0"); + maintainSlashScale = newMaintainSlashScale; + } else if (Memory.compareStrings(key, "maxNumOfWorkingCandidates")) { + require(value.length == 32, "length of maxNumOfWorkingCandidates mismatch"); + uint256 newMaxNumOfWorkingCandidates = BytesToTypes.bytesToUint256(32, value); + require(newMaxNumOfWorkingCandidates <= maxNumOfCandidates, "the maxNumOfWorkingCandidates must be not greater than maxNumOfCandidates"); + maxNumOfWorkingCandidates = newMaxNumOfWorkingCandidates; + } else if (Memory.compareStrings(key, "maxNumOfCandidates")) { + require(value.length == 32, "length of maxNumOfCandidates mismatch"); + uint256 newMaxNumOfCandidates = BytesToTypes.bytesToUint256(32, value); + maxNumOfCandidates = newMaxNumOfCandidates; + if (maxNumOfWorkingCandidates > maxNumOfCandidates) { + maxNumOfWorkingCandidates = maxNumOfCandidates; + } + } else if (Memory.compareStrings(key, "numOfCabinets")) { + require(value.length == 32, "length of numOfCabinets mismatch"); + uint256 newNumOfCabinets = BytesToTypes.bytesToUint256(32, value); + require(newNumOfCabinets > 0, "the numOfCabinets must be greater than 0"); + require(newNumOfCabinets <= MAX_NUM_OF_VALIDATORS, "the numOfCabinets must be less than MAX_NUM_OF_VALIDATORS"); + numOfCabinets = newNumOfCabinets; + } else if (Memory.compareStrings(key, "finalityRewardRatio")) { + require(value.length == 32, "length of finalityRewardRatio mismatch"); + uint256 newFinalityRewardRatio = BytesToTypes.bytesToUint256(32, value); + require(newFinalityRewardRatio >= 1 && newFinalityRewardRatio < 100, "the finalityRewardRatio is out of range"); + finalityRewardRatio = newFinalityRewardRatio; } else { require(false, "unknown param"); } @@ -429,67 +706,222 @@ contract BSCValidatorSet is IBSCValidatorSet, System, IParamSubscriber, IApplica } /*********************** Internal Functions **************************/ + function doUpdateState(Validator[] memory validatorSet, bytes[] memory voteAddrs) private { + uint n = currentValidatorSet.length; + uint m = validatorSet.length; - function checkValidatorSet(Validator[] memory validatorSet) private pure returns(bool, string memory) { - if (validatorSet.length > MAX_NUM_OF_VALIDATORS){ - return (false, "the number of validators exceed the limit"); + for (uint i; i < n; ++i) { + Validator memory oldValidator = currentValidatorSet[i]; + delete currentValidatorSetMap[oldValidator.consensusAddress]; } - for (uint i = 0;im) { + for (uint i = m; i < n; ++i) { + currentValidatorSet.pop(); + validatorExtraSet.pop(); } } - return (true,""); + uint k = n < m ? n:m; + for (uint i; i < k; ++i) { + currentValidatorSetMap[validatorSet[i].consensusAddress] = i+1; + currentValidatorSet[i] = validatorSet[i]; + validatorExtraSet[i].voteAddress = voteAddrs[i]; + validatorExtraSet[i].isMaintaining = false; + validatorExtraSet[i].enterMaintenanceHeight = 0; + } + if (m>n) { + ValidatorExtra memory _validatorExtra; + for (uint i = n; i < m; i++) { + _validatorExtra.voteAddress = voteAddrs[i]; + currentValidatorSet.push(validatorSet[i]); + validatorExtraSet.push(_validatorExtra); + currentValidatorSetMap[validatorSet[i].consensusAddress] = i+1; + } + } + + // make sure all new validators are cleared maintainInfo + // should not happen, still protect + numOfMaintaining = 0; + n = currentValidatorSet.length; + for (uint i; i < n; ++i) { + validatorExtraSet[i].isMaintaining = false; + validatorExtraSet[i].enterMaintenanceHeight = 0; + } } - function doUpdateState(Validator[] memory validatorSet) private{ + function getVoteAddresses(address[] memory validators) internal view returns(bytes[] memory) { uint n = currentValidatorSet.length; - uint m = validatorSet.length; + uint length = validators.length; + bytes[] memory voteAddrs = new bytes[](length); - for (uint i = 0;im) { - for (uint i = m;i 0; --index) { + i = index - 1; // the actual index + if (!validatorExtraSet[i].isMaintaining) { + continue; + } + + // only maintaining validators + validator = currentValidatorSet[i].consensusAddress; + + // exit maintenance + isFelony = _exitMaintenance(validator, i, workingValidatorCount); + if (!isFelony || numOfFelony >= _validatorSet.length - 1) { + continue; + } + + // record the jailed validator in validatorSet + for (uint k; k < _validatorSet.length; ++k) { + if (_validatorSet[k].consensusAddress == validator) { + _validatorSet[k].jailed = true; + numOfFelony++; + break; + } } } - if (m>n) { - for (uint i = n;i= felonyThreshold) { + _felony(validator, index); + ISlashIndicator(SLASH_CONTRACT_ADDR).sendFelonyPackage(validator); + isFelony = true; + } else if (slashCount >= misdemeanorThreshold) { + _misdemeanor(validator); + } + + emit validatorExitMaintenance(validator); } //rlp encode & decode function - function decodeValidatorSetSynPackage(bytes memory msgBytes) internal pure returns (IbcValidatorSetPackage memory, bool) { + function decodeValidatorSetSynPackage(bytes memory msgBytes) internal pure returns(IbcValidatorSetPackage memory, bool) { IbcValidatorSetPackage memory validatorSetPkg; RLPDecode.Iterator memory iter = msgBytes.toRLPItem().iterator(); @@ -500,13 +932,15 @@ contract BSCValidatorSet is IBSCValidatorSet, System, IParamSubscriber, IApplica validatorSetPkg.packageType = uint8(iter.next().toUint()); } else if (idx == 1) { RLPDecode.RLPItem[] memory items = iter.next().toList(); - validatorSetPkg.validatorSet =new Validator[](items.length); - for (uint j = 0;j uint64) public channelReceiveSequenceMap; mapping(uint8 => bool) public isRelayRewardFromSystemReward; + // to prevent the utilization of ancient block header + mapping(uint8 => uint64) public channelSyncedHeaderMap; + // event event crossChainPackage(uint16 chainId, uint64 indexed oracleSequence, uint64 indexed packageSequence, uint8 indexed channelId, bytes payload); event receivedPackage(uint8 packageType, uint64 indexed packageSequence, uint8 indexed channelId); @@ -68,6 +70,14 @@ contract CrossChain is System, ICrossChain, IParamSubscriber{ _; } + modifier headerInOrder(uint64 height, uint8 channelId) { + require(height >= channelSyncedHeaderMap[channelId], "too old header"); + if (height != channelSyncedHeaderMap[channelId]) { + channelSyncedHeaderMap[channelId] = height; + } + _; + } + // | length | prefix | sourceChainID| destinationChainID | channelID | sequence | // | 32 bytes | 1 byte | 2 bytes | 2 bytes | 1 bytes | 8 bytes | function generateKey(uint64 _sequence, uint8 _channelID) internal pure returns(bytes memory) { @@ -127,7 +137,7 @@ contract CrossChain is System, ICrossChain, IParamSubscriber{ alreadyInit=true; } -function encodePayload(uint8 packageType, uint256 relayFee, bytes memory msgBytes) public pure returns(bytes memory) { + function encodePayload(uint8 packageType, uint256 relayFee, bytes memory msgBytes) public pure returns(bytes memory) { uint256 payloadLength = msgBytes.length + 33; bytes memory payload = new bytes(payloadLength); uint256 ptr; @@ -189,21 +199,22 @@ function encodePayload(uint8 packageType, uint256 relayFee, bytes memory msgByte return (true, packageType, relayFee, msgBytes); } - function handlePackage(bytes calldata payload, bytes calldata proof, uint64 height, uint64 packageSequence, uint8 channelId) onlyInit onlyRelayer - sequenceInOrder(packageSequence, channelId) blockSynced(height) channelSupported(channelId) external { + function handlePackage(bytes calldata payload, bytes calldata proof, uint64 height, uint64 packageSequence, uint8 channelId) onlyInit onlyRelayer onlyWhitelabelRelayer + sequenceInOrder(packageSequence, channelId) blockSynced(height) channelSupported(channelId) headerInOrder(height, channelId) external { bytes memory payloadLocal = payload; // fix error: stack too deep, try removing local variables bytes memory proofLocal = proof; // fix error: stack too deep, try removing local variables require(MerkleProof.validateMerkleProof(ILightClient(LIGHT_CLIENT_ADDR).getAppHash(height), STORE_NAME, generateKey(packageSequence, channelId), payloadLocal, proofLocal), "invalid merkle proof"); address payable headerRelayer = ILightClient(LIGHT_CLIENT_ADDR).getSubmitter(height); + uint64 sequenceLocal = packageSequence; // fix error: stack too deep, try removing local variables uint8 channelIdLocal = channelId; // fix error: stack too deep, try removing local variables (bool success, uint8 packageType, uint256 relayFee, bytes memory msgBytes) = decodePayloadHeader(payloadLocal); if (!success) { - emit unsupportedPackage(packageSequence, channelIdLocal, payloadLocal); + emit unsupportedPackage(sequenceLocal, channelIdLocal, payloadLocal); return; } - emit receivedPackage(packageType, packageSequence, channelIdLocal); + emit receivedPackage(packageType, sequenceLocal, channelIdLocal); if (packageType == SYN_PACKAGE) { address handlerContract = channelHandlerContractMap[channelIdLocal]; try IApplication(handlerContract).handleSynPackage(channelIdLocal, msgBytes) returns (bytes memory responsePayload) { @@ -315,4 +326,4 @@ function encodePayload(uint8 packageType, uint256 relayFee, bytes memory msgByte } emit paramChange(key, value); } -} \ No newline at end of file +} diff --git a/contracts/CrossChain.template b/contracts/CrossChain.template index c363268a..0e9a6653 100644 --- a/contracts/CrossChain.template +++ b/contracts/CrossChain.template @@ -9,9 +9,7 @@ import "./lib/Memory.sol"; import "./lib/BytesToTypes.sol"; import "./interface/IParamSubscriber.sol"; import "./System.sol"; -{% if mock %}import "./mock/MerkleProof.sol"; -{% else %}import "./MerkleProof.sol"; -{% endif %} +import "./MerkleProof.sol"; contract CrossChain is System, ICrossChain, IParamSubscriber{ @@ -36,6 +34,9 @@ contract CrossChain is System, ICrossChain, IParamSubscriber{ mapping(uint8 => uint64) public channelReceiveSequenceMap; mapping(uint8 => bool) public isRelayRewardFromSystemReward; + // to prevent the utilization of ancient block header + mapping(uint8 => uint64) public channelSyncedHeaderMap; + // event event crossChainPackage(uint16 chainId, uint64 indexed oracleSequence, uint64 indexed packageSequence, uint8 indexed channelId, bytes payload); event receivedPackage(uint8 packageType, uint64 indexed packageSequence, uint8 indexed channelId); @@ -69,6 +70,14 @@ contract CrossChain is System, ICrossChain, IParamSubscriber{ _; } + modifier headerInOrder(uint64 height, uint8 channelId) { + require(height >= channelSyncedHeaderMap[channelId], "too old header"); + if (height != channelSyncedHeaderMap[channelId]) { + channelSyncedHeaderMap[channelId] = height; + } + _; + } + // | length | prefix | sourceChainID| destinationChainID | channelID | sequence | // | 32 bytes | 1 byte | 2 bytes | 2 bytes | 1 bytes | 8 bytes | function generateKey(uint64 _sequence, uint8 _channelID) internal pure returns(bytes memory) { @@ -128,7 +137,7 @@ contract CrossChain is System, ICrossChain, IParamSubscriber{ alreadyInit=true; } -function encodePayload(uint8 packageType, uint256 relayFee, bytes memory msgBytes) public pure returns(bytes memory) { + function encodePayload(uint8 packageType, uint256 relayFee, bytes memory msgBytes) public pure returns(bytes memory) { uint256 payloadLength = msgBytes.length + 33; bytes memory payload = new bytes(payloadLength); uint256 ptr; @@ -190,21 +199,22 @@ function encodePayload(uint8 packageType, uint256 relayFee, bytes memory msgByte return (true, packageType, relayFee, msgBytes); } - function handlePackage(bytes calldata payload, bytes calldata proof, uint64 height, uint64 packageSequence, uint8 channelId) onlyInit onlyRelayer - sequenceInOrder(packageSequence, channelId) blockSynced(height) channelSupported(channelId) external { + function handlePackage(bytes calldata payload, bytes calldata proof, uint64 height, uint64 packageSequence, uint8 channelId) onlyInit onlyRelayer onlyWhitelabelRelayer + sequenceInOrder(packageSequence, channelId) blockSynced(height) channelSupported(channelId) headerInOrder(height, channelId) external { bytes memory payloadLocal = payload; // fix error: stack too deep, try removing local variables bytes memory proofLocal = proof; // fix error: stack too deep, try removing local variables require(MerkleProof.validateMerkleProof(ILightClient(LIGHT_CLIENT_ADDR).getAppHash(height), STORE_NAME, generateKey(packageSequence, channelId), payloadLocal, proofLocal), "invalid merkle proof"); address payable headerRelayer = ILightClient(LIGHT_CLIENT_ADDR).getSubmitter(height); + uint64 sequenceLocal = packageSequence; // fix error: stack too deep, try removing local variables uint8 channelIdLocal = channelId; // fix error: stack too deep, try removing local variables (bool success, uint8 packageType, uint256 relayFee, bytes memory msgBytes) = decodePayloadHeader(payloadLocal); if (!success) { - emit unsupportedPackage(packageSequence, channelIdLocal, payloadLocal); + emit unsupportedPackage(sequenceLocal, channelIdLocal, payloadLocal); return; } - emit receivedPackage(packageType, packageSequence, channelIdLocal); + emit receivedPackage(packageType, sequenceLocal, channelIdLocal); if (packageType == SYN_PACKAGE) { address handlerContract = channelHandlerContractMap[channelIdLocal]; try IApplication(handlerContract).handleSynPackage(channelIdLocal, msgBytes) returns (bytes memory responsePayload) { @@ -316,4 +326,4 @@ function encodePayload(uint8 packageType, uint256 relayFee, bytes memory msgByte } emit paramChange(key, value); } -} \ No newline at end of file +} diff --git a/contracts/Migrations.sol b/contracts/Migrations.sol deleted file mode 100644 index ab55d35c..00000000 --- a/contracts/Migrations.sol +++ /dev/null @@ -1,18 +0,0 @@ -pragma solidity 0.6.4; - -contract Migrations { - address public owner; - uint public last_completed_migration; - - constructor() public { - owner = msg.sender; - } - - modifier restricted() { - if (msg.sender == owner) _; - } - - function setCompleted(uint completed) public restricted { - last_completed_migration = completed; - } -} diff --git a/contracts/RelayerHub.sol b/contracts/RelayerHub.sol index a2fe99c7..6a714943 100644 --- a/contracts/RelayerHub.sol +++ b/contracts/RelayerHub.sol @@ -57,10 +57,7 @@ contract RelayerHub is IRelayerHub, System, IParamSubscriber{ } function register() external payable noExist onlyInit notContract noProxy{ - require(msg.value == requiredDeposit, "deposit value is not exactly the same"); - relayers[msg.sender] = relayer(requiredDeposit, dues); - relayersExistMap[msg.sender] = true; - emit relayerRegister(msg.sender); + revert("register suspended"); } function unregister() external exist onlyInit{ diff --git a/contracts/RelayerHub.template b/contracts/RelayerHub.template new file mode 100644 index 00000000..6a714943 --- /dev/null +++ b/contracts/RelayerHub.template @@ -0,0 +1,94 @@ +pragma solidity 0.6.4; + +import "./lib/BytesToTypes.sol"; +import "./lib/Memory.sol"; +import "./interface/IRelayerHub.sol"; +import "./interface/IParamSubscriber.sol"; +import "./System.sol"; +import "./lib/SafeMath.sol"; + + +contract RelayerHub is IRelayerHub, System, IParamSubscriber{ + using SafeMath for uint256; + + uint256 public constant INIT_REQUIRED_DEPOSIT = 1e20; + uint256 public constant INIT_DUES = 1e17; + + uint256 public requiredDeposit; + uint256 public dues; + + mapping(address =>relayer) relayers; + mapping(address =>bool) relayersExistMap; + + struct relayer{ + uint256 deposit; + uint256 dues; + } + + modifier notContract() { + require(!isContract(msg.sender), "contract is not allowed to be a relayer"); + _; + } + + modifier noProxy() { + require(msg.sender == tx.origin, "no proxy is allowed"); + _; + } + + modifier noExist() { + require(!relayersExistMap[msg.sender], "relayer already exist"); + _; + } + + modifier exist() { + require(relayersExistMap[msg.sender], "relayer do not exist"); + _; + } + + event relayerRegister(address _relayer); + event relayerUnRegister(address _relayer); + event paramChange(string key, bytes value); + + + function init() external onlyNotInit{ + requiredDeposit = INIT_REQUIRED_DEPOSIT; + dues = INIT_DUES; + alreadyInit = true; + } + + function register() external payable noExist onlyInit notContract noProxy{ + revert("register suspended"); + } + + function unregister() external exist onlyInit{ + relayer memory r = relayers[msg.sender]; + msg.sender.transfer(r.deposit.sub(r.dues)); + address payable systemPayable = address(uint160(SYSTEM_REWARD_ADDR)); + systemPayable.transfer(r.dues); + delete relayersExistMap[msg.sender]; + delete relayers[msg.sender]; + emit relayerUnRegister(msg.sender); + } + + /*********************** Param update ********************************/ + function updateParam(string calldata key, bytes calldata value) external override onlyInit onlyGov{ + if (Memory.compareStrings(key,"requiredDeposit")) { + require(value.length == 32, "length of requiredDeposit mismatch"); + uint256 newRequiredDeposit = BytesToTypes.bytesToUint256(32, value); + require(newRequiredDeposit > 1 && newRequiredDeposit <= 1e21 && newRequiredDeposit > dues, "the requiredDeposit out of range"); + requiredDeposit = newRequiredDeposit; + } else if (Memory.compareStrings(key,"dues")) { + require(value.length == 32, "length of dues mismatch"); + uint256 newDues = BytesToTypes.bytesToUint256(32, value); + require(newDues > 0 && newDues < requiredDeposit, "the dues out of range"); + dues = newDues; + } else { + require(false, "unknown param"); + } + emit paramChange(key, value); + } + + function isRelayer(address sender) external override view returns (bool) { + return relayersExistMap[sender]; + } +} diff --git a/contracts/RelayerIncentivize.sol b/contracts/RelayerIncentivize.sol index 345df464..47ae46b2 100644 --- a/contracts/RelayerIncentivize.sol +++ b/contracts/RelayerIncentivize.sol @@ -56,9 +56,7 @@ contract RelayerIncentivize is IRelayerIncentivize, System, IParamSubscriber { receive() external payable{} - function addReward(address payable headerRelayerAddr, address payable packageRelayer, uint256 amount, bool fromSystemReward) onlyInit onlyCrossChainContract external override returns (bool) { - uint256 actualAmount; if (fromSystemReward) { actualAmount = ISystemReward(SYSTEM_REWARD_ADDR).claimRewards(address(uint160(INCENTIVIZE_ADDR)), amount.add(dynamicExtraIncentiveAmount)); diff --git a/contracts/RelayerIncentivize.template b/contracts/RelayerIncentivize.template index 9e0b8465..9df2abab 100644 --- a/contracts/RelayerIncentivize.template +++ b/contracts/RelayerIncentivize.template @@ -56,11 +56,7 @@ contract RelayerIncentivize is IRelayerIncentivize, System, IParamSubscriber { receive() external payable{} - {% if mock %} - function addReward(address payable headerRelayerAddr, address payable packageRelayer, uint256 amount, bool fromSystemReward) external override returns (bool) { - {% else %} function addReward(address payable headerRelayerAddr, address payable packageRelayer, uint256 amount, bool fromSystemReward) onlyInit onlyCrossChainContract external override returns (bool) { - {% endif %} uint256 actualAmount; if (fromSystemReward) { actualAmount = ISystemReward(SYSTEM_REWARD_ADDR).claimRewards(address(uint160(INCENTIVIZE_ADDR)), amount.add(dynamicExtraIncentiveAmount)); diff --git a/contracts/SlashIndicator.sol b/contracts/SlashIndicator.sol index f20269b6..7517983b 100644 --- a/contracts/SlashIndicator.sol +++ b/contracts/SlashIndicator.sol @@ -1,12 +1,17 @@ pragma solidity 0.6.4; +pragma experimental ABIEncoderV2; + import "./System.sol"; import "./lib/BytesToTypes.sol"; +import "./lib/TypesToBytes.sol"; +import "./lib/BytesLib.sol"; import "./lib/Memory.sol"; import "./interface/ISlashIndicator.sol"; import "./interface/IApplication.sol"; import "./interface/IBSCValidatorSet.sol"; import "./interface/IParamSubscriber.sol"; import "./interface/ICrossChain.sol"; +import "./interface/ISystemReward.sol"; import "./lib/CmnPkg.sol"; import "./lib/RLPEncode.sol"; @@ -22,9 +27,17 @@ contract SlashIndicator is ISlashIndicator,System,IParamSubscriber, IApplication address[] public validators; mapping(address => Indicator) public indicators; uint256 public previousHeight; + + // The BSC validators assign proper values for `misdemeanorThreshold` and `felonyThreshold` through governance. + // The proper values depends on BSC network's tolerance for continuous missing blocks. uint256 public misdemeanorThreshold; uint256 public felonyThreshold; + // BEP-126 Fast Finality + uint256 public constant INIT_FINALITY_SLASH_REWARD_RATIO = 20; + + uint256 public finalitySlashRewardRatio; + event validatorSlashed(address indexed validator); event indicatorCleaned(); event paramChange(string key, bytes value); @@ -39,6 +52,21 @@ contract SlashIndicator is ISlashIndicator,System,IParamSubscriber, IApplication bool exist; } + // Proof that a validator misbehaved in fast finality + struct VoteData { + uint256 srcNum; + bytes32 srcHash; + uint256 tarNum; + bytes32 tarHash; + bytes sig; + } + + struct FinalityEvidence { + VoteData voteA; + VoteData voteB; + bytes voteAddr; + } + modifier oncePerBlock() { require(block.number > previousHeight, "can not slash twice in one block"); _; @@ -80,6 +108,9 @@ contract SlashIndicator is ISlashIndicator,System,IParamSubscriber, IApplication /*********************** External func ********************************/ function slash(address validator) external onlyCoinbase onlyInit oncePerBlock onlyZeroGasPrice{ + if (!IBSCValidatorSet(VALIDATOR_CONTRACT_ADDR).isCurrentValidator(validator)) { + return; + } Indicator memory indicator = indicators[validator]; if (indicator.exist) { indicator.count++; @@ -100,7 +131,6 @@ contract SlashIndicator is ISlashIndicator,System,IParamSubscriber, IApplication emit validatorSlashed(validator); } - // To prevent validator misbehaving and leaving, do not clean slash record to zero, but decrease by felonyThreshold/DECREASE_RATE . // Clean is an effective implement to reorganize "validators" and "indicators". function clean() external override(ISlashIndicator) onlyValidatorContract onlyInit{ @@ -155,6 +185,88 @@ contract SlashIndicator is ISlashIndicator,System,IParamSubscriber, IApplication emit indicatorCleaned(); } + function submitFinalityViolationEvidence(FinalityEvidence memory _evidence) public onlyInit onlyRelayer { + if (finalitySlashRewardRatio == 0) { + finalitySlashRewardRatio = INIT_FINALITY_SLASH_REWARD_RATIO; + } + + // Basic check + require(_evidence.voteA.srcNum+256 > block.number && + _evidence.voteB.srcNum+256 > block.number, "too old block involved"); + require(!(_evidence.voteA.srcHash == _evidence.voteB.srcHash && + _evidence.voteA.tarHash == _evidence.voteB.tarHash), "two identical votes"); + require(_evidence.voteA.srcNum < _evidence.voteA.tarNum && + _evidence.voteB.srcNum < _evidence.voteB.tarNum, "srcNum bigger than tarNum"); + + // Vote rules check + require((_evidence.voteA.srcNum<_evidence.voteB.srcNum && _evidence.voteB.tarNum<_evidence.voteA.tarNum) || + (_evidence.voteB.srcNum<_evidence.voteA.srcNum && _evidence.voteA.tarNum<_evidence.voteB.tarNum) || + _evidence.voteA.tarNum == _evidence.voteB.tarNum, "no violation of vote rules"); + + // BLS verification + (address[] memory vals, bytes[] memory voteAddrs) = IBSCValidatorSet(VALIDATOR_CONTRACT_ADDR).getLivingValidators(); + address valAddr; + bytes memory voteAddr = _evidence.voteAddr; + for (uint i; i < voteAddrs.length; ++i) { + if (BytesLib.equal(voteAddrs[i], voteAddr)) { + valAddr = vals[i]; + break; + } + } + require(valAddr != address(0), "validator not exist"); + + require(verifyBLSSignature(_evidence.voteA, _evidence.voteAddr) && + verifyBLSSignature(_evidence.voteB, _evidence.voteAddr), "verify signature failed"); + + uint256 amount = (address(SYSTEM_REWARD_ADDR).balance * finalitySlashRewardRatio) / 100; + ISystemReward(SYSTEM_REWARD_ADDR).claimRewards(msg.sender, amount); + IBSCValidatorSet(VALIDATOR_CONTRACT_ADDR).felony(valAddr); + ICrossChain(CROSS_CHAIN_CONTRACT_ADDR).sendSynPackage(SLASH_CHANNELID, encodeSlashPackage(valAddr), 0); + emit validatorSlashed(valAddr); + } + + function sendFelonyPackage(address validator) external override(ISlashIndicator) onlyValidatorContract onlyInit { + ICrossChain(CROSS_CHAIN_CONTRACT_ADDR).sendSynPackage(SLASH_CHANNELID, encodeSlashPackage(validator), 0); + } + + function verifyBLSSignature(VoteData memory vote, bytes memory voteAddr) internal view returns(bool) { + bytes[] memory elements = new bytes[](4); + bytes memory _bytes = new bytes(32); + elements[0] = vote.srcNum.encodeUint(); + TypesToBytes.bytes32ToBytes(32, vote.srcHash, _bytes); + elements[1] = _bytes.encodeBytes(); + elements[2] = vote.tarNum.encodeUint(); + TypesToBytes.bytes32ToBytes(32, vote.tarHash, _bytes); + elements[3] = _bytes.encodeBytes(); + + TypesToBytes.bytes32ToBytes(32, keccak256(elements.encodeList()), _bytes); + + // assemble input data + bytes memory input = new bytes(176); + bytesConcat(input, _bytes, 0, 32); + bytesConcat(input, vote.sig, 32, 96); + bytesConcat(input, voteAddr, 128, 48); + + // call the precompiled contract to verify the BLS signature + // the precompiled contract's address is 0x66 + bytes memory output = new bytes(1); + assembly { + let len := mload(input) + if iszero(staticcall(not(0), 0x66, add(input, 0x20), len, add(output, 0x20), 0x01)) { + revert(0, 0) + } + } + if (BytesLib.toUint8(output, 0) != uint8(1)) { + return false; + } + return true; + } + + function bytesConcat(bytes memory data, bytes memory _bytes, uint256 index, uint256 len) internal pure { + for (uint i; i misdemeanorThreshold, "the felonyThreshold out of range"); felonyThreshold = newFelonyThreshold; + } else if (Memory.compareStrings(key, "finalitySlashRewardRatio")) { + require(value.length == 32, "length of finalitySlashRewardRatio mismatch"); + uint256 newFinalitySlashRewardRatio = BytesToTypes.bytesToUint256(32, value); + require(newFinalitySlashRewardRatio >= 10 && newFinalitySlashRewardRatio < 100, "the finality slash reward ratio out of range"); + finalitySlashRewardRatio = newFinalitySlashRewardRatio; } else { require(false, "unknown param"); } @@ -188,4 +305,8 @@ contract SlashIndicator is ISlashIndicator,System,IParamSubscriber, IApplication elements[3] = uint256(block.timestamp).encodeUint(); return elements.encodeList(); } -} \ No newline at end of file + + function getSlashThresholds() override(ISlashIndicator) external view returns (uint256, uint256) { + return (misdemeanorThreshold, felonyThreshold); + } +} diff --git a/contracts/SlashIndicator.template b/contracts/SlashIndicator.template index f1e9ad32..3f1f5613 100644 --- a/contracts/SlashIndicator.template +++ b/contracts/SlashIndicator.template @@ -1,12 +1,17 @@ pragma solidity 0.6.4; +pragma experimental ABIEncoderV2; + import "./System.sol"; import "./lib/BytesToTypes.sol"; +import "./lib/TypesToBytes.sol"; +import "./lib/BytesLib.sol"; import "./lib/Memory.sol"; import "./interface/ISlashIndicator.sol"; import "./interface/IApplication.sol"; import "./interface/IBSCValidatorSet.sol"; import "./interface/IParamSubscriber.sol"; import "./interface/ICrossChain.sol"; +import "./interface/ISystemReward.sol"; import "./lib/CmnPkg.sol"; import "./lib/RLPEncode.sol"; @@ -22,9 +27,17 @@ contract SlashIndicator is ISlashIndicator,System,IParamSubscriber, IApplication address[] public validators; mapping(address => Indicator) public indicators; uint256 public previousHeight; + + // The BSC validators assign proper values for `misdemeanorThreshold` and `felonyThreshold` through governance. + // The proper values depends on BSC network's tolerance for continuous missing blocks. uint256 public misdemeanorThreshold; uint256 public felonyThreshold; + // BEP-126 Fast Finality + uint256 public constant INIT_FINALITY_SLASH_REWARD_RATIO = 20; + + uint256 public finalitySlashRewardRatio; + event validatorSlashed(address indexed validator); event indicatorCleaned(); event paramChange(string key, bytes value); @@ -39,6 +52,21 @@ contract SlashIndicator is ISlashIndicator,System,IParamSubscriber, IApplication bool exist; } + // Proof that a validator misbehaved in fast finality + struct VoteData { + uint256 srcNum; + bytes32 srcHash; + uint256 tarNum; + bytes32 tarHash; + bytes sig; + } + + struct FinalityEvidence { + VoteData voteA; + VoteData voteB; + bytes voteAddr; + } + modifier oncePerBlock() { require(block.number > previousHeight, "can not slash twice in one block"); _; @@ -85,6 +113,9 @@ contract SlashIndicator is ISlashIndicator,System,IParamSubscriber, IApplication /*********************** External func ********************************/ function slash(address validator) external onlyCoinbase onlyInit oncePerBlock onlyZeroGasPrice{ + if (!IBSCValidatorSet(VALIDATOR_CONTRACT_ADDR).isCurrentValidator(validator)) { + return; + } Indicator memory indicator = indicators[validator]; if (indicator.exist) { indicator.count++; @@ -105,7 +136,6 @@ contract SlashIndicator is ISlashIndicator,System,IParamSubscriber, IApplication emit validatorSlashed(validator); } - // To prevent validator misbehaving and leaving, do not clean slash record to zero, but decrease by felonyThreshold/DECREASE_RATE . // Clean is an effective implement to reorganize "validators" and "indicators". function clean() external override(ISlashIndicator) onlyValidatorContract onlyInit{ @@ -160,6 +190,88 @@ contract SlashIndicator is ISlashIndicator,System,IParamSubscriber, IApplication emit indicatorCleaned(); } + function submitFinalityViolationEvidence(FinalityEvidence memory _evidence) public onlyInit onlyRelayer { + if (finalitySlashRewardRatio == 0) { + finalitySlashRewardRatio = INIT_FINALITY_SLASH_REWARD_RATIO; + } + + // Basic check + require(_evidence.voteA.srcNum+256 > block.number && + _evidence.voteB.srcNum+256 > block.number, "too old block involved"); + require(!(_evidence.voteA.srcHash == _evidence.voteB.srcHash && + _evidence.voteA.tarHash == _evidence.voteB.tarHash), "two identical votes"); + require(_evidence.voteA.srcNum < _evidence.voteA.tarNum && + _evidence.voteB.srcNum < _evidence.voteB.tarNum, "srcNum bigger than tarNum"); + + // Vote rules check + require((_evidence.voteA.srcNum<_evidence.voteB.srcNum && _evidence.voteB.tarNum<_evidence.voteA.tarNum) || + (_evidence.voteB.srcNum<_evidence.voteA.srcNum && _evidence.voteA.tarNum<_evidence.voteB.tarNum) || + _evidence.voteA.tarNum == _evidence.voteB.tarNum, "no violation of vote rules"); + + // BLS verification + (address[] memory vals, bytes[] memory voteAddrs) = IBSCValidatorSet(VALIDATOR_CONTRACT_ADDR).getLivingValidators(); + address valAddr; + bytes memory voteAddr = _evidence.voteAddr; + for (uint i; i < voteAddrs.length; ++i) { + if (BytesLib.equal(voteAddrs[i], voteAddr)) { + valAddr = vals[i]; + break; + } + } + require(valAddr != address(0), "validator not exist"); +{% if mock %}{% else %} + require(verifyBLSSignature(_evidence.voteA, _evidence.voteAddr) && + verifyBLSSignature(_evidence.voteB, _evidence.voteAddr), "verify signature failed"); +{% endif %} + uint256 amount = (address(SYSTEM_REWARD_ADDR).balance * finalitySlashRewardRatio) / 100; + ISystemReward(SYSTEM_REWARD_ADDR).claimRewards(msg.sender, amount); + IBSCValidatorSet(VALIDATOR_CONTRACT_ADDR).felony(valAddr); + ICrossChain(CROSS_CHAIN_CONTRACT_ADDR).sendSynPackage(SLASH_CHANNELID, encodeSlashPackage(valAddr), 0); + emit validatorSlashed(valAddr); + } + + function sendFelonyPackage(address validator) external override(ISlashIndicator) onlyValidatorContract onlyInit { + ICrossChain(CROSS_CHAIN_CONTRACT_ADDR).sendSynPackage(SLASH_CHANNELID, encodeSlashPackage(validator), 0); + } + + function verifyBLSSignature(VoteData memory vote, bytes memory voteAddr) internal view returns(bool) { + bytes[] memory elements = new bytes[](4); + bytes memory _bytes = new bytes(32); + elements[0] = vote.srcNum.encodeUint(); + TypesToBytes.bytes32ToBytes(32, vote.srcHash, _bytes); + elements[1] = _bytes.encodeBytes(); + elements[2] = vote.tarNum.encodeUint(); + TypesToBytes.bytes32ToBytes(32, vote.tarHash, _bytes); + elements[3] = _bytes.encodeBytes(); + + TypesToBytes.bytes32ToBytes(32, keccak256(elements.encodeList()), _bytes); + + // assemble input data + bytes memory input = new bytes(176); + bytesConcat(input, _bytes, 0, 32); + bytesConcat(input, vote.sig, 32, 96); + bytesConcat(input, voteAddr, 128, 48); + + // call the precompiled contract to verify the BLS signature + // the precompiled contract's address is 0x66 + bytes memory output = new bytes(1); + assembly { + let len := mload(input) + if iszero(staticcall(not(0), 0x66, add(input, 0x20), len, add(output, 0x20), 0x01)) { + revert(0, 0) + } + } + if (BytesLib.toUint8(output, 0) != uint8(1)) { + return false; + } + return true; + } + + function bytesConcat(bytes memory data, bytes memory _bytes, uint256 index, uint256 len) internal pure { + for (uint i; i misdemeanorThreshold, "the felonyThreshold out of range"); felonyThreshold = newFelonyThreshold; + } else if (Memory.compareStrings(key, "finalitySlashRewardRatio")) { + require(value.length == 32, "length of finalitySlashRewardRatio mismatch"); + uint256 newFinalitySlashRewardRatio = BytesToTypes.bytesToUint256(32, value); + require(newFinalitySlashRewardRatio >= 10 && newFinalitySlashRewardRatio < 100, "the finality slash reward ratio out of range"); + finalitySlashRewardRatio = newFinalitySlashRewardRatio; } else { require(false, "unknown param"); } @@ -193,4 +310,8 @@ contract SlashIndicator is ISlashIndicator,System,IParamSubscriber, IApplication elements[3] = uint256(block.timestamp).encodeUint(); return elements.encodeList(); } -} \ No newline at end of file + + function getSlashThresholds() override(ISlashIndicator) external view returns (uint256, uint256) { + return (misdemeanorThreshold, felonyThreshold); + } +} diff --git a/contracts/Staking.sol b/contracts/Staking.sol new file mode 100644 index 00000000..23366221 --- /dev/null +++ b/contracts/Staking.sol @@ -0,0 +1,682 @@ +pragma solidity 0.6.4; + +import "./System.sol"; +import "./interface/IApplication.sol"; +import "./interface/ICrossChain.sol"; +import "./interface/IParamSubscriber.sol"; +import "./interface/IStaking.sol"; +import "./interface/ITokenHub.sol"; +import "./lib/BytesToTypes.sol"; +import "./lib/BytesLib.sol"; +import "./lib/CmnPkg.sol"; +import "./lib/Memory.sol"; +import "./lib/RLPEncode.sol"; +import "./lib/RLPDecode.sol"; +import "./lib/SafeMath.sol"; + + +contract Staking is IStaking, System, IParamSubscriber, IApplication { + using SafeMath for uint256; + using RLPEncode for *; + using RLPDecode for *; + + // Cross Stake Event type + uint8 public constant EVENT_DELEGATE = 0x01; + uint8 public constant EVENT_UNDELEGATE = 0x02; + uint8 public constant EVENT_REDELEGATE = 0x03; + uint8 public constant EVENT_DISTRIBUTE_REWARD = 0x04; + uint8 public constant EVENT_DISTRIBUTE_UNDELEGATED = 0x05; + + // ack package status code + uint8 public constant CODE_FAILED = 0; + uint8 public constant CODE_SUCCESS = 1; + + // Error code + uint32 public constant ERROR_WITHDRAW_BNB = 101; + + uint256 public constant TEN_DECIMALS = 1e10; + uint256 public constant LOCK_TIME = 8 days; // 8*24*3600 second + + uint256 public constant INIT_RELAYER_FEE = 16 * 1e15; + uint256 public constant INIT_BSC_RELAYER_FEE = 1 * 1e16; + uint256 public constant INIT_MIN_DELEGATION = 100 * 1e18; + uint256 public constant INIT_TRANSFER_GAS = 2300; + + uint256 public relayerFee; + uint256 public bSCRelayerFee; + uint256 public minDelegation; + + mapping(address => uint256) delegated; // delegator => totalAmount + mapping(address => mapping(address => uint256)) delegatedOfValidator; // delegator => validator => amount + mapping(address => uint256) distributedReward; // delegator => reward + mapping(address => mapping(address => uint256)) pendingUndelegateTime; // delegator => validator => minTime + mapping(address => uint256) undelegated; // delegator => totalUndelegated + mapping(address => mapping(address => mapping(address => uint256))) pendingRedelegateTime; // delegator => srcValidator => dstValidator => minTime + + mapping(uint256 => bytes32) packageQueue; // index => package's hash + mapping(address => uint256) delegateInFly; // delegator => delegate request in fly + mapping(address => uint256) undelegateInFly; // delegator => undelegate request in fly + mapping(address => uint256) redelegateInFly; // delegator => redelegate request in fly + + uint256 internal leftIndex; + uint256 internal rightIndex; + uint8 internal locked; + + uint256 public transferGas; // this param is newly added after the hardfork on testnet. It need to be initialed by governed + + modifier noReentrant() { + require(locked != 2, "No re-entrancy"); + locked = 2; + _; + locked = 1; + } + + modifier tenDecimalPrecision(uint256 amount) { + require(msg.value%TEN_DECIMALS==0 && amount%TEN_DECIMALS==0, "precision loss in conversion"); + _; + } + + modifier initParams() { + if (!alreadyInit) { + relayerFee = INIT_RELAYER_FEE; + bSCRelayerFee = INIT_BSC_RELAYER_FEE; + minDelegation = INIT_MIN_DELEGATION; + transferGas = INIT_TRANSFER_GAS; + alreadyInit = true; + } + _; + } + + /*********************************** Events **********************************/ + event delegateSubmitted(address indexed delegator, address indexed validator, uint256 amount, uint256 relayerFee); + event undelegateSubmitted(address indexed delegator, address indexed validator, uint256 amount, uint256 relayerFee); + event redelegateSubmitted(address indexed delegator, address indexed validatorSrc, address indexed validatorDst, uint256 amount, uint256 relayerFee); + event rewardReceived(address indexed delegator, uint256 amount); + event rewardClaimed(address indexed delegator, uint256 amount); + event undelegatedReceived(address indexed delegator, address indexed validator, uint256 amount); + event undelegatedClaimed(address indexed delegator, uint256 amount); + event delegateSuccess(address indexed delegator, address indexed validator, uint256 amount); + event undelegateSuccess(address indexed delegator, address indexed validator, uint256 amount); + event redelegateSuccess(address indexed delegator, address indexed valSrc, address indexed valDst, uint256 amount); + event delegateFailed(address indexed delegator, address indexed validator, uint256 amount, uint8 errCode); + event undelegateFailed(address indexed delegator, address indexed validator, uint256 amount, uint8 errCode); + event redelegateFailed(address indexed delegator, address indexed valSrc, address indexed valDst, uint256 amount, uint8 errCode); + event paramChange(string key, bytes value); + event failedSynPackage(uint8 indexed eventType, uint256 errCode); + event crashResponse(uint8 indexed eventType); + + receive() external payable {} + + /************************* Implement cross chain app *************************/ + function handleSynPackage(uint8, bytes calldata msgBytes) external onlyCrossChainContract initParams override returns(bytes memory) { + RLPDecode.Iterator memory iter = msgBytes.toRLPItem().iterator(); + uint8 eventType = uint8(iter.next().toUint()); + uint32 resCode; + bytes memory ackPackage; + if (eventType == EVENT_DISTRIBUTE_REWARD) { + (resCode, ackPackage) = _handleDistributeRewardSynPackage(iter); + } else if (eventType == EVENT_DISTRIBUTE_UNDELEGATED) { + (resCode, ackPackage) = _handleDistributeUndelegatedSynPackage(iter); + } else { + revert("unknown event type"); + } + + if (resCode != CODE_OK) { + emit failedSynPackage(eventType, resCode); + } + return ackPackage; + } + + function handleAckPackage(uint8, bytes calldata msgBytes) external onlyCrossChainContract initParams override { + RLPDecode.Iterator memory iter = msgBytes.toRLPItem().iterator(); + + uint8 status; + uint8 errCode; + bytes memory packBytes; + bool success; + uint256 idx; + while (iter.hasNext()) { + if (idx == 0) { + status = uint8(iter.next().toUint()); + } else if (idx == 1) { + errCode = uint8(iter.next().toUint()); + } else if (idx == 2) { + packBytes = iter.next().toBytes(); + success = true; + } else { + break; + } + ++idx; + } + require(success, "rlp decode failed"); + + require(_checkPackHash(packBytes), "wrong pack hash"); + iter = packBytes.toRLPItem().iterator(); + uint8 eventType = uint8(iter.next().toUint()); + RLPDecode.Iterator memory paramIter; + if (iter.hasNext()) { + paramIter = iter.next().toBytes().toRLPItem().iterator(); + } else { + revert("empty ack package"); + } + if (eventType == EVENT_DELEGATE) { + _handleDelegateAckPackage(paramIter, status, errCode); + } else if (eventType == EVENT_UNDELEGATE) { + _handleUndelegateAckPackage(paramIter, status, errCode); + } else if (eventType == EVENT_REDELEGATE) { + _handleRedelegateAckPackage(paramIter, status, errCode); + } else { + revert("unknown event type"); + } + } + + function handleFailAckPackage(uint8, bytes calldata msgBytes) external onlyCrossChainContract initParams override { + require(_checkPackHash(msgBytes), "wrong pack hash"); + RLPDecode.Iterator memory iter = msgBytes.toRLPItem().iterator(); + uint8 eventType = uint8(iter.next().toUint()); + RLPDecode.Iterator memory paramIter; + if (iter.hasNext()) { + paramIter = iter.next().toBytes().toRLPItem().iterator(); + } else { + revert("empty fail ack package"); + } + if (eventType == EVENT_DELEGATE) { + _handleDelegateFailAckPackage(paramIter); + } else if (eventType == EVENT_UNDELEGATE) { + _handleUndelegateFailAckPackage(paramIter); + } else if (eventType == EVENT_REDELEGATE) { + _handleRedelegateFailAckPackage(paramIter); + } else { + revert("unknown event type"); + } + return; + } + + /***************************** External functions *****************************/ + function delegate(address validator, uint256 amount) override external payable noReentrant tenDecimalPrecision(amount) initParams { + require(amount >= minDelegation, "invalid delegate amount"); + require(msg.value >= amount.add(relayerFee), "not enough msg value"); + (bool success,) = msg.sender.call{gas: transferGas}(""); + require(success, "invalid delegator"); // the msg sender must be payable + + uint256 convertedAmount = amount.div(TEN_DECIMALS); // native bnb decimals is 8 on BBC, while the native bnb decimals on BSC is 18 + uint256 _relayerFee = (msg.value).sub(amount); + uint256 oracleRelayerFee = _relayerFee.sub(bSCRelayerFee); + + bytes[] memory elements = new bytes[](3); + elements[0] = msg.sender.encodeAddress(); + elements[1] = validator.encodeAddress(); + elements[2] = convertedAmount.encodeUint(); + bytes memory msgBytes = _RLPEncode(EVENT_DELEGATE, elements.encodeList()); + packageQueue[rightIndex] = keccak256(msgBytes); + ++rightIndex; + delegateInFly[msg.sender] += 1; + + ICrossChain(CROSS_CHAIN_CONTRACT_ADDR).sendSynPackage(CROSS_STAKE_CHANNELID, msgBytes, oracleRelayerFee.div(TEN_DECIMALS)); + payable(TOKEN_HUB_ADDR).transfer(amount.add(oracleRelayerFee)); + payable(SYSTEM_REWARD_ADDR).transfer(bSCRelayerFee); + + emit delegateSubmitted(msg.sender, validator, amount, oracleRelayerFee); + } + + function undelegate(address validator, uint256 amount) override external payable noReentrant tenDecimalPrecision(amount) initParams { + require(msg.value >= relayerFee, "not enough relay fee"); + if (amount < minDelegation) { + require(amount == delegatedOfValidator[msg.sender][validator], "invalid amount"); + require(amount > bSCRelayerFee, "not enough funds"); + } + require(block.timestamp >= pendingUndelegateTime[msg.sender][validator], "pending undelegation exist"); + uint256 remainBalance = delegatedOfValidator[msg.sender][validator].sub(amount, "not enough funds"); + if (remainBalance != 0) { + require(remainBalance > bSCRelayerFee, "insufficient balance after undelegate"); + } + + uint256 convertedAmount = amount.div(TEN_DECIMALS); // native bnb decimals is 8 on BBC, while the native bnb decimals on BSC is 18 + uint256 _relayerFee = msg.value; + uint256 oracleRelayerFee = _relayerFee.sub(bSCRelayerFee); + + bytes[] memory elements = new bytes[](3); + elements[0] = msg.sender.encodeAddress(); + elements[1] = validator.encodeAddress(); + elements[2] = convertedAmount.encodeUint(); + bytes memory msgBytes = _RLPEncode(EVENT_UNDELEGATE, elements.encodeList()); + packageQueue[rightIndex] = keccak256(msgBytes); + ++rightIndex; + undelegateInFly[msg.sender] += 1; + + pendingUndelegateTime[msg.sender][validator] = block.timestamp.add(LOCK_TIME); + + ICrossChain(CROSS_CHAIN_CONTRACT_ADDR).sendSynPackage(CROSS_STAKE_CHANNELID, msgBytes, oracleRelayerFee.div(TEN_DECIMALS)); + payable(TOKEN_HUB_ADDR).transfer(oracleRelayerFee); + payable(SYSTEM_REWARD_ADDR).transfer(bSCRelayerFee); + + emit undelegateSubmitted(msg.sender, validator, amount, oracleRelayerFee); + } + + function redelegate(address validatorSrc, address validatorDst, uint256 amount) override external noReentrant payable tenDecimalPrecision(amount) initParams { + require(validatorSrc != validatorDst, "invalid redelegation"); + require(msg.value >= relayerFee, "not enough relay fee"); + require(amount >= minDelegation, "invalid amount"); + require(block.timestamp >= pendingRedelegateTime[msg.sender][validatorSrc][validatorDst] && + block.timestamp >= pendingRedelegateTime[msg.sender][validatorDst][validatorSrc], "pending redelegation exist"); + uint256 remainBalance = delegatedOfValidator[msg.sender][validatorSrc].sub(amount, "not enough funds"); + if (remainBalance != 0) { + require(remainBalance > bSCRelayerFee, "insufficient balance after redelegate"); + } + + uint256 convertedAmount = amount.div(TEN_DECIMALS);// native bnb decimals is 8 on BBC, while the native bnb decimals on BSC is 18 + uint256 _relayerFee = msg.value; + uint256 oracleRelayerFee = _relayerFee.sub(bSCRelayerFee); + + bytes[] memory elements = new bytes[](4); + elements[0] = msg.sender.encodeAddress(); + elements[1] = validatorSrc.encodeAddress(); + elements[2] = validatorDst.encodeAddress(); + elements[3] = convertedAmount.encodeUint(); + bytes memory msgBytes = _RLPEncode(EVENT_REDELEGATE, elements.encodeList()); + packageQueue[rightIndex] = keccak256(msgBytes); + ++rightIndex; + redelegateInFly[msg.sender] += 1; + + pendingRedelegateTime[msg.sender][validatorDst][validatorSrc] = block.timestamp.add(LOCK_TIME); + pendingRedelegateTime[msg.sender][validatorSrc][validatorDst] = block.timestamp.add(LOCK_TIME); + + ICrossChain(CROSS_CHAIN_CONTRACT_ADDR).sendSynPackage(CROSS_STAKE_CHANNELID, msgBytes, oracleRelayerFee.div(TEN_DECIMALS)); + payable(TOKEN_HUB_ADDR).transfer(oracleRelayerFee); + payable(SYSTEM_REWARD_ADDR).transfer(bSCRelayerFee); + + emit redelegateSubmitted(msg.sender, validatorSrc, validatorDst, amount, oracleRelayerFee); + } + + function claimReward() override external noReentrant returns(uint256 amount) { + amount = distributedReward[msg.sender]; + require(amount > 0, "no pending reward"); + + distributedReward[msg.sender] = 0; + (bool success,) = msg.sender.call{gas: transferGas, value: amount}(""); + require(success, "transfer failed"); + emit rewardClaimed(msg.sender, amount); + } + + function claimUndelegated() override external noReentrant returns(uint256 amount) { + amount = undelegated[msg.sender]; + require(amount > 0, "no undelegated funds"); + + undelegated[msg.sender] = 0; + (bool success,) = msg.sender.call{gas: transferGas, value: amount}(""); + require(success, "transfer failed"); + emit undelegatedClaimed(msg.sender, amount); + } + + function getDelegated(address delegator, address validator) override external view returns(uint256) { + return delegatedOfValidator[delegator][validator]; + } + + function getTotalDelegated(address delegator) override external view returns(uint256) { + return delegated[delegator]; + } + + function getDistributedReward(address delegator) override external view returns(uint256) { + return distributedReward[delegator]; + } + + function getPendingRedelegateTime(address delegator, address valSrc, address valDst) override external view returns(uint256) { + return pendingRedelegateTime[delegator][valSrc][valDst]; + } + + function getUndelegated(address delegator) override external view returns(uint256) { + return undelegated[delegator]; + } + + function getPendingUndelegateTime(address delegator, address validator) override external view returns(uint256) { + return pendingUndelegateTime[delegator][validator]; + } + + function getRelayerFee() override external view returns(uint256) { + return relayerFee; + } + + function getMinDelegation() override external view returns(uint256) { + return minDelegation; + } + + function getRequestInFly(address delegator) override external view returns(uint256[3] memory) { + uint256[3] memory request; + request[0] = delegateInFly[delegator]; + request[1] = undelegateInFly[delegator]; + request[2] = redelegateInFly[delegator]; + return request; + } + + /***************************** Internal functions *****************************/ + function _RLPEncode(uint8 eventType, bytes memory msgBytes) internal pure returns(bytes memory output) { + bytes[] memory elements = new bytes[](2); + elements[0] = eventType.encodeUint(); + elements[1] = msgBytes.encodeBytes(); + output = elements.encodeList(); + } + + function _encodeRefundPackage(uint8 eventType, address recipient, uint256 amount, uint32 errorCode) internal pure returns(uint32, bytes memory) { + amount = amount.div(TEN_DECIMALS); + bytes[] memory elements = new bytes[](4); + elements[0] = eventType.encodeUint(); + elements[1] = recipient.encodeAddress(); + elements[2] = amount.encodeUint(); + elements[3] = errorCode.encodeUint(); + bytes memory packageBytes = elements.encodeList(); + return (errorCode, packageBytes); + } + + function _checkPackHash(bytes memory packBytes) internal returns(bool){ + bytes32 revHash = keccak256(packBytes); + bytes32 expHash = packageQueue[leftIndex]; + if (revHash != expHash) { + return false; + } + delete packageQueue[leftIndex]; + ++leftIndex; + return true; + } + + /******************************** Param update ********************************/ + function updateParam(string calldata key, bytes calldata value) override external onlyInit onlyGov { + if (Memory.compareStrings(key, "relayerFee")) { + require(value.length == 32, "length of relayerFee mismatch"); + uint256 newRelayerFee = BytesToTypes.bytesToUint256(32, value); + require(newRelayerFee < minDelegation, "the relayerFee must be less than minDelegation"); + require(newRelayerFee > bSCRelayerFee, "the relayerFee must be more than BSCRelayerFee"); + require(newRelayerFee%TEN_DECIMALS==0, "the relayerFee mod ten decimals must be zero"); + relayerFee = newRelayerFee; + } else if (Memory.compareStrings(key, "bSCRelayerFee")) { + require(value.length == 32, "length of bSCRelayerFee mismatch"); + uint256 newBSCRelayerFee = BytesToTypes.bytesToUint256(32, value); + require(newBSCRelayerFee != 0, "the BSCRelayerFee must not be zero"); + require(newBSCRelayerFee < relayerFee, "the BSCRelayerFee must be less than relayerFee"); + require(newBSCRelayerFee%TEN_DECIMALS==0, "the BSCRelayerFee mod ten decimals must be zero"); + bSCRelayerFee = newBSCRelayerFee; + } else if (Memory.compareStrings(key, "minDelegation")) { + require(value.length == 32, "length of minDelegation mismatch"); + uint256 newMinDelegation = BytesToTypes.bytesToUint256(32, value); + require(newMinDelegation > relayerFee, "the minDelegation must be greater than relayerFee"); + minDelegation = newMinDelegation; + } else if (Memory.compareStrings(key, "transferGas")) { + require(value.length == 32, "length of transferGas mismatch"); + uint256 newTransferGas = BytesToTypes.bytesToUint256(32, value); + require(newTransferGas > 0, "the transferGas cannot be zero"); + transferGas = newTransferGas; + } else { + revert("unknown param"); + } + emit paramChange(key, value); + } + + /************************* Handle cross-chain package *************************/ + function _handleDelegateAckPackage(RLPDecode.Iterator memory paramIter, uint8 status, uint8 errCode) internal { + bool success; + uint256 idx; + address delegator; + address validator; + uint256 bcAmount; + while (paramIter.hasNext()) { + if (idx == 0) { + delegator = address(uint160(paramIter.next().toAddress())); + } else if (idx == 1) { + validator = address(uint160(paramIter.next().toAddress())); + } else if (idx == 2) { + bcAmount = uint256(paramIter.next().toUint()); + success = true; + } else { + break; + } + ++idx; + } + require(success, "rlp decode failed"); + + uint256 amount = bcAmount.mul(TEN_DECIMALS); + delegateInFly[delegator] -= 1; + if (status == CODE_SUCCESS) { + require(errCode == 0, "wrong status"); + delegated[delegator] = delegated[delegator].add(amount); + delegatedOfValidator[delegator][validator] = delegatedOfValidator[delegator][validator].add(amount); + + emit delegateSuccess(delegator, validator, amount); + } else if (status == CODE_FAILED) { + undelegated[delegator] = undelegated[delegator].add(amount); + require(ITokenHub(TOKEN_HUB_ADDR).withdrawStakingBNB(amount), "withdraw bnb failed"); + + emit delegateFailed(delegator, validator, amount, errCode); + } else { + revert("wrong status"); + } + } + + function _handleDelegateFailAckPackage(RLPDecode.Iterator memory paramIter) internal { + bool success; + uint256 idx; + address delegator; + address validator; + uint256 bcAmount; + while (paramIter.hasNext()) { + if (idx == 0) { + delegator = address(uint160(paramIter.next().toAddress())); + } else if (idx == 1) { + validator = address(uint160(paramIter.next().toAddress())); + } else if (idx == 2) { + bcAmount = uint256(paramIter.next().toUint()); + success = true; + } else { + break; + } + ++idx; + } + require(success, "rlp decode failed"); + + uint256 amount = bcAmount.mul(TEN_DECIMALS); + delegateInFly[delegator] -= 1; + undelegated[delegator] = undelegated[delegator].add(amount); + require(ITokenHub(TOKEN_HUB_ADDR).withdrawStakingBNB(amount), "withdraw bnb failed"); + + emit crashResponse(EVENT_DELEGATE); + } + + function _handleUndelegateAckPackage(RLPDecode.Iterator memory paramIter, uint8 status, uint8 errCode) internal { + bool success; + uint256 idx; + address delegator; + address validator; + uint256 bcAmount; + while (paramIter.hasNext()) { + if (idx == 0) { + delegator = address(uint160(paramIter.next().toAddress())); + } else if (idx == 1) { + validator = address(uint160(paramIter.next().toAddress())); + } else if (idx == 2) { + bcAmount = uint256(paramIter.next().toUint()); + success = true; + } else { + break; + } + ++idx; + } + require(success, "rlp decode failed"); + + uint256 amount = bcAmount.mul(TEN_DECIMALS); + undelegateInFly[delegator] -= 1; + if (status == CODE_SUCCESS) { + require(errCode == 0, "wrong status"); + delegated[delegator] = delegated[delegator].sub(amount); + delegatedOfValidator[delegator][validator] = delegatedOfValidator[delegator][validator].sub(amount); + pendingUndelegateTime[delegator][validator] = block.timestamp.add(LOCK_TIME); + + emit undelegateSuccess(delegator, validator, amount); + } else if (status == CODE_FAILED) { + pendingUndelegateTime[delegator][validator] = 0; + emit undelegateFailed(delegator, validator, amount, errCode); + } else { + revert("wrong status"); + } + } + + function _handleUndelegateFailAckPackage(RLPDecode.Iterator memory paramIter) internal { + bool success; + uint256 idx; + address delegator; + address validator; + uint256 bcAmount; + while (paramIter.hasNext()) { + if (idx == 0) { + delegator = address(uint160(paramIter.next().toAddress())); + } else if (idx == 1) { + validator = address(uint160(paramIter.next().toAddress())); + } else if (idx == 2) { + bcAmount = uint256(paramIter.next().toUint()); + success = true; + } else { + break; + } + ++idx; + } + require(success, "rlp decode failed"); + + undelegateInFly[delegator] -= 1; + pendingUndelegateTime[delegator][validator] = 0; + + emit crashResponse(EVENT_UNDELEGATE); + } + + function _handleRedelegateAckPackage(RLPDecode.Iterator memory paramIter, uint8 status, uint8 errCode) internal { + bool success; + uint256 idx; + address delegator; + address valSrc; + address valDst; + uint256 bcAmount; + while (paramIter.hasNext()) { + if (idx == 0) { + delegator = address(uint160(paramIter.next().toAddress())); + } else if (idx == 1) { + valSrc = address(uint160(paramIter.next().toAddress())); + } else if (idx == 2) { + valDst = address(uint160(paramIter.next().toAddress())); + } else if (idx == 3) { + bcAmount = uint256(paramIter.next().toUint()); + success = true; + } else { + break; + } + ++idx; + } + require(success, "rlp decode failed"); + + uint256 amount = bcAmount.mul(TEN_DECIMALS); + redelegateInFly[delegator] -= 1; + if (status == CODE_SUCCESS) { + require(errCode == 0, "wrong status"); + delegatedOfValidator[delegator][valSrc] = delegatedOfValidator[delegator][valSrc].sub(amount); + delegatedOfValidator[delegator][valDst] = delegatedOfValidator[delegator][valDst].add(amount); + pendingRedelegateTime[delegator][valSrc][valDst] = block.timestamp.add(LOCK_TIME); + pendingRedelegateTime[delegator][valDst][valSrc] = block.timestamp.add(LOCK_TIME); + + emit redelegateSuccess(delegator, valSrc, valDst, amount); + } else if (status == CODE_FAILED) { + pendingRedelegateTime[delegator][valSrc][valDst] = 0; + pendingRedelegateTime[delegator][valDst][valSrc] = 0; + emit redelegateFailed(delegator, valSrc, valDst, amount, errCode); + } else { + revert("wrong status"); + } + } + + function _handleRedelegateFailAckPackage(RLPDecode.Iterator memory paramIter) internal { + bool success; + uint256 idx; + address delegator; + address valSrc; + address valDst; + uint256 bcAmount; + while (paramIter.hasNext()) { + if (idx == 0) { + delegator = address(uint160(paramIter.next().toAddress())); + } else if (idx == 1) { + valSrc = address(uint160(paramIter.next().toAddress())); + } else if (idx == 2) { + valDst = address(uint160(paramIter.next().toAddress())); + } else if (idx == 3) { + bcAmount = uint256(paramIter.next().toUint()); + success = true; + } else { + break; + } + ++idx; + } + require(success, "rlp decode failed"); + + redelegateInFly[delegator] -= 1; + pendingRedelegateTime[delegator][valSrc][valDst] = 0; + pendingRedelegateTime[delegator][valDst][valSrc] = 0; + + emit crashResponse(EVENT_REDELEGATE); + } + + function _handleDistributeRewardSynPackage(RLPDecode.Iterator memory iter) internal returns(uint32, bytes memory) { + bool success; + uint256 idx; + address recipient; + uint256 amount; + while (iter.hasNext()) { + if (idx == 0) { + recipient = address(uint160(iter.next().toAddress())); + } else if (idx == 1) { + amount = uint256(iter.next().toUint()); + success = true; + } else { + break; + } + ++idx; + } + require(success, "rlp decode failed"); + + bool ok = ITokenHub(TOKEN_HUB_ADDR).withdrawStakingBNB(amount); + if (!ok) { + return _encodeRefundPackage(EVENT_DISTRIBUTE_REWARD, recipient, amount, ERROR_WITHDRAW_BNB); + } + + distributedReward[recipient] = distributedReward[recipient].add(amount); + + emit rewardReceived(recipient, amount); + return (CODE_OK, new bytes(0)); + } + + function _handleDistributeUndelegatedSynPackage(RLPDecode.Iterator memory iter) internal returns(uint32, bytes memory) { + bool success; + uint256 idx; + address recipient; + address validator; + uint256 amount; + while (iter.hasNext()) { + if (idx == 0) { + recipient = address(uint160(iter.next().toAddress())); + } else if (idx == 1) { + validator = address(uint160(iter.next().toAddress())); + } else if (idx == 2) { + amount = uint256(iter.next().toUint()); + success = true; + } else { + break; + } + ++idx; + } + require(success, "rlp decode failed"); + + bool ok = ITokenHub(TOKEN_HUB_ADDR).withdrawStakingBNB(amount); + if (!ok) { + return _encodeRefundPackage(EVENT_DISTRIBUTE_UNDELEGATED, recipient, amount, ERROR_WITHDRAW_BNB); + } + + pendingUndelegateTime[recipient][validator] = 0; + undelegated[recipient] = undelegated[recipient].add(amount); + + emit undelegatedReceived(recipient, validator, amount); + return (CODE_OK, new bytes(0)); + } +} diff --git a/contracts/Staking.template b/contracts/Staking.template new file mode 100644 index 00000000..23366221 --- /dev/null +++ b/contracts/Staking.template @@ -0,0 +1,682 @@ +pragma solidity 0.6.4; + +import "./System.sol"; +import "./interface/IApplication.sol"; +import "./interface/ICrossChain.sol"; +import "./interface/IParamSubscriber.sol"; +import "./interface/IStaking.sol"; +import "./interface/ITokenHub.sol"; +import "./lib/BytesToTypes.sol"; +import "./lib/BytesLib.sol"; +import "./lib/CmnPkg.sol"; +import "./lib/Memory.sol"; +import "./lib/RLPEncode.sol"; +import "./lib/RLPDecode.sol"; +import "./lib/SafeMath.sol"; + + +contract Staking is IStaking, System, IParamSubscriber, IApplication { + using SafeMath for uint256; + using RLPEncode for *; + using RLPDecode for *; + + // Cross Stake Event type + uint8 public constant EVENT_DELEGATE = 0x01; + uint8 public constant EVENT_UNDELEGATE = 0x02; + uint8 public constant EVENT_REDELEGATE = 0x03; + uint8 public constant EVENT_DISTRIBUTE_REWARD = 0x04; + uint8 public constant EVENT_DISTRIBUTE_UNDELEGATED = 0x05; + + // ack package status code + uint8 public constant CODE_FAILED = 0; + uint8 public constant CODE_SUCCESS = 1; + + // Error code + uint32 public constant ERROR_WITHDRAW_BNB = 101; + + uint256 public constant TEN_DECIMALS = 1e10; + uint256 public constant LOCK_TIME = 8 days; // 8*24*3600 second + + uint256 public constant INIT_RELAYER_FEE = 16 * 1e15; + uint256 public constant INIT_BSC_RELAYER_FEE = 1 * 1e16; + uint256 public constant INIT_MIN_DELEGATION = 100 * 1e18; + uint256 public constant INIT_TRANSFER_GAS = 2300; + + uint256 public relayerFee; + uint256 public bSCRelayerFee; + uint256 public minDelegation; + + mapping(address => uint256) delegated; // delegator => totalAmount + mapping(address => mapping(address => uint256)) delegatedOfValidator; // delegator => validator => amount + mapping(address => uint256) distributedReward; // delegator => reward + mapping(address => mapping(address => uint256)) pendingUndelegateTime; // delegator => validator => minTime + mapping(address => uint256) undelegated; // delegator => totalUndelegated + mapping(address => mapping(address => mapping(address => uint256))) pendingRedelegateTime; // delegator => srcValidator => dstValidator => minTime + + mapping(uint256 => bytes32) packageQueue; // index => package's hash + mapping(address => uint256) delegateInFly; // delegator => delegate request in fly + mapping(address => uint256) undelegateInFly; // delegator => undelegate request in fly + mapping(address => uint256) redelegateInFly; // delegator => redelegate request in fly + + uint256 internal leftIndex; + uint256 internal rightIndex; + uint8 internal locked; + + uint256 public transferGas; // this param is newly added after the hardfork on testnet. It need to be initialed by governed + + modifier noReentrant() { + require(locked != 2, "No re-entrancy"); + locked = 2; + _; + locked = 1; + } + + modifier tenDecimalPrecision(uint256 amount) { + require(msg.value%TEN_DECIMALS==0 && amount%TEN_DECIMALS==0, "precision loss in conversion"); + _; + } + + modifier initParams() { + if (!alreadyInit) { + relayerFee = INIT_RELAYER_FEE; + bSCRelayerFee = INIT_BSC_RELAYER_FEE; + minDelegation = INIT_MIN_DELEGATION; + transferGas = INIT_TRANSFER_GAS; + alreadyInit = true; + } + _; + } + + /*********************************** Events **********************************/ + event delegateSubmitted(address indexed delegator, address indexed validator, uint256 amount, uint256 relayerFee); + event undelegateSubmitted(address indexed delegator, address indexed validator, uint256 amount, uint256 relayerFee); + event redelegateSubmitted(address indexed delegator, address indexed validatorSrc, address indexed validatorDst, uint256 amount, uint256 relayerFee); + event rewardReceived(address indexed delegator, uint256 amount); + event rewardClaimed(address indexed delegator, uint256 amount); + event undelegatedReceived(address indexed delegator, address indexed validator, uint256 amount); + event undelegatedClaimed(address indexed delegator, uint256 amount); + event delegateSuccess(address indexed delegator, address indexed validator, uint256 amount); + event undelegateSuccess(address indexed delegator, address indexed validator, uint256 amount); + event redelegateSuccess(address indexed delegator, address indexed valSrc, address indexed valDst, uint256 amount); + event delegateFailed(address indexed delegator, address indexed validator, uint256 amount, uint8 errCode); + event undelegateFailed(address indexed delegator, address indexed validator, uint256 amount, uint8 errCode); + event redelegateFailed(address indexed delegator, address indexed valSrc, address indexed valDst, uint256 amount, uint8 errCode); + event paramChange(string key, bytes value); + event failedSynPackage(uint8 indexed eventType, uint256 errCode); + event crashResponse(uint8 indexed eventType); + + receive() external payable {} + + /************************* Implement cross chain app *************************/ + function handleSynPackage(uint8, bytes calldata msgBytes) external onlyCrossChainContract initParams override returns(bytes memory) { + RLPDecode.Iterator memory iter = msgBytes.toRLPItem().iterator(); + uint8 eventType = uint8(iter.next().toUint()); + uint32 resCode; + bytes memory ackPackage; + if (eventType == EVENT_DISTRIBUTE_REWARD) { + (resCode, ackPackage) = _handleDistributeRewardSynPackage(iter); + } else if (eventType == EVENT_DISTRIBUTE_UNDELEGATED) { + (resCode, ackPackage) = _handleDistributeUndelegatedSynPackage(iter); + } else { + revert("unknown event type"); + } + + if (resCode != CODE_OK) { + emit failedSynPackage(eventType, resCode); + } + return ackPackage; + } + + function handleAckPackage(uint8, bytes calldata msgBytes) external onlyCrossChainContract initParams override { + RLPDecode.Iterator memory iter = msgBytes.toRLPItem().iterator(); + + uint8 status; + uint8 errCode; + bytes memory packBytes; + bool success; + uint256 idx; + while (iter.hasNext()) { + if (idx == 0) { + status = uint8(iter.next().toUint()); + } else if (idx == 1) { + errCode = uint8(iter.next().toUint()); + } else if (idx == 2) { + packBytes = iter.next().toBytes(); + success = true; + } else { + break; + } + ++idx; + } + require(success, "rlp decode failed"); + + require(_checkPackHash(packBytes), "wrong pack hash"); + iter = packBytes.toRLPItem().iterator(); + uint8 eventType = uint8(iter.next().toUint()); + RLPDecode.Iterator memory paramIter; + if (iter.hasNext()) { + paramIter = iter.next().toBytes().toRLPItem().iterator(); + } else { + revert("empty ack package"); + } + if (eventType == EVENT_DELEGATE) { + _handleDelegateAckPackage(paramIter, status, errCode); + } else if (eventType == EVENT_UNDELEGATE) { + _handleUndelegateAckPackage(paramIter, status, errCode); + } else if (eventType == EVENT_REDELEGATE) { + _handleRedelegateAckPackage(paramIter, status, errCode); + } else { + revert("unknown event type"); + } + } + + function handleFailAckPackage(uint8, bytes calldata msgBytes) external onlyCrossChainContract initParams override { + require(_checkPackHash(msgBytes), "wrong pack hash"); + RLPDecode.Iterator memory iter = msgBytes.toRLPItem().iterator(); + uint8 eventType = uint8(iter.next().toUint()); + RLPDecode.Iterator memory paramIter; + if (iter.hasNext()) { + paramIter = iter.next().toBytes().toRLPItem().iterator(); + } else { + revert("empty fail ack package"); + } + if (eventType == EVENT_DELEGATE) { + _handleDelegateFailAckPackage(paramIter); + } else if (eventType == EVENT_UNDELEGATE) { + _handleUndelegateFailAckPackage(paramIter); + } else if (eventType == EVENT_REDELEGATE) { + _handleRedelegateFailAckPackage(paramIter); + } else { + revert("unknown event type"); + } + return; + } + + /***************************** External functions *****************************/ + function delegate(address validator, uint256 amount) override external payable noReentrant tenDecimalPrecision(amount) initParams { + require(amount >= minDelegation, "invalid delegate amount"); + require(msg.value >= amount.add(relayerFee), "not enough msg value"); + (bool success,) = msg.sender.call{gas: transferGas}(""); + require(success, "invalid delegator"); // the msg sender must be payable + + uint256 convertedAmount = amount.div(TEN_DECIMALS); // native bnb decimals is 8 on BBC, while the native bnb decimals on BSC is 18 + uint256 _relayerFee = (msg.value).sub(amount); + uint256 oracleRelayerFee = _relayerFee.sub(bSCRelayerFee); + + bytes[] memory elements = new bytes[](3); + elements[0] = msg.sender.encodeAddress(); + elements[1] = validator.encodeAddress(); + elements[2] = convertedAmount.encodeUint(); + bytes memory msgBytes = _RLPEncode(EVENT_DELEGATE, elements.encodeList()); + packageQueue[rightIndex] = keccak256(msgBytes); + ++rightIndex; + delegateInFly[msg.sender] += 1; + + ICrossChain(CROSS_CHAIN_CONTRACT_ADDR).sendSynPackage(CROSS_STAKE_CHANNELID, msgBytes, oracleRelayerFee.div(TEN_DECIMALS)); + payable(TOKEN_HUB_ADDR).transfer(amount.add(oracleRelayerFee)); + payable(SYSTEM_REWARD_ADDR).transfer(bSCRelayerFee); + + emit delegateSubmitted(msg.sender, validator, amount, oracleRelayerFee); + } + + function undelegate(address validator, uint256 amount) override external payable noReentrant tenDecimalPrecision(amount) initParams { + require(msg.value >= relayerFee, "not enough relay fee"); + if (amount < minDelegation) { + require(amount == delegatedOfValidator[msg.sender][validator], "invalid amount"); + require(amount > bSCRelayerFee, "not enough funds"); + } + require(block.timestamp >= pendingUndelegateTime[msg.sender][validator], "pending undelegation exist"); + uint256 remainBalance = delegatedOfValidator[msg.sender][validator].sub(amount, "not enough funds"); + if (remainBalance != 0) { + require(remainBalance > bSCRelayerFee, "insufficient balance after undelegate"); + } + + uint256 convertedAmount = amount.div(TEN_DECIMALS); // native bnb decimals is 8 on BBC, while the native bnb decimals on BSC is 18 + uint256 _relayerFee = msg.value; + uint256 oracleRelayerFee = _relayerFee.sub(bSCRelayerFee); + + bytes[] memory elements = new bytes[](3); + elements[0] = msg.sender.encodeAddress(); + elements[1] = validator.encodeAddress(); + elements[2] = convertedAmount.encodeUint(); + bytes memory msgBytes = _RLPEncode(EVENT_UNDELEGATE, elements.encodeList()); + packageQueue[rightIndex] = keccak256(msgBytes); + ++rightIndex; + undelegateInFly[msg.sender] += 1; + + pendingUndelegateTime[msg.sender][validator] = block.timestamp.add(LOCK_TIME); + + ICrossChain(CROSS_CHAIN_CONTRACT_ADDR).sendSynPackage(CROSS_STAKE_CHANNELID, msgBytes, oracleRelayerFee.div(TEN_DECIMALS)); + payable(TOKEN_HUB_ADDR).transfer(oracleRelayerFee); + payable(SYSTEM_REWARD_ADDR).transfer(bSCRelayerFee); + + emit undelegateSubmitted(msg.sender, validator, amount, oracleRelayerFee); + } + + function redelegate(address validatorSrc, address validatorDst, uint256 amount) override external noReentrant payable tenDecimalPrecision(amount) initParams { + require(validatorSrc != validatorDst, "invalid redelegation"); + require(msg.value >= relayerFee, "not enough relay fee"); + require(amount >= minDelegation, "invalid amount"); + require(block.timestamp >= pendingRedelegateTime[msg.sender][validatorSrc][validatorDst] && + block.timestamp >= pendingRedelegateTime[msg.sender][validatorDst][validatorSrc], "pending redelegation exist"); + uint256 remainBalance = delegatedOfValidator[msg.sender][validatorSrc].sub(amount, "not enough funds"); + if (remainBalance != 0) { + require(remainBalance > bSCRelayerFee, "insufficient balance after redelegate"); + } + + uint256 convertedAmount = amount.div(TEN_DECIMALS);// native bnb decimals is 8 on BBC, while the native bnb decimals on BSC is 18 + uint256 _relayerFee = msg.value; + uint256 oracleRelayerFee = _relayerFee.sub(bSCRelayerFee); + + bytes[] memory elements = new bytes[](4); + elements[0] = msg.sender.encodeAddress(); + elements[1] = validatorSrc.encodeAddress(); + elements[2] = validatorDst.encodeAddress(); + elements[3] = convertedAmount.encodeUint(); + bytes memory msgBytes = _RLPEncode(EVENT_REDELEGATE, elements.encodeList()); + packageQueue[rightIndex] = keccak256(msgBytes); + ++rightIndex; + redelegateInFly[msg.sender] += 1; + + pendingRedelegateTime[msg.sender][validatorDst][validatorSrc] = block.timestamp.add(LOCK_TIME); + pendingRedelegateTime[msg.sender][validatorSrc][validatorDst] = block.timestamp.add(LOCK_TIME); + + ICrossChain(CROSS_CHAIN_CONTRACT_ADDR).sendSynPackage(CROSS_STAKE_CHANNELID, msgBytes, oracleRelayerFee.div(TEN_DECIMALS)); + payable(TOKEN_HUB_ADDR).transfer(oracleRelayerFee); + payable(SYSTEM_REWARD_ADDR).transfer(bSCRelayerFee); + + emit redelegateSubmitted(msg.sender, validatorSrc, validatorDst, amount, oracleRelayerFee); + } + + function claimReward() override external noReentrant returns(uint256 amount) { + amount = distributedReward[msg.sender]; + require(amount > 0, "no pending reward"); + + distributedReward[msg.sender] = 0; + (bool success,) = msg.sender.call{gas: transferGas, value: amount}(""); + require(success, "transfer failed"); + emit rewardClaimed(msg.sender, amount); + } + + function claimUndelegated() override external noReentrant returns(uint256 amount) { + amount = undelegated[msg.sender]; + require(amount > 0, "no undelegated funds"); + + undelegated[msg.sender] = 0; + (bool success,) = msg.sender.call{gas: transferGas, value: amount}(""); + require(success, "transfer failed"); + emit undelegatedClaimed(msg.sender, amount); + } + + function getDelegated(address delegator, address validator) override external view returns(uint256) { + return delegatedOfValidator[delegator][validator]; + } + + function getTotalDelegated(address delegator) override external view returns(uint256) { + return delegated[delegator]; + } + + function getDistributedReward(address delegator) override external view returns(uint256) { + return distributedReward[delegator]; + } + + function getPendingRedelegateTime(address delegator, address valSrc, address valDst) override external view returns(uint256) { + return pendingRedelegateTime[delegator][valSrc][valDst]; + } + + function getUndelegated(address delegator) override external view returns(uint256) { + return undelegated[delegator]; + } + + function getPendingUndelegateTime(address delegator, address validator) override external view returns(uint256) { + return pendingUndelegateTime[delegator][validator]; + } + + function getRelayerFee() override external view returns(uint256) { + return relayerFee; + } + + function getMinDelegation() override external view returns(uint256) { + return minDelegation; + } + + function getRequestInFly(address delegator) override external view returns(uint256[3] memory) { + uint256[3] memory request; + request[0] = delegateInFly[delegator]; + request[1] = undelegateInFly[delegator]; + request[2] = redelegateInFly[delegator]; + return request; + } + + /***************************** Internal functions *****************************/ + function _RLPEncode(uint8 eventType, bytes memory msgBytes) internal pure returns(bytes memory output) { + bytes[] memory elements = new bytes[](2); + elements[0] = eventType.encodeUint(); + elements[1] = msgBytes.encodeBytes(); + output = elements.encodeList(); + } + + function _encodeRefundPackage(uint8 eventType, address recipient, uint256 amount, uint32 errorCode) internal pure returns(uint32, bytes memory) { + amount = amount.div(TEN_DECIMALS); + bytes[] memory elements = new bytes[](4); + elements[0] = eventType.encodeUint(); + elements[1] = recipient.encodeAddress(); + elements[2] = amount.encodeUint(); + elements[3] = errorCode.encodeUint(); + bytes memory packageBytes = elements.encodeList(); + return (errorCode, packageBytes); + } + + function _checkPackHash(bytes memory packBytes) internal returns(bool){ + bytes32 revHash = keccak256(packBytes); + bytes32 expHash = packageQueue[leftIndex]; + if (revHash != expHash) { + return false; + } + delete packageQueue[leftIndex]; + ++leftIndex; + return true; + } + + /******************************** Param update ********************************/ + function updateParam(string calldata key, bytes calldata value) override external onlyInit onlyGov { + if (Memory.compareStrings(key, "relayerFee")) { + require(value.length == 32, "length of relayerFee mismatch"); + uint256 newRelayerFee = BytesToTypes.bytesToUint256(32, value); + require(newRelayerFee < minDelegation, "the relayerFee must be less than minDelegation"); + require(newRelayerFee > bSCRelayerFee, "the relayerFee must be more than BSCRelayerFee"); + require(newRelayerFee%TEN_DECIMALS==0, "the relayerFee mod ten decimals must be zero"); + relayerFee = newRelayerFee; + } else if (Memory.compareStrings(key, "bSCRelayerFee")) { + require(value.length == 32, "length of bSCRelayerFee mismatch"); + uint256 newBSCRelayerFee = BytesToTypes.bytesToUint256(32, value); + require(newBSCRelayerFee != 0, "the BSCRelayerFee must not be zero"); + require(newBSCRelayerFee < relayerFee, "the BSCRelayerFee must be less than relayerFee"); + require(newBSCRelayerFee%TEN_DECIMALS==0, "the BSCRelayerFee mod ten decimals must be zero"); + bSCRelayerFee = newBSCRelayerFee; + } else if (Memory.compareStrings(key, "minDelegation")) { + require(value.length == 32, "length of minDelegation mismatch"); + uint256 newMinDelegation = BytesToTypes.bytesToUint256(32, value); + require(newMinDelegation > relayerFee, "the minDelegation must be greater than relayerFee"); + minDelegation = newMinDelegation; + } else if (Memory.compareStrings(key, "transferGas")) { + require(value.length == 32, "length of transferGas mismatch"); + uint256 newTransferGas = BytesToTypes.bytesToUint256(32, value); + require(newTransferGas > 0, "the transferGas cannot be zero"); + transferGas = newTransferGas; + } else { + revert("unknown param"); + } + emit paramChange(key, value); + } + + /************************* Handle cross-chain package *************************/ + function _handleDelegateAckPackage(RLPDecode.Iterator memory paramIter, uint8 status, uint8 errCode) internal { + bool success; + uint256 idx; + address delegator; + address validator; + uint256 bcAmount; + while (paramIter.hasNext()) { + if (idx == 0) { + delegator = address(uint160(paramIter.next().toAddress())); + } else if (idx == 1) { + validator = address(uint160(paramIter.next().toAddress())); + } else if (idx == 2) { + bcAmount = uint256(paramIter.next().toUint()); + success = true; + } else { + break; + } + ++idx; + } + require(success, "rlp decode failed"); + + uint256 amount = bcAmount.mul(TEN_DECIMALS); + delegateInFly[delegator] -= 1; + if (status == CODE_SUCCESS) { + require(errCode == 0, "wrong status"); + delegated[delegator] = delegated[delegator].add(amount); + delegatedOfValidator[delegator][validator] = delegatedOfValidator[delegator][validator].add(amount); + + emit delegateSuccess(delegator, validator, amount); + } else if (status == CODE_FAILED) { + undelegated[delegator] = undelegated[delegator].add(amount); + require(ITokenHub(TOKEN_HUB_ADDR).withdrawStakingBNB(amount), "withdraw bnb failed"); + + emit delegateFailed(delegator, validator, amount, errCode); + } else { + revert("wrong status"); + } + } + + function _handleDelegateFailAckPackage(RLPDecode.Iterator memory paramIter) internal { + bool success; + uint256 idx; + address delegator; + address validator; + uint256 bcAmount; + while (paramIter.hasNext()) { + if (idx == 0) { + delegator = address(uint160(paramIter.next().toAddress())); + } else if (idx == 1) { + validator = address(uint160(paramIter.next().toAddress())); + } else if (idx == 2) { + bcAmount = uint256(paramIter.next().toUint()); + success = true; + } else { + break; + } + ++idx; + } + require(success, "rlp decode failed"); + + uint256 amount = bcAmount.mul(TEN_DECIMALS); + delegateInFly[delegator] -= 1; + undelegated[delegator] = undelegated[delegator].add(amount); + require(ITokenHub(TOKEN_HUB_ADDR).withdrawStakingBNB(amount), "withdraw bnb failed"); + + emit crashResponse(EVENT_DELEGATE); + } + + function _handleUndelegateAckPackage(RLPDecode.Iterator memory paramIter, uint8 status, uint8 errCode) internal { + bool success; + uint256 idx; + address delegator; + address validator; + uint256 bcAmount; + while (paramIter.hasNext()) { + if (idx == 0) { + delegator = address(uint160(paramIter.next().toAddress())); + } else if (idx == 1) { + validator = address(uint160(paramIter.next().toAddress())); + } else if (idx == 2) { + bcAmount = uint256(paramIter.next().toUint()); + success = true; + } else { + break; + } + ++idx; + } + require(success, "rlp decode failed"); + + uint256 amount = bcAmount.mul(TEN_DECIMALS); + undelegateInFly[delegator] -= 1; + if (status == CODE_SUCCESS) { + require(errCode == 0, "wrong status"); + delegated[delegator] = delegated[delegator].sub(amount); + delegatedOfValidator[delegator][validator] = delegatedOfValidator[delegator][validator].sub(amount); + pendingUndelegateTime[delegator][validator] = block.timestamp.add(LOCK_TIME); + + emit undelegateSuccess(delegator, validator, amount); + } else if (status == CODE_FAILED) { + pendingUndelegateTime[delegator][validator] = 0; + emit undelegateFailed(delegator, validator, amount, errCode); + } else { + revert("wrong status"); + } + } + + function _handleUndelegateFailAckPackage(RLPDecode.Iterator memory paramIter) internal { + bool success; + uint256 idx; + address delegator; + address validator; + uint256 bcAmount; + while (paramIter.hasNext()) { + if (idx == 0) { + delegator = address(uint160(paramIter.next().toAddress())); + } else if (idx == 1) { + validator = address(uint160(paramIter.next().toAddress())); + } else if (idx == 2) { + bcAmount = uint256(paramIter.next().toUint()); + success = true; + } else { + break; + } + ++idx; + } + require(success, "rlp decode failed"); + + undelegateInFly[delegator] -= 1; + pendingUndelegateTime[delegator][validator] = 0; + + emit crashResponse(EVENT_UNDELEGATE); + } + + function _handleRedelegateAckPackage(RLPDecode.Iterator memory paramIter, uint8 status, uint8 errCode) internal { + bool success; + uint256 idx; + address delegator; + address valSrc; + address valDst; + uint256 bcAmount; + while (paramIter.hasNext()) { + if (idx == 0) { + delegator = address(uint160(paramIter.next().toAddress())); + } else if (idx == 1) { + valSrc = address(uint160(paramIter.next().toAddress())); + } else if (idx == 2) { + valDst = address(uint160(paramIter.next().toAddress())); + } else if (idx == 3) { + bcAmount = uint256(paramIter.next().toUint()); + success = true; + } else { + break; + } + ++idx; + } + require(success, "rlp decode failed"); + + uint256 amount = bcAmount.mul(TEN_DECIMALS); + redelegateInFly[delegator] -= 1; + if (status == CODE_SUCCESS) { + require(errCode == 0, "wrong status"); + delegatedOfValidator[delegator][valSrc] = delegatedOfValidator[delegator][valSrc].sub(amount); + delegatedOfValidator[delegator][valDst] = delegatedOfValidator[delegator][valDst].add(amount); + pendingRedelegateTime[delegator][valSrc][valDst] = block.timestamp.add(LOCK_TIME); + pendingRedelegateTime[delegator][valDst][valSrc] = block.timestamp.add(LOCK_TIME); + + emit redelegateSuccess(delegator, valSrc, valDst, amount); + } else if (status == CODE_FAILED) { + pendingRedelegateTime[delegator][valSrc][valDst] = 0; + pendingRedelegateTime[delegator][valDst][valSrc] = 0; + emit redelegateFailed(delegator, valSrc, valDst, amount, errCode); + } else { + revert("wrong status"); + } + } + + function _handleRedelegateFailAckPackage(RLPDecode.Iterator memory paramIter) internal { + bool success; + uint256 idx; + address delegator; + address valSrc; + address valDst; + uint256 bcAmount; + while (paramIter.hasNext()) { + if (idx == 0) { + delegator = address(uint160(paramIter.next().toAddress())); + } else if (idx == 1) { + valSrc = address(uint160(paramIter.next().toAddress())); + } else if (idx == 2) { + valDst = address(uint160(paramIter.next().toAddress())); + } else if (idx == 3) { + bcAmount = uint256(paramIter.next().toUint()); + success = true; + } else { + break; + } + ++idx; + } + require(success, "rlp decode failed"); + + redelegateInFly[delegator] -= 1; + pendingRedelegateTime[delegator][valSrc][valDst] = 0; + pendingRedelegateTime[delegator][valDst][valSrc] = 0; + + emit crashResponse(EVENT_REDELEGATE); + } + + function _handleDistributeRewardSynPackage(RLPDecode.Iterator memory iter) internal returns(uint32, bytes memory) { + bool success; + uint256 idx; + address recipient; + uint256 amount; + while (iter.hasNext()) { + if (idx == 0) { + recipient = address(uint160(iter.next().toAddress())); + } else if (idx == 1) { + amount = uint256(iter.next().toUint()); + success = true; + } else { + break; + } + ++idx; + } + require(success, "rlp decode failed"); + + bool ok = ITokenHub(TOKEN_HUB_ADDR).withdrawStakingBNB(amount); + if (!ok) { + return _encodeRefundPackage(EVENT_DISTRIBUTE_REWARD, recipient, amount, ERROR_WITHDRAW_BNB); + } + + distributedReward[recipient] = distributedReward[recipient].add(amount); + + emit rewardReceived(recipient, amount); + return (CODE_OK, new bytes(0)); + } + + function _handleDistributeUndelegatedSynPackage(RLPDecode.Iterator memory iter) internal returns(uint32, bytes memory) { + bool success; + uint256 idx; + address recipient; + address validator; + uint256 amount; + while (iter.hasNext()) { + if (idx == 0) { + recipient = address(uint160(iter.next().toAddress())); + } else if (idx == 1) { + validator = address(uint160(iter.next().toAddress())); + } else if (idx == 2) { + amount = uint256(iter.next().toUint()); + success = true; + } else { + break; + } + ++idx; + } + require(success, "rlp decode failed"); + + bool ok = ITokenHub(TOKEN_HUB_ADDR).withdrawStakingBNB(amount); + if (!ok) { + return _encodeRefundPackage(EVENT_DISTRIBUTE_UNDELEGATED, recipient, amount, ERROR_WITHDRAW_BNB); + } + + pendingUndelegateTime[recipient][validator] = 0; + undelegated[recipient] = undelegated[recipient].add(amount); + + emit undelegatedReceived(recipient, validator, amount); + return (CODE_OK, new bytes(0)); + } +} diff --git a/contracts/System.sol b/contracts/System.sol index 7d64ddc2..b86d845c 100644 --- a/contracts/System.sol +++ b/contracts/System.sol @@ -17,6 +17,7 @@ contract System { uint8 constant public STAKING_CHANNELID = 0x08; uint8 constant public GOV_CHANNELID = 0x09; uint8 constant public SLASH_CHANNELID = 0x0b; + uint8 constant public CROSS_STAKE_CHANNELID = 0x10; uint16 constant public bscChainID = 0x0060; address public constant VALIDATOR_CONTRACT_ADDR = 0x0000000000000000000000000000000000001000; @@ -29,7 +30,7 @@ contract System { address public constant GOV_HUB_ADDR = 0x0000000000000000000000000000000000001007; address public constant TOKEN_MANAGER_ADDR = 0x0000000000000000000000000000000000001008; address public constant CROSS_CHAIN_CONTRACT_ADDR = 0x0000000000000000000000000000000000002000; - + address public constant STAKING_CONTRACT_ADDR = 0x0000000000000000000000000000000000002001; modifier onlyCoinbase() { require(msg.sender == block.coinbase, "the message sender must be the block producer"); @@ -81,6 +82,13 @@ contract System { _; } + + modifier onlyWhitelabelRelayer() { + require(msg.sender == 0xb005741528b86F5952469d80A8614591E3c5B632 || msg.sender == 0x446AA6E0DC65690403dF3F127750da1322941F3e, "the msg sender is not a whitelabel relayer"); + _; + } + + modifier onlyTokenManager() { require(msg.sender == TOKEN_MANAGER_ADDR, "the msg sender must be tokenManager"); _; diff --git a/contracts/System.template b/contracts/System.template index 4ceba2da..359d8246 100644 --- a/contracts/System.template +++ b/contracts/System.template @@ -17,32 +17,9 @@ contract System { uint8 constant public STAKING_CHANNELID = 0x08; uint8 constant public GOV_CHANNELID = 0x09; uint8 constant public SLASH_CHANNELID = 0x0b; + uint8 constant public CROSS_STAKE_CHANNELID = 0x10; uint16 constant public bscChainID = 0x{{bscChainId}}; -{% if mock %} - address public VALIDATOR_CONTRACT_ADDR; - address public SLASH_CONTRACT_ADDR; - address public SYSTEM_REWARD_ADDR; - address public LIGHT_CLIENT_ADDR; - address public TOKEN_HUB_ADDR; - address public INCENTIVIZE_ADDR; - address public RELAYERHUB_CONTRACT_ADDR; - address public GOV_HUB_ADDR; - address public TOKEN_MANAGER_ADDR; - address public CROSS_CHAIN_CONTRACT_ADDR; - - function updateContractAddr(address valAddr, address slashAddr, address rewardAddr, address lightAddr, address tokenHubAddr, - address incentivizeAddr, address relayerHubAddr, address govHub, address tokenManagerAddr, address crossChain) external { - VALIDATOR_CONTRACT_ADDR = valAddr; - SLASH_CONTRACT_ADDR = slashAddr; - SYSTEM_REWARD_ADDR = rewardAddr; - LIGHT_CLIENT_ADDR = lightAddr; - TOKEN_HUB_ADDR = tokenHubAddr; - INCENTIVIZE_ADDR = incentivizeAddr; - RELAYERHUB_CONTRACT_ADDR = relayerHubAddr; - GOV_HUB_ADDR = govHub; - TOKEN_MANAGER_ADDR = tokenManagerAddr; - CROSS_CHAIN_CONTRACT_ADDR = crossChain; - }{% else %} + address public constant VALIDATOR_CONTRACT_ADDR = 0x0000000000000000000000000000000000001000; address public constant SLASH_CONTRACT_ADDR = 0x0000000000000000000000000000000000001001; address public constant SYSTEM_REWARD_ADDR = 0x0000000000000000000000000000000000001002; @@ -53,20 +30,13 @@ contract System { address public constant GOV_HUB_ADDR = 0x0000000000000000000000000000000000001007; address public constant TOKEN_MANAGER_ADDR = 0x0000000000000000000000000000000000001008; address public constant CROSS_CHAIN_CONTRACT_ADDR = 0x0000000000000000000000000000000000002000; -{% endif %} -{% if mock %} - address public constant SYSTEM_ADDRESS = 0x9fB29AAc15b9A4B7F17c3385939b007540f4d791; + address public constant STAKING_CONTRACT_ADDR = 0x0000000000000000000000000000000000002001; - modifier onlyCoinbase() { - require(msg.sender == SYSTEM_ADDRESS, "the message sender must be the block producer"); - _; - } -{% else %} modifier onlyCoinbase() { require(msg.sender == block.coinbase, "the message sender must be the block producer"); _; } -{% endif %} + modifier onlyNotInit() { require(!alreadyInit, "the contract already init"); _; @@ -112,6 +82,28 @@ contract System { _; } + {% if network == 'local' %} + modifier onlyWhitelabelRelayer() { + require(msg.sender == 0xA904540818AC9c47f2321F97F1069B9d8746c6DB || msg.sender == 0x316b2Fa7C8a2ab7E21110a4B3f58771C01A71344, "the msg sender is not a whitelabel relayer"); + _; + } + {% elif network == 'QA' %} + modifier onlyWhitelabelRelayer() { + require(msg.sender == 0x88cb4D8F77742c24d647BEf8049D3f3C56067cDD || msg.sender == 0x42D596440775C90db8d9187b47650986E1063493, "the msg sender is not a whitelabel relayer"); + _; + } + {% elif network == 'testnet' %} + modifier onlyWhitelabelRelayer() { + require(msg.sender == 0x9fB29AAc15b9A4B7F17c3385939b007540f4d791 || msg.sender == 0x37B8516a0F88E65D677229b402ec6C1e0E333004, "the msg sender is not a whitelabel relayer"); + _; + } + {% else %} + modifier onlyWhitelabelRelayer() { + require(msg.sender == 0xb005741528b86F5952469d80A8614591E3c5B632 || msg.sender == 0x446AA6E0DC65690403dF3F127750da1322941F3e, "the msg sender is not a whitelabel relayer"); + _; + } + {% endif %} + modifier onlyTokenManager() { require(msg.sender == TOKEN_MANAGER_ADDR, "the msg sender must be tokenManager"); _; diff --git a/contracts/SystemReward.sol b/contracts/SystemReward.sol index ffaa2a60..34c1f406 100644 --- a/contracts/SystemReward.sol +++ b/contracts/SystemReward.sol @@ -1,14 +1,16 @@ pragma solidity 0.6.4; + import "./System.sol"; +import "./lib/Memory.sol"; +import "./interface/IParamSubscriber.sol"; import "./interface/ISystemReward.sol"; -contract SystemReward is System, ISystemReward{ +contract SystemReward is System, IParamSubscriber, ISystemReward { uint256 public constant MAX_REWARDS = 1e18; uint public numOperator; mapping(address => bool) operators; - modifier doInit() { if (!alreadyInit) { operators[LIGHT_CLIENT_ADDR] = true; @@ -19,16 +21,16 @@ contract SystemReward is System, ISystemReward{ _; } - modifier onlyOperator() { require(operators[msg.sender],"only operator is allowed to call the method"); _; } - + event rewardTo(address indexed to, uint256 amount); event rewardEmpty(); event receiveDeposit(address indexed from, uint256 amount); - + event updateOperator(address indexed operator); + event paramChange(string key, bytes value); receive() external payable{ if (msg.value>0) { @@ -36,13 +38,12 @@ contract SystemReward is System, ISystemReward{ } } - function claimRewards(address payable to, uint256 amount) external override(ISystemReward) doInit onlyOperator returns(uint256) { uint256 actualAmount = amount < address(this).balance ? amount : address(this).balance; if (actualAmount > MAX_REWARDS) { actualAmount = MAX_REWARDS; } - if (actualAmount>0) { + if (actualAmount != 0) { to.transfer(actualAmount); emit rewardTo(to, actualAmount); } else { @@ -54,4 +55,20 @@ contract SystemReward is System, ISystemReward{ function isOperator(address addr) external view returns (bool) { return operators[addr]; } -} \ No newline at end of file + + function updateParam(string calldata key, bytes calldata value) onlyGov external override { + if (Memory.compareStrings(key, "updateOperator")) { + bytes memory valueLocal = value; + require(valueLocal.length == 20, "length of value for updateOperator should be 20"); + address operatorAddr; + assembly { + operatorAddr := mload(add(valueLocal, 20)) + } + operators[operatorAddr] = true; + emit updateOperator(operatorAddr); + } else { + require(false, "unknown param"); + } + emit paramChange(key, value); + } +} diff --git a/contracts/SystemReward.template b/contracts/SystemReward.template index 8784188e..34c1f406 100644 --- a/contracts/SystemReward.template +++ b/contracts/SystemReward.template @@ -1,14 +1,16 @@ pragma solidity 0.6.4; + import "./System.sol"; +import "./lib/Memory.sol"; +import "./interface/IParamSubscriber.sol"; import "./interface/ISystemReward.sol"; -contract SystemReward is System, ISystemReward{ +contract SystemReward is System, IParamSubscriber, ISystemReward { uint256 public constant MAX_REWARDS = 1e18; uint public numOperator; mapping(address => bool) operators; - modifier doInit() { if (!alreadyInit) { operators[LIGHT_CLIENT_ADDR] = true; @@ -19,19 +21,16 @@ contract SystemReward is System, ISystemReward{ _; } - modifier onlyOperator() { require(operators[msg.sender],"only operator is allowed to call the method"); _; } - {% if mock %} - event newOperator(address indexed operator); - event deleteOperator(address indexed operator); - {% endif %} + event rewardTo(address indexed to, uint256 amount); event rewardEmpty(); event receiveDeposit(address indexed from, uint256 amount); - + event updateOperator(address indexed operator); + event paramChange(string key, bytes value); receive() external payable{ if (msg.value>0) { @@ -39,35 +38,12 @@ contract SystemReward is System, ISystemReward{ } } - {% if mock %} - modifier onlyOperatorExist(address _operator) { - require(operators[_operator], "the operator do not exist"); - _; - } - - modifier onlyOperatorNotExist(address _operator) { - require(!operators[_operator],"the operator already exist"); - _; - } - - function addOperator(address operator) external doInit onlyOperatorNotExist(operator) { - operators[operator] = true; - numOperator ++; - emit newOperator(operator); - } - - function removeOperator(address operator) external doInit onlyOperatorExist(operator) { - delete operators[operator]; - numOperator --; - emit deleteOperator(operator); - } - {% endif %} function claimRewards(address payable to, uint256 amount) external override(ISystemReward) doInit onlyOperator returns(uint256) { uint256 actualAmount = amount < address(this).balance ? amount : address(this).balance; if (actualAmount > MAX_REWARDS) { actualAmount = MAX_REWARDS; } - if (actualAmount>0) { + if (actualAmount != 0) { to.transfer(actualAmount); emit rewardTo(to, actualAmount); } else { @@ -79,4 +55,20 @@ contract SystemReward is System, ISystemReward{ function isOperator(address addr) external view returns (bool) { return operators[addr]; } -} \ No newline at end of file + + function updateParam(string calldata key, bytes calldata value) onlyGov external override { + if (Memory.compareStrings(key, "updateOperator")) { + bytes memory valueLocal = value; + require(valueLocal.length == 20, "length of value for updateOperator should be 20"); + address operatorAddr; + assembly { + operatorAddr := mload(add(valueLocal, 20)) + } + operators[operatorAddr] = true; + emit updateOperator(operatorAddr); + } else { + require(false, "unknown param"); + } + emit paramChange(key, value); + } +} diff --git a/contracts/TendermintLightClient.sol b/contracts/TendermintLightClient.sol index 418dbe32..d8db849c 100644 --- a/contracts/TendermintLightClient.sol +++ b/contracts/TendermintLightClient.sol @@ -57,7 +57,7 @@ contract TendermintLightClient is ILightClient, System, IParamSubscriber{ emit initConsensusState(initialHeight, cs.appHash); } - function syncTendermintHeader(bytes calldata header, uint64 height) external onlyRelayer returns (bool) { + function syncTendermintHeader(bytes calldata header, uint64 height) external onlyRelayer onlyWhitelabelRelayer returns (bool) { require(submitters[height] == address(0x0), "can't sync duplicated header"); require(height > initialHeight, "can't sync header before initialHeight"); diff --git a/contracts/TendermintLightClient.template b/contracts/TendermintLightClient.template index 13511ed7..efdba652 100644 --- a/contracts/TendermintLightClient.template +++ b/contracts/TendermintLightClient.template @@ -57,7 +57,7 @@ contract TendermintLightClient is ILightClient, System, IParamSubscriber{ emit initConsensusState(initialHeight, cs.appHash); } - function syncTendermintHeader(bytes calldata header, uint64 height) external onlyRelayer returns (bool) { + function syncTendermintHeader(bytes calldata header, uint64 height) external onlyRelayer onlyWhitelabelRelayer returns (bool) { require(submitters[height] == address(0x0), "can't sync duplicated header"); require(height > initialHeight, "can't sync header before initialHeight"); diff --git a/contracts/TokenHub.sol b/contracts/TokenHub.sol index 72a93e76..17a29e59 100644 --- a/contracts/TokenHub.sol +++ b/contracts/TokenHub.sol @@ -561,4 +561,12 @@ contract TokenHub is ITokenHub, System, IParamSubscriber, IApplication, ISystemR } return string(bep2Symbol); } + + function withdrawStakingBNB(uint256 amount) external override returns(bool) { + require(msg.sender == STAKING_CONTRACT_ADDR, "only staking system contract can call this function"); + if (amount != 0) { + payable(STAKING_CONTRACT_ADDR).transfer(amount); + } + return true; + } } diff --git a/contracts/TokenHub.template b/contracts/TokenHub.template index a2979006..7f4b4f8b 100644 --- a/contracts/TokenHub.template +++ b/contracts/TokenHub.template @@ -561,4 +561,12 @@ contract TokenHub is ITokenHub, System, IParamSubscriber, IApplication, ISystemR } return string(bep2Symbol); } + + function withdrawStakingBNB(uint256 amount) external override returns(bool) { + require(msg.sender == STAKING_CONTRACT_ADDR, "only staking system contract can call this function"); + if (amount != 0) { + payable(STAKING_CONTRACT_ADDR).transfer(amount); + } + return true; + } } diff --git a/contracts/interface/IBSCValidatorSet.sol b/contracts/interface/IBSCValidatorSet.sol index 9f7f0c0d..3a6f2407 100644 --- a/contracts/interface/IBSCValidatorSet.sol +++ b/contracts/interface/IBSCValidatorSet.sol @@ -1,6 +1,10 @@ pragma solidity 0.6.4; +pragma experimental ABIEncoderV2; interface IBSCValidatorSet { function misdemeanor(address validator) external; function felony(address validator)external; -} \ No newline at end of file + function isCurrentValidator(address validator) external view returns (bool); + function getLivingValidators() external view returns(address[] memory, bytes[] memory); + function getMiningValidators() external view returns(address[] memory, bytes[] memory); +} diff --git a/contracts/interface/ICrossChain.sol b/contracts/interface/ICrossChain.sol index 893c09f8..ad887f15 100644 --- a/contracts/interface/ICrossChain.sol +++ b/contracts/interface/ICrossChain.sol @@ -5,4 +5,4 @@ interface ICrossChain { * @dev Send package to Binance Chain */ function sendSynPackage(uint8 channelId, bytes calldata msgBytes, uint256 relayFee) external; -} \ No newline at end of file +} diff --git a/contracts/interface/ISlashIndicator.sol b/contracts/interface/ISlashIndicator.sol index eb0f6f02..04f12b7d 100644 --- a/contracts/interface/ISlashIndicator.sol +++ b/contracts/interface/ISlashIndicator.sol @@ -2,4 +2,6 @@ pragma solidity 0.6.4; interface ISlashIndicator { function clean() external; -} \ No newline at end of file + function sendFelonyPackage(address validator) external; + function getSlashThresholds() external view returns (uint256, uint256); +} diff --git a/contracts/interface/IStaking.sol b/contracts/interface/IStaking.sol new file mode 100644 index 00000000..d3358fba --- /dev/null +++ b/contracts/interface/IStaking.sol @@ -0,0 +1,32 @@ +pragma solidity 0.6.4; + +interface IStaking { + + function delegate(address validator, uint256 amount) external payable; + + function undelegate(address validator, uint256 amount) external payable; + + function redelegate(address validatorSrc, address validatorDst, uint256 amount) external payable; + + function claimReward() external returns(uint256); + + function claimUndelegated() external returns(uint256); + + function getDelegated(address delegator, address validator) external view returns(uint256); + + function getTotalDelegated(address delegator) external view returns(uint256); + + function getDistributedReward(address delegator) external view returns(uint256); + + function getPendingRedelegateTime(address delegator, address valSrc, address valDst) external view returns(uint256); + + function getUndelegated(address delegator) external view returns(uint256); + + function getPendingUndelegateTime(address delegator, address validator) external view returns(uint256); + + function getRelayerFee() external view returns(uint256); + + function getMinDelegation() external view returns(uint256); + + function getRequestInFly(address delegator) external view returns(uint256[3] memory); +} diff --git a/contracts/interface/ITokenHub.sol b/contracts/interface/ITokenHub.sol index 429001af..ac935c74 100644 --- a/contracts/interface/ITokenHub.sol +++ b/contracts/interface/ITokenHub.sol @@ -19,6 +19,5 @@ interface ITokenHub { function batchTransferOutBNB(address[] calldata recipientAddrs, uint256[] calldata amounts, address[] calldata refundAddrs, uint64 expireTime) external payable returns (bool); + function withdrawStakingBNB(uint256 amount) external returns(bool); } - - diff --git a/contracts/mock/MerkleProof.sol b/contracts/mock/MerkleProof.sol deleted file mode 100644 index b021ce34..00000000 --- a/contracts/mock/MerkleProof.sol +++ /dev/null @@ -1,7 +0,0 @@ -pragma solidity 0.6.4; - -library MerkleProof { - function validateMerkleProof(bytes32 , string memory , bytes memory, bytes memory , bytes memory) internal pure returns (bool) { - return true; - } -} \ No newline at end of file diff --git a/contracts/mock/MockLightClient.sol b/contracts/mock/MockLightClient.sol deleted file mode 100644 index 4629c5c4..00000000 --- a/contracts/mock/MockLightClient.sol +++ /dev/null @@ -1,30 +0,0 @@ -pragma solidity 0.6.4; - -import "../interface/ILightClient.sol"; - -contract MockLightClient is ILightClient{ - bool blockNotSynced; - bool stateNotVerified; - - function isHeaderSynced(uint64) external override(ILightClient) view returns (bool) { - return !blockNotSynced; - } - - function getAppHash(uint64) external override(ILightClient) view returns (bytes32) { - return bytes32(0x0); - } - - function init() public {} - - function getSubmitter(uint64) external override(ILightClient) view returns (address payable) { - return address(0x0); - } - - function setBlockNotSynced(bool notSynced) external{ - blockNotSynced = notSynced; - } - - function setStateNotVerified(bool notVerified) external{ - stateNotVerified = notVerified; - } -} \ No newline at end of file diff --git a/contracts/mock/MockRelayerHub.sol b/contracts/mock/MockRelayerHub.sol deleted file mode 100644 index ec1520f6..00000000 --- a/contracts/mock/MockRelayerHub.sol +++ /dev/null @@ -1,10 +0,0 @@ -pragma solidity 0.6.4; - -import "../interface/IRelayerHub.sol"; - -contract MockRelayerHub is IRelayerHub { - - function isRelayer(address) external override view returns (bool) { - return true; - } -} diff --git a/contracts/mock/MockSystemReward.sol b/contracts/mock/MockSystemReward.sol deleted file mode 100644 index 8069d758..00000000 --- a/contracts/mock/MockSystemReward.sol +++ /dev/null @@ -1,21 +0,0 @@ -pragma solidity 0.6.4; - -contract MockSystemReward { - - event RewardTo(address indexed to, uint256 indexed amount); - event RewardEmpty(); - - constructor() public payable { - - } - - function claimRewards(address payable to, uint256 amount) public payable { - uint256 actualAmount = amount < address(this).balance ? amount : address(this).balance; - if (actualAmount>0) { - to.transfer(actualAmount); - emit RewardTo(to, actualAmount); - } else { - emit RewardEmpty(); - } - } -} \ No newline at end of file diff --git a/contracts/mock/MockTokenHub.sol b/contracts/mock/MockTokenHub.sol index 5d569fcb..da7b83c7 100644 --- a/contracts/mock/MockTokenHub.sol +++ b/contracts/mock/MockTokenHub.sol @@ -37,6 +37,13 @@ contract MockTokenHub is ITokenHub { function setPanicBatchTransferOut(bool doPanic)external{ panicBatchTransferOut = doPanic; } -} - + function withdrawStakingBNB(uint256 amount) external override returns(bool) { + address STAKING_CONTRACT_ADDR = address(0x0000000000000000000000000000000000002001); + require(msg.sender == STAKING_CONTRACT_ADDR, "only staking system contract can call this function"); + if (amount != 0) { + payable(STAKING_CONTRACT_ADDR).transfer(amount); + } + return true; + } +} diff --git a/foundry.toml b/foundry.toml new file mode 100644 index 00000000..10bde931 --- /dev/null +++ b/foundry.toml @@ -0,0 +1,41 @@ +[profile.default] +src = 'contracts' +test = 'test' +script = 'script' +out = 'out' +fs_permissions = [{ access = "read-write", path = "./" }] +libs = ['lib', 'node_modules'] +remappings = [ + 'ds-test/=lib/forge-std/lib/ds-test/src/', + 'forge-std/=lib/forge-std/src/', + 'openzeppelin-solidity/=node_modules/openzeppelin-solidity/', +] +cache = true +cache_path = 'cache' +auto_detect_solc = true +optimizer = true +optimizer_runs = 200 +verbosity = 3 +ignored_error_codes = [1878, 5574, 5667] +ffi = true +initial_balance = '0xffffffffffffffffffffffff' + +[profile.default.rpc_storage_caching] +chains = 'all' +endpoints = 'all' + +[fuzz] +runs = 1024 + +[fmt] +line_length = 240 +tab_width = 2 +bracket_spacing = false +int_types = 'long' +func_attrs_with_params_multiline = true +quote_style = 'double' +number_underscore = 'preserve' + +[rpc_endpoints] +bsc = "${RPC_BSC}" # set by .env +local = "http://127.0.0.1:8545" diff --git a/generate-genesis.js b/generate-genesis.js index 1c4cacbc..2e25c487 100644 --- a/generate-genesis.js +++ b/generate-genesis.js @@ -19,6 +19,10 @@ program.option( "" ) +program.option("--network ", + "network", + "mainnet"); + program.option( "--initBurnRatio ", "initBurnRatio", @@ -38,6 +42,8 @@ require("./generate-tendermintlightclient"); require("./generate-relayerincentivizecontract"); require("./generate-crosschain"); require("./generate-slash"); +require("./generate-relayerhub"); +require("./generate-staking"); program.version("0.0.1") program.option( @@ -139,6 +145,11 @@ Promise.all([ "crossChain", "contracts/CrossChain.sol", "CrossChain" + ), + compileContract( + "staking", + "contracts/Staking.sol", + "Staking" ) ]).then(result => { diff --git a/generate-relayerhub.js b/generate-relayerhub.js new file mode 100644 index 00000000..7a62f56c --- /dev/null +++ b/generate-relayerhub.js @@ -0,0 +1,31 @@ +const program = require("commander"); +const fs = require("fs"); +const nunjucks = require("nunjucks"); + +program.version("0.0.1"); +program.option( + "-t, --template