diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 7dafd73e7..6ae812950 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -48,7 +48,7 @@ steps: label: "build all rust contracts" agents: - - "queue=bridge" + - "queue=medium" - command: | source ~/.cargo/env @@ -117,57 +117,43 @@ steps: - label: "e2e test" command: | - source ~/.nvm/nvm.sh - source ~/.cargo/env - source ~/.yarn/yarn.sh - - if [[ ! -d ~/go ]]; then - wget -q -O - https://raw.githubusercontent.com/canha/golang-tools-install-script/master/goinstall.sh | bash - fi + source ci/e2e_ci_prepare_env.sh + source ci/e2e_ci_prepare_log.sh + ci/e2e.sh + + artifact_paths: + - "logs/**/*.log" + timeout: 40 + + agents: + - "queue=default" - export GOROOT=~/.go - export GOPATH=~/go - export PATH=$$GOPATH/bin:$$GOROOT/bin:$$PATH - npm i -g ganache-cli - git submodule update --init --recursive + - label: "test challege with near watchdog" + command: | + source ci/e2e_ci_prepare_env.sh + source ci/e2e_ci_prepare_log.sh + ci/test_challenge.sh + + artifact_paths: + - "logs/**/*.log" + timeout: 40 + + agents: + - "queue=default" - # hard link pm2 logs to current dir, so buildkite can pick up them as artifacts - mkdir -p ~/.rainbow/logs/eth-relay - mkdir -p ~/.rainbow/logs/near-relay - mkdir -p ~/.rainbow/logs/ganache - touch eth-relay-out.log - touch eth-relay-err.log - touch near-relay-out.log - touch near-relay-err.log - touch ganache-out.log - touch ganache-err.log - if [[ ! -f ~/.rainbow/logs/eth-relay/out.log ]]; then - ln eth-relay-out.log ~/.rainbow/logs/eth-relay/out.log - ln eth-relay-err.log ~/.rainbow/logs/eth-relay/err.log - ln near-relay-out.log ~/.rainbow/logs/near-relay/out.log - ln near-relay-err.log ~/.rainbow/logs/near-relay/err.log - ln ganache-out.log ~/.rainbow/logs/ganache/out.log - ln ganache-err.log ~/.rainbow/logs/ganache/err.log - fi - - cd environment/vendor/ethashproof - ./build.sh - cd - - rustup default stable - rustup target add wasm32-unknown-unknown - cd environment - yarn - node index.js clean - cd .. - ci/e2e.sh + - label: "test ethrelay catchup" + command: | + source ci/e2e_ci_prepare_env.sh + source ci/e2e_ci_prepare_log.sh + ci/test_ethrelay_catchup.sh artifact_paths: - - "*.log" + - "logs/**/*.log" timeout: 40 agents: - "queue=default" - + - command: | source ~/.nvm/nvm.sh source ~/.yarn/yarn.sh diff --git a/ci/e2e.sh b/ci/e2e.sh index 002e94efb..f01c7cff0 100755 --- a/ci/e2e.sh +++ b/ci/e2e.sh @@ -1,6 +1,5 @@ #!/bin/bash # This test launch all commands and tranfer tokens -# If run locally, you need a manually `node index.js clean`, `npm i -g ganache-cli` set -exuo pipefail @@ -9,6 +8,7 @@ ROOT_DIR=$CI_DIR/.. cd $ROOT_DIR/environment yarn +node index.js clean if [ -n "${LOCAL_CORE_SRC+x}" ]; then node index.js prepare --core-src "$LOCAL_CORE_SRC" else @@ -28,7 +28,7 @@ done node index.js init-near-contracts node index.js init-eth-ed25519 # Use short lockup time for tests -node index.js init-eth-client --eth-client-lock-eth-amount 1e18 --eth-client-lock-duration 10 +node index.js init-eth-client --eth-client-lock-eth-amount 1e18 --eth-client-lock-duration 30 node index.js init-eth-prover node index.js init-eth-erc20 node index.js init-eth-locker diff --git a/ci/e2e_ci_prepare_env.sh b/ci/e2e_ci_prepare_env.sh new file mode 100644 index 000000000..92287578f --- /dev/null +++ b/ci/e2e_ci_prepare_env.sh @@ -0,0 +1,12 @@ +# This file should be sourced when run e2e test on ci +source ~/.nvm/nvm.sh +source ~/.cargo/env +source ~/.yarn/yarn.sh + +if [[ ! -d ~/go ]]; then + wget -q -O - https://raw.githubusercontent.com/canha/golang-tools-install-script/master/goinstall.sh | bash +fi + +export GOROOT=~/.go +export GOPATH=~/go +export PATH=$GOPATH/bin:$GOROOT/bin:$PATH diff --git a/ci/e2e_ci_prepare_log.sh b/ci/e2e_ci_prepare_log.sh new file mode 100644 index 000000000..c156db7a3 --- /dev/null +++ b/ci/e2e_ci_prepare_log.sh @@ -0,0 +1,5 @@ +function finish { + cp -r ~/.rainbow/logs . +} +trap finish ERR +trap finish EXIT \ No newline at end of file diff --git a/ci/test_challenge.sh b/ci/test_challenge.sh new file mode 100755 index 000000000..448bffd81 --- /dev/null +++ b/ci/test_challenge.sh @@ -0,0 +1,66 @@ +#!/bin/bash +# This test launch all commands, submit a invalid block and challenge + +set -exuo pipefail + +CI_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/tmp/ganache.out 2>&1 && pwd )" +ROOT_DIR=$CI_DIR/.. + +cd $ROOT_DIR/environment +yarn +node index.js clean +if [ -n "${LOCAL_CORE_SRC+x}" ]; then + node index.js prepare --core-src "$LOCAL_CORE_SRC" +else + node index.js prepare +fi +node index.js start near-node +# First start pm2 daemon +yarn run pm2 ping +node index.js start ganache +# Wait for the local node to start +while ! curl localhost:3030; do + sleep 1 +done + +while ! curl localhost:9545; do + sleep 1 +done + +node index.js init-near-contracts +node index.js init-eth-ed25519 +# Use short lockup time for tests +node index.js init-eth-client --eth-client-lock-eth-amount 1e18 --eth-client-lock-duration 60 +node index.js init-eth-prover +node index.js init-eth-erc20 +node index.js init-eth-locker +node index.js init-near-fun-token + +sleep 5 +yarn run pm2 list +node index.js start near-relay --eth-master-sk 0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501201 +sleep 5 +yarn run pm2 list +node index.js start eth-relay +sleep 5 +yarn run pm2 list +node index.js start near-watchdog +sleep 5 +yarn run pm2 list + +sleep 30 +node index.js stop near-relay +node index.js DANGER submit_invalid_near_block +sleep 30 +node index.js start near-relay + +node index.js transfer-eth-erc20-to-near --amount 1000 \ +--eth-sender-sk 0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501200 \ +--near-receiver-account rainbow_bridge_eth_on_near_prover --near-master-account rainbow_bridge_eth_on_near_prover \ +2>&1 | tee -a /tmp/eth2neartransfer.out +grep "Balance of rainbow_bridge_eth_on_near_prover after the transfer is 1000" /tmp/eth2neartransfer.out +node index.js transfer-eth-erc20-from-near --amount 1 --near-sender-account rainbow_bridge_eth_on_near_prover \ +--near-sender-sk ed25519:3D4YudUQRE39Lc4JHghuB5WM8kbgDDa34mnrEP5DdTApVH81af7e2dWgNPEaiQfdJnZq1CNPp5im4Rg5b733oiMP \ +--eth-receiver-address 0xEC8bE1A5630364292E56D01129E8ee8A9578d7D8 \ +2>&1 | tee -a /tmp/near2ethtransfer.out +grep "after the transfer: 1" /tmp/near2ethtransfer.out diff --git a/ci/test_ethrelay_catchup.sh b/ci/test_ethrelay_catchup.sh new file mode 100755 index 000000000..41b7e4907 --- /dev/null +++ b/ci/test_ethrelay_catchup.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# This test launch all commands, but postpone start eth-relay late to test it catch fast + +set -exuo pipefail + +CI_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/tmp/ganache.out 2>&1 && pwd )" +ROOT_DIR=$CI_DIR/.. + +cd $ROOT_DIR/environment +yarn +node index.js clean +if [ -n "${LOCAL_CORE_SRC+x}" ]; then + node index.js prepare --core-src "$LOCAL_CORE_SRC" +else + node index.js prepare +fi +node index.js start near-node +export GANACHE_BLOCK_TIME=3 +node index.js start ganache +# Wait for the local node to start +while ! curl localhost:3030; do + sleep 1 +done + +while ! curl localhost:9545; do + sleep 1 +done + +node index.js init-near-contracts +node index.js init-eth-ed25519 +# Use short lockup time for tests +node index.js init-eth-client --eth-client-lock-eth-amount 1e18 --eth-client-lock-duration 10 +node index.js init-eth-prover +node index.js init-eth-erc20 +node index.js init-eth-locker +node index.js init-near-fun-token +# First start pm2 daemon +yarn run pm2 ping +sleep 5 +yarn run pm2 list +node index.js start near-relay --eth-master-sk 0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501201 +sleep 5 +yarn run pm2 list +sleep 100 +node index.js start eth-relay +sleep 5 +yarn run pm2 list +node index.js transfer-eth-erc20-to-near --amount 1000 \ +--eth-sender-sk 0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501200 \ +--near-receiver-account rainbow_bridge_eth_on_near_prover --near-master-account rainbow_bridge_eth_on_near_prover \ +2>&1 | tee -a /tmp/eth2neartransfer.out +grep "Balance of rainbow_bridge_eth_on_near_prover after the transfer is 1000" /tmp/eth2neartransfer.out +node index.js transfer-eth-erc20-from-near --amount 1 --near-sender-account rainbow_bridge_eth_on_near_prover \ +--near-sender-sk ed25519:3D4YudUQRE39Lc4JHghuB5WM8kbgDDa34mnrEP5DdTApVH81af7e2dWgNPEaiQfdJnZq1CNPp5im4Rg5b733oiMP \ +--eth-receiver-address 0xEC8bE1A5630364292E56D01129E8ee8A9578d7D8 \ +2>&1 | tee -a /tmp/near2ethtransfer.out +grep "after the transfer: 1" /tmp/near2ethtransfer.out diff --git a/environment/commands/danger-submit-invalid-near-block.js b/environment/commands/danger-submit-invalid-near-block.js new file mode 100644 index 000000000..af3e0a1e0 --- /dev/null +++ b/environment/commands/danger-submit-invalid-near-block.js @@ -0,0 +1,12 @@ +const ProcessManager = require('pm2') +const { Near2EthRelay } = require('../lib/near2eth-relay') + +class DangerSubmitInvalidNearBlock { + static async execute() { + const relay = new Near2EthRelay() + await relay.initialize() + await relay.DANGER_submitInvalidNearBlock() + } +} + +exports.DangerSubmitInvalidNearBlock = DangerSubmitInvalidNearBlock diff --git a/environment/commands/stop/all.js b/environment/commands/stop/all.js index 8290fd4d4..2005aaecd 100644 --- a/environment/commands/stop/all.js +++ b/environment/commands/stop/all.js @@ -1,32 +1,37 @@ -const ProcessManager = require('pm2-promise'); +const ProcessManager = require('pm2-promise') -const { StopLocalNearNodeCommand } = require('./near.js'); +const { StopLocalNearNodeCommand } = require('./near.js') async function stop(serviceName) { - try { - await ProcessManager.delete(serviceName); - console.log(serviceName, 'successfully stopped...'); - } catch (err) { - if (!err.message.includes('process or namespace not found')) { - console.log(serviceName, 'error stopping the process due to:', err); - } else { - console.log(serviceName, 'already stopped'); - } - }; + try { + await ProcessManager.delete(serviceName) + console.log(serviceName, 'successfully stopped...') + } catch (err) { + if (!err.message.includes('process or namespace not found')) { + console.log(serviceName, 'error stopping the process due to:', err) + } else { + console.log(serviceName, 'already stopped') + } + } } class StopAllCommands { - static async execute() { - console.log('Stopping all processes...'); - - StopLocalNearNodeCommand.execute(); - for (const serviceName of ['ganache', 'eth-relay', 'near-relay', 'near-watchdog']) { - await stop(serviceName); - } + static async execute() { + console.log('Stopping all processes...') - console.log('Stopping all processes done'); - await ProcessManager.disconnect(); + StopLocalNearNodeCommand.execute() + for (const serviceName of [ + 'ganache', + 'eth-relay', + 'near-relay', + 'near-watchdog', + ]) { + await stop(serviceName) } + + console.log('Stopping all processes done') + await ProcessManager.disconnect() + } } -exports.StopAllCommands = StopAllCommands; +exports.StopAllCommands = StopAllCommands diff --git a/environment/commands/stop/near.js b/environment/commands/stop/near.js index c9bca27a2..26ba9463c 100644 --- a/environment/commands/stop/near.js +++ b/environment/commands/stop/near.js @@ -1,15 +1,15 @@ -const { execSync } = require('child_process'); +const { execSync } = require('child_process') class StopLocalNearNodeCommand { - static execute() { - console.log('Stopping local near node...'); - const command = 'python3 ~/.rainbow/nearup/main.py stop'; - try { - execSync(command); - } catch (err) { - console.log('Error stopping local near node', err); - } + static execute() { + console.log('Stopping local near node...') + const command = 'python3 ~/.rainbow/nearup/main.py stop' + try { + execSync(command) + } catch (err) { + console.log('Error stopping local near node', err) } + } } -exports.StopLocalNearNodeCommand = StopLocalNearNodeCommand; +exports.StopLocalNearNodeCommand = StopLocalNearNodeCommand diff --git a/environment/commands/stop/process.js b/environment/commands/stop/process.js index 324cd9936..d975d5f5c 100644 --- a/environment/commands/stop/process.js +++ b/environment/commands/stop/process.js @@ -1,24 +1,24 @@ -const ProcessManager = require('pm2'); +const ProcessManager = require('pm2') class StopManagedProcessCommand { - static execute (command) { - const serviceName = command._name; - console.log('Stopping process:', serviceName); - ProcessManager.delete(serviceName, (err) => { - if (err) { - if (!err.message.includes('process or namespace not found')) { - console.log('Error stopping the process due to:', err); - process.exit(1); - } else { - console.log(serviceName, 'already stopped'); - } - } else { - console.log(serviceName, 'successfully stopped...'); - } - // @ts-ignore - ProcessManager.disconnect(); - }); - } + static execute(command) { + const serviceName = command._name + console.log('Stopping process:', serviceName) + ProcessManager.delete(serviceName, err => { + if (err) { + if (!err.message.includes('process or namespace not found')) { + console.log('Error stopping the process due to:', err) + process.exit(1) + } else { + console.log(serviceName, 'already stopped') + } + } else { + console.log(serviceName, 'successfully stopped...') + } + // @ts-ignore + ProcessManager.disconnect() + }) + } } -exports.StopManagedProcessCommand = StopManagedProcessCommand; +exports.StopManagedProcessCommand = StopManagedProcessCommand diff --git a/environment/commands/transfer-eth-erc20-to-near.js b/environment/commands/transfer-eth-erc20-to-near.js index ebc54fe15..742ddd894 100644 --- a/environment/commands/transfer-eth-erc20-to-near.js +++ b/environment/commands/transfer-eth-erc20-to-near.js @@ -12,7 +12,7 @@ const { verifyAccount } = require('../lib/near-helpers') const { NearMintableToken } = require('../lib/near-mintable-token') const { RainbowConfig } = require('../lib/config') const { NearClientContract } = require('../lib/near-client-contract') -const { sleep } = require('../lib/robust') +const { sleep, RobustWeb3 } = require('../lib/robust') const { normalizeEthKey } = require('../lib/robust') let initialCmd @@ -24,20 +24,24 @@ class TransferETHERC20ToNear { process.exit(1) } - static async approve({ web3, ethERC20Contract, amount, ethSenderAccount }) { + static async approve({ + robustWeb3, + ethERC20Contract, + amount, + ethSenderAccount, + }) { // Approve tokens for transfer. try { console.log('Approving token transfer.') - await ethERC20Contract.methods - .approve(RainbowConfig.getParam('eth-locker-address'), Number(amount)) - .send({ + await robustWeb3.callContract( + ethERC20Contract, + 'approve', + [RainbowConfig.getParam('eth-locker-address'), Number(amount)], + { from: ethSenderAccount, gas: 5000000, - handleRevert: true, - gasPrice: new BN(await web3.eth.getGasPrice()).mul( - new BN(RainbowConfig.getParam('eth-gas-multiplier')) - ), - }) + } + ) console.log('Approved token transfer.') TransferETHERC20ToNear.recordTransferLog({ finished: 'approve' }) } catch (txRevertMessage) { @@ -48,7 +52,7 @@ class TransferETHERC20ToNear { } static async lock({ - web3, + robustWeb3, ethTokenLockerContract, amount, nearReceiverAccount, @@ -58,16 +62,15 @@ class TransferETHERC20ToNear { console.log( 'Transferring tokens from the ERC20 account to the token locker account.' ) - const transaction = await ethTokenLockerContract.methods - .lockToken(Number(amount), nearReceiverAccount) - .send({ + const transaction = await robustWeb3.callContract( + ethTokenLockerContract, + 'lockToken', + [Number(amount), nearReceiverAccount], + { from: ethSenderAccount, gas: 5000000, - handleRevert: true, - gasPrice: new BN(await web3.eth.getGasPrice()).mul( - new BN(RainbowConfig.getParam('eth-gas-multiplier')) - ), - }) + } + ) const lockedEvent = transaction.events.Locked console.log('Success tranfer to locker') TransferETHERC20ToNear.recordTransferLog({ @@ -164,7 +167,7 @@ class TransferETHERC20ToNear { if (!is_safe) { const delay = 10 console.log( - `Near Client is currently at block ${last_block_number}. Waiting for block ${blockNumber} to be confirmed. Sleeping for ${delay} sec.` + `Near Client contract is currently at block ${last_block_number}. Waiting for block ${blockNumber} to be confirmed. Sleeping for ${delay} sec.` ) await sleep(delay * 1000) } else { @@ -261,8 +264,8 @@ class TransferETHERC20ToNear { const nearReceiverAccount = command.nearReceiverAccount // @ts-ignore - const web3 = new Web3(RainbowConfig.getParam('eth-node-url')) - + let robustWeb3 = new RobustWeb3(RainbowConfig.getParam('eth-node-url')) + let web3 = robustWeb3.web3 let ethSenderAccount = web3.eth.accounts.privateKeyToAccount( normalizeEthKey(ethSenderSk) ) @@ -330,7 +333,7 @@ class TransferETHERC20ToNear { if (transferLog.finished === undefined) { await TransferETHERC20ToNear.approve({ - web3, + robustWeb3, ethERC20Contract, amount, ethSenderAccount, @@ -339,7 +342,7 @@ class TransferETHERC20ToNear { } if (transferLog.finished === 'approve') { await TransferETHERC20ToNear.lock({ - web3, + robustWeb3, ethTokenLockerContract, amount, nearReceiverAccount, diff --git a/environment/index.js b/environment/index.js index 607f6c490..c078f07c8 100644 --- a/environment/index.js +++ b/environment/index.js @@ -14,6 +14,9 @@ const { StartLocalNearNodeCommand } = require('./commands/start/near.js') const { StopLocalNearNodeCommand } = require('./commands/stop/near.js') const { StopAllCommands } = require('./commands/stop/all.js') const { StopManagedProcessCommand } = require('./commands/stop/process.js') +const { + DangerSubmitInvalidNearBlock, +} = require('./commands/danger-submit-invalid-near-block') const { TransferETHERC20ToNear, } = require('./commands/transfer-eth-erc20-to-near') @@ -489,6 +492,32 @@ RainbowConfig.addOptions( ] ) +// Testing command +const dangerCommand = program + .command('DANGER') + .description( + 'Dangerous commands that should only be used for testing purpose.' + ) + +RainbowConfig.addOptions( + dangerCommand + .command('submit_invalid_near_block') + .description( + 'Fetch latest near block, randomly mutate one byte and submit to NearBridge' + ) + .action(DangerSubmitInvalidNearBlock.execute), + [ + 'eth-node-url', + 'eth-master-sk', + 'near-node-url', + 'near-network-id', + 'eth-client-abi-path', + 'eth-client-address', + 'near2eth-relay-delay', + 'eth-gas-multiplier', + ] +) + program .command('eth-dump ') .option('--eth-node-url ', 'ETH node API url') diff --git a/environment/lib/borsh/index.js b/environment/lib/borsh/index.js index e16d195fe..e080809e1 100644 --- a/environment/lib/borsh/index.js +++ b/environment/lib/borsh/index.js @@ -388,9 +388,11 @@ class BorshContract { enumerable: true, value: async args => { args = serialize(borshSchema, d.inputFieldType, args) - const result = await this.account.connection.provider.query( - `call/${this.contractId}/${d.methodName}`, - nearlib.utils.serialize.base_encode(args) + const result = await backoff(10, () => + this.account.connection.provider.query( + `call/${this.contractId}/${d.methodName}`, + nearlib.utils.serialize.base_encode(args) + ) ) if (result.logs) { this.account.printLogs(this.contractId, result.logs) diff --git a/environment/lib/near-client-contract/index.js b/environment/lib/near-client-contract/index.js index ae703d9d4..4b597b053 100644 --- a/environment/lib/near-client-contract/index.js +++ b/environment/lib/near-client-contract/index.js @@ -1,136 +1,136 @@ -const { web3BlockToRlp } = require("../eth2near-relay"); +const { web3BlockToRlp } = require('../eth2near-relay') -const Web3 = require("web3"); -const BN = require("bn.js"); -const { BorshContract, hexToBuffer, readerToHex } = require("../borsh"); -const { RobustWeb3 } = require("../robust"); +const Web3 = require('web3') +const BN = require('bn.js') +const { BorshContract, hexToBuffer, readerToHex } = require('../borsh') +const { RobustWeb3 } = require('../robust') // @ts-ignore -const roots = require("./dag_merkle_roots.json"); +const roots = require('./dag_merkle_roots.json') const borshSchema = { bool: { - kind: "function", + kind: 'function', // @ts-ignore - ser: (b) => Buffer.from(Web3.utils.hexToBytes(b ? "0x01" : "0x00")), - deser: (z) => readerToHex(1)(z) === "0x01", + ser: b => Buffer.from(Web3.utils.hexToBytes(b ? '0x01' : '0x00')), + deser: z => readerToHex(1)(z) === '0x01', }, initInput: { - kind: "struct", + kind: 'struct', fields: [ - ["validate_ethash", "bool"], - ["dags_start_epoch", "u64"], - ["dags_merkle_roots", ["H128"]], - ["first_header", ["u8"]], - ["hashes_gc_threshold", "u64"], - ["finalized_gc_threshold", "u64"], - ["num_confirmations", "u64"], + ['validate_ethash', 'bool'], + ['dags_start_epoch', 'u64'], + ['dags_merkle_roots', ['H128']], + ['first_header', ['u8']], + ['hashes_gc_threshold', 'u64'], + ['finalized_gc_threshold', 'u64'], + ['num_confirmations', 'u64'], ], }, dagMerkleRootInput: { - kind: "struct", - fields: [["epoch", "u64"]], + kind: 'struct', + fields: [['epoch', 'u64']], }, addBlockHeaderInput: { - kind: "struct", + kind: 'struct', fields: [ - ["block_header", ["u8"]], - ["dag_nodes", ["DoubleNodeWithMerkleProof"]], + ['block_header', ['u8']], + ['dag_nodes', ['DoubleNodeWithMerkleProof']], ], }, DoubleNodeWithMerkleProof: { - kind: "struct", + kind: 'struct', fields: [ - ["dag_nodes", ["H512"]], - ["proof", ["H128"]], + ['dag_nodes', ['H512']], + ['proof', ['H128']], ], }, H128: { - kind: "function", + kind: 'function', ser: hexToBuffer, deser: readerToHex(16), }, H256: { - kind: "function", + kind: 'function', ser: hexToBuffer, deser: readerToHex(32), }, H512: { - kind: "function", + kind: 'function', ser: hexToBuffer, deser: readerToHex(64), }, - "?H256": { - kind: "option", - type: "H256", + '?H256': { + kind: 'option', + type: 'H256', }, -}; +} class NearClientContract extends BorshContract { constructor(account, contractId) { super(borshSchema, account, contractId, { viewMethods: [ { - methodName: "initialized", + methodName: 'initialized', inputFieldType: null, - outputFieldType: "bool", + outputFieldType: 'bool', }, { - methodName: "dag_merkle_root", - inputFieldType: "dagMerkleRootInput", - outputFieldType: "H128", + methodName: 'dag_merkle_root', + inputFieldType: 'dagMerkleRootInput', + outputFieldType: 'H128', }, { - methodName: "last_block_number", + methodName: 'last_block_number', inputFieldType: null, - outputFieldType: "u64", + outputFieldType: 'u64', }, { - methodName: "block_hash", - inputFieldType: "u64", - outputFieldType: "?H256", + methodName: 'block_hash', + inputFieldType: 'u64', + outputFieldType: '?H256', }, { - methodName: "known_hashes", - inputFieldType: "u64", - outputFieldType: ["H256"], + methodName: 'known_hashes', + inputFieldType: 'u64', + outputFieldType: ['H256'], }, { - methodName: "block_hash_safe", - inputFieldType: "u64", - outputFieldType: "?H256", + methodName: 'block_hash_safe', + inputFieldType: 'u64', + outputFieldType: '?H256', }, ], changeMethods: [ { - methodName: "init", - inputFieldType: "initInput", + methodName: 'init', + inputFieldType: 'initInput', outputFieldType: null, }, { - methodName: "add_block_header", - inputFieldType: "addBlockHeaderInput", + methodName: 'add_block_header', + inputFieldType: 'addBlockHeaderInput', outputFieldType: null, }, ], - }); + }) } // Call initialization methods on the contract. // If validate_ethash is true will do ethash validation otherwise it won't. async maybeInitialize(validate_ethash, robustWeb3) { - await this.accessKeyInit(); - let initialized = false; + await this.accessKeyInit() + let initialized = false try { // @ts-ignore - initialized = await this.initialized(); + initialized = await this.initialized() } catch (e) {} if (!initialized) { - console.log("EthClient is not initialized, initializing..."); - const last_block_number = await robustWeb3.getBlockNumber(); + console.log('EthClient is not initialized, initializing...') + const last_block_number = await robustWeb3.getBlockNumber() const blockRlp = web3BlockToRlp( await robustWeb3.getBlock(last_block_number) - ); + ) // @ts-ignore await this.init( { @@ -142,32 +142,32 @@ class NearClientContract extends BorshContract { finalized_gc_threshold: 500, num_confirmations: 10, }, - new BN("300000000000000") - ); - console.log("EthClient initialized"); + new BN('300000000000000') + ) + console.log('EthClient initialized') } - console.log("Checking EthClient initialization."); + console.log('Checking EthClient initialization.') // @ts-ignore const first_root = await this.dag_merkle_root({ epoch: 0, - }); + }) // @ts-ignore const last_root = await this.dag_merkle_root({ epoch: 511, - }); + }) if ( !( - first_root === "0x55b891e842e58f58956a847cbbf67821" && - last_root === "0x4aa6ca6ebef942d8766065b2e590fd32" + first_root === '0x55b891e842e58f58956a847cbbf67821' && + last_root === '0x4aa6ca6ebef942d8766065b2e590fd32' ) ) { console.log( `EthClient initialization error! The first and last roots are ${first_root} and ${last_root}` - ); - process.exit(1); + ) + process.exit(1) } } } -exports.NearClientContract = NearClientContract; +exports.NearClientContract = NearClientContract diff --git a/environment/lib/near2eth-relay.js b/environment/lib/near2eth-relay.js index 4effc3a15..cbf3d78de 100644 --- a/environment/lib/near2eth-relay.js +++ b/environment/lib/near2eth-relay.js @@ -169,6 +169,119 @@ class Near2EthRelay { } } + async DANGER_submitInvalidNearBlock() { + const clientContract = this.clientContract + const robustWeb3 = this.robustWeb3 + const near = this.near + const ethMasterAccount = this.ethMasterAccount + const web3 = this.web3 + + let lastClientBlock + let clientBlockHash + while (true) { + lastClientBlock = await clientContract.methods.last().call() + const clientBlockHeight = lastClientBlock.height + const clientBlockHashHex = await clientContract.methods + .blockHashes(clientBlockHeight) + .call() + clientBlockHash = bs58.encode(toBuffer(clientBlockHashHex)) + console.log( + `Current light client head is: hash=${clientBlockHash}, height=${clientBlockHeight}` + ) + const latestBlock = await robustWeb3.getBlock('latest') + if (latestBlock.timestamp >= lastClientBlock.validAfter) { + console.log('Block is valid.') + break + } else { + const sleepSec = lastClientBlock.validAfter - latestBlock.timestamp + console.log(`Block is not valid yet. Sleeping ${sleepSec} seconds.`) + await sleep(sleepSec * 1000) + } + } + // Check whether master account has enough balance at stake. + const lockEthAmount = await clientContract.methods.lock_eth_amount().call() + const balance = await clientContract.methods + .balanceOf(ethMasterAccount) + .call() + if (balance === '0') { + console.log( + `The sender account does not have enough stake. Transferring ${lockEthAmount} wei.` + ) + // @ts-ignore + let _depositTx + for (let i = 0; i <= MAX_WEB3_RETRIES; i++) { + if (i === MAX_WEB3_RETRIES) { + console.error(`Failed ${MAX_WEB3_RETRIES} times`) + process.exit(1) + } + try { + _depositTx = await clientContract.methods.deposit().send({ + from: ethMasterAccount, + gas: 1000000, + handleRevert: true, + value: new BN(lockEthAmount), + gasPrice: new BN(await web3.eth.getGasPrice()).mul( + new BN(RainbowConfig.getParam('eth-gas-multiplier')) + ), + }) + break + } catch (err) { + console.log(`Encountered Web3 error while depositing stake ${err}`) + await sleep(1000) + } + } + console.log('Transferred.') + } + let lightClientBlock + for (let i = 0; i <= MAX_WEB3_RETRIES; i++) { + if (i === MAX_WEB3_RETRIES) { + console.error(`Failed ${MAX_WEB3_RETRIES} times`) + process.exit(1) + } + try { + lightClientBlock = await near.connection.provider.sendJsonRpc( + 'next_light_client_block', + [clientBlockHash] + ) + break + } catch (err) { + console.log( + `Encountered error while requesting light client block ${err}` + ) + await sleep(1000) + } + } + console.log(`${JSON.stringify(lightClientBlock)}`) + while (true) { + let borshBlock = borshify(lightClientBlock) + console.log('Mutate block by one byte') + console.log(borshBlock) + borshBlock[Math.floor(borshBlock.length * Math.random())] += 1 + console.log('Adding block') + + try { + await clientContract.methods.addLightClientBlock(borshBlock).send({ + from: ethMasterAccount, + gas: 4000000, + handleRevert: true, + gasPrice: new BN(await web3.eth.getGasPrice()).mul( + new BN(RainbowConfig.getParam('eth-gas-multiplier')) + ), + }) + break + } catch (err) { + console.log( + `Encountered Web3 error while submitting light client block ${err}` + ) + await sleep(1000) + continue + } + } + + console.log('Successfully submit invalid block') + process.exit(0) + } + async run() { // process.send('ready'); const clientContract = this.clientContract diff --git a/environment/lib/near2eth-watchdog.js b/environment/lib/near2eth-watchdog.js index c9b884cb9..a5e685c90 100644 --- a/environment/lib/near2eth-watchdog.js +++ b/environment/lib/near2eth-watchdog.js @@ -60,12 +60,12 @@ class Near2EthWatchdog { // We cannot memorize processed blocks because they might have been re-submitted with different data. for (let i = 0; i < lastClientBlock.approvals_after_next_length; i++) { - console.log(`Checking ${i} signature.`) + console.log(`Checking signature ${i}.`) const result = await this.clientContract.methods .checkBlockProducerSignatureInLastBlock(i) .call() if (!result) { - console.log(`Challenging ${i} signature.`) + console.log(`Challenging signature ${i}.`) try { let gasPrice = await this.web3.eth.getGasPrice() let nonce = await this.web3.eth.getTransactionCount( diff --git a/environment/lib/robust.js b/environment/lib/robust.js index 851a3d2cd..0a31617fd 100644 --- a/environment/lib/robust.js +++ b/environment/lib/robust.js @@ -1,6 +1,7 @@ /// This module gives a few utils for robust error handling, /// and wrap web3 with error handling and retry const Web3 = require('web3') +const _ = require('lodash') const RETRY = 10 const DELAY = 500 @@ -18,6 +19,8 @@ const backoff = (retries, fn, delay = DELAY, wait = BACKOFF) => : Promise.reject(err) ) +const SLOW_TX_ERROR_MSG = 'transaction not executed within 5 minutes' + class RobustWeb3 { constructor(ethNodeUrl) { this.ethNodeUrl = ethNodeUrl @@ -48,6 +51,84 @@ class RobustWeb3 { }) } + async callContract(contract, method, args, options) { + let gasPrice = await this.web3.eth.getGasPrice() + let nonce = await this.web3.eth.getTransactionCount(options.from, 'pending') + while (gasPrice < 10000 * 1e9) { + try { + // Keep sending with same nonce but higher gasPrice to override same txn + let tx = { + from: options.from, + to: contract.options.address, + gas: Web3.utils.toHex(options.gas), + gasPrice: Web3.utils.toHex(gasPrice), + nonce: Web3.utils.toHex(nonce), + data: contract.methods[method](...args).encodeABI(), + } + + let receipt = await promiseWithTimeout( + 5 * 60 * 1000, + this.web3.eth.sendTransaction(tx), + SLOW_TX_ERROR_MSG + ) + if (_.isArray(receipt.logs)) { + // decode logs + var events = _.map(receipt.logs, function(log) { + return contract._decodeEventABI.call( + { + name: 'ALLEVENTS', + jsonInterface: contract.options.jsonInterface, + }, + log + ) + }) + + // make log names keys + receipt.events = {} + var count = 0 + events.forEach(function(ev) { + if (ev.event) { + // if > 1 of the same event, don't overwrite any existing events + if (receipt.events[ev.event]) { + if (Array.isArray(receipt.events[ev.event])) { + receipt.events[ev.event].push(ev) + } else { + receipt.events[ev.event] = [receipt.events[ev.event], ev] + } + } else { + receipt.events[ev.event] = ev + } + } else { + receipt.events[count] = ev + count++ + } + }) + delete receipt.logs + } + return receipt + } catch (e) { + if (e.message === SLOW_TX_ERROR_MSG) { + console.log(SLOW_TX_ERROR_MSG) + console.log( + `current gasPrice: ${gasPrice}. resend tx with double gasPrice` + ) + gasPrice *= 2 + } else if ( + e.message.indexOf("the tx doesn't have the correct nonce") >= 0 + ) { + console.log('nonce error, retrying with new nonce') + nonce++ + } else if (e.toString() === 'Error: connection not open') { + console.log('web3 disconnected, reconnecting') + this.web3.setProvider(this.ethNodeUrl) + } else { + throw e + } + } + } + throw new Error('Cannot finish txn within 1e13 gas') + } + async getTransactionReceipt(t) { return await backoff(RETRY, async () => { try { diff --git a/environment/package.json b/environment/package.json index 8f0a59c98..05d6e162c 100644 --- a/environment/package.json +++ b/environment/package.json @@ -54,4 +54,4 @@ "semi": false, "singleQuote": true } -} +} \ No newline at end of file diff --git a/environment/scripts/start_ganache.sh b/environment/scripts/start_ganache.sh index 4f16d341a..16b1a5c58 100755 --- a/environment/scripts/start_ganache.sh +++ b/environment/scripts/start_ganache.sh @@ -3,4 +3,5 @@ set -euo pipefail SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" cd $SCRIPTS_DIR/../vendor/ganache -yarn run ganache-cli --port 9545 --blockTime 12 --gasLimit 10000000 --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501200,10000000000000000000000000000" --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501201,10000000000000000000000000000" --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501202,10000000000000000000000000000" +ganache_block_time=${GANACHE_BLOCK_TIME:-12} +yarn run ganache-cli --port 9545 --blockTime $ganache_block_time --gasLimit 10000000 --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501200,10000000000000000000000000000" --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501201,10000000000000000000000000000" --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501202,10000000000000000000000000000" diff --git a/libs-rs/eth-client/build.sh b/libs-rs/eth-client/build.sh index 789c75c2b..b52d9dbab 100755 --- a/libs-rs/eth-client/build.sh +++ b/libs-rs/eth-client/build.sh @@ -5,10 +5,15 @@ set -e DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +if [[ -z "$BUILDKITE" ]]; then + userflag="-u $UID:$UID" +else + userflag="" +fi + docker run \ --mount type=bind,source=$DIR/..,target=/host \ - --cap-add=SYS_PTRACE --security-opt seccomp=unconfined \ - -u $UID:$UID \ + --cap-add=SYS_PTRACE --security-opt seccomp=unconfined $userflag \ -w /host/eth-client \ -e RUSTFLAGS='-C link-arg=-s' \ nearprotocol/contract-builder \ diff --git a/libs-rs/eth-prover/build.sh b/libs-rs/eth-prover/build.sh index fed9068af..471e3b821 100755 --- a/libs-rs/eth-prover/build.sh +++ b/libs-rs/eth-prover/build.sh @@ -5,10 +5,15 @@ set -e DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +if [[ -z "$BUILDKITE" ]]; then + userflag="-u $UID:$UID" +else + userflag="" +fi + docker run \ --mount type=bind,source=$DIR/..,target=/host \ - --cap-add=SYS_PTRACE --security-opt seccomp=unconfined \ - -u $UID:$UID \ + --cap-add=SYS_PTRACE --security-opt seccomp=unconfined $userflag \ -w /host/eth-prover \ -e RUSTFLAGS='-C link-arg=-s' \ nearprotocol/contract-builder \ diff --git a/libs-rs/mintable-fungible-token/build.sh b/libs-rs/mintable-fungible-token/build.sh index 6bb2f04b9..a12431aa1 100755 --- a/libs-rs/mintable-fungible-token/build.sh +++ b/libs-rs/mintable-fungible-token/build.sh @@ -3,10 +3,15 @@ set -e DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +if [[ -z "$BUILDKITE" ]]; then + userflag="-u $UID:$UID" +else + userflag="" +fi + docker run \ --mount type=bind,source=$DIR/..,target=/host \ - --cap-add=SYS_PTRACE --security-opt seccomp=unconfined \ - -u $UID:$UID \ + --cap-add=SYS_PTRACE --security-opt seccomp=unconfined $userflag \ -w /host/mintable-fungible-token \ -e RUSTFLAGS='-C link-arg=-s' \ nearprotocol/contract-builder \ diff --git a/libs-sol/nearbridge/contracts/NearBridge.sol b/libs-sol/nearbridge/contracts/NearBridge.sol index 3884a59a3..5b7508811 100644 --- a/libs-sol/nearbridge/contracts/NearBridge.sol +++ b/libs-sol/nearbridge/contracts/NearBridge.sol @@ -61,6 +61,7 @@ contract NearBridge is INearBridge { edwards = ed; lock_eth_amount = l_eth; lock_duration = l_dur; + burner = address(0); } function deposit() public payable { diff --git a/libs-sol/nearbridge/dist/NearBridge.full.abi b/libs-sol/nearbridge/dist/NearBridge.full.abi index 2cd617639..42aa076d3 100644 --- a/libs-sol/nearbridge/dist/NearBridge.full.abi +++ b/libs-sol/nearbridge/dist/NearBridge.full.abi @@ -1 +1 @@ -[{"inputs":[{"internalType":"contract Ed25519","name":"ed","type":"address"},{"internalType":"uint256","name":"l_eth","type":"uint256"},{"internalType":"uint256","name":"l_dur","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"height","type":"uint64"},{"indexed":false,"internalType":"bytes32","name":"blockHash","type":"bytes32"}],"name":"BlockHashAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"height","type":"uint64"},{"indexed":false,"internalType":"bytes32","name":"blockHash","type":"bytes32"}],"name":"BlockHashReverted","type":"event"},{"constant":false,"inputs":[{"internalType":"bytes","name":"data","type":"bytes"}],"name":"addLightClientBlock","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"backup","outputs":[{"internalType":"uint64","name":"height","type":"uint64"},{"internalType":"bytes32","name":"epochId","type":"bytes32"},{"internalType":"bytes32","name":"nextEpochId","type":"bytes32"},{"internalType":"address","name":"submitter","type":"address"},{"internalType":"uint256","name":"validAfter","type":"uint256"},{"internalType":"bytes32","name":"hash","type":"bytes32"},{"internalType":"bytes32","name":"next_hash","type":"bytes32"},{"internalType":"uint256","name":"approvals_after_next_length","type":"uint256"},{"internalType":"uint256","name":"next_bps_length","type":"uint256"},{"internalType":"uint256","name":"next_total_stake","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint64","name":"","type":"uint64"}],"name":"blockHashes","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint64","name":"","type":"uint64"}],"name":"blockMerkleRoots","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address payable","name":"receiver","type":"address"},{"internalType":"uint256","name":"signatureIndex","type":"uint256"}],"name":"challenge","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"signatureIndex","type":"uint256"}],"name":"checkBlockProducerSignatureInLastBlock","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"deposit","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes","name":"data","type":"bytes"}],"name":"initWithBlock","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes","name":"initial_validators","type":"bytes"}],"name":"initWithValidators","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"initialized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"last","outputs":[{"internalType":"uint64","name":"height","type":"uint64"},{"internalType":"bytes32","name":"epochId","type":"bytes32"},{"internalType":"bytes32","name":"nextEpochId","type":"bytes32"},{"internalType":"address","name":"submitter","type":"address"},{"internalType":"uint256","name":"validAfter","type":"uint256"},{"internalType":"bytes32","name":"hash","type":"bytes32"},{"internalType":"bytes32","name":"next_hash","type":"bytes32"},{"internalType":"uint256","name":"approvals_after_next_length","type":"uint256"},{"internalType":"uint256","name":"next_bps_length","type":"uint256"},{"internalType":"uint256","name":"next_total_stake","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"lock_duration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"lock_eth_amount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"prev","outputs":[{"internalType":"uint64","name":"height","type":"uint64"},{"internalType":"bytes32","name":"epochId","type":"bytes32"},{"internalType":"bytes32","name":"nextEpochId","type":"bytes32"},{"internalType":"address","name":"submitter","type":"address"},{"internalType":"uint256","name":"validAfter","type":"uint256"},{"internalType":"bytes32","name":"hash","type":"bytes32"},{"internalType":"bytes32","name":"next_hash","type":"bytes32"},{"internalType":"uint256","name":"approvals_after_next_length","type":"uint256"},{"internalType":"uint256","name":"next_bps_length","type":"uint256"},{"internalType":"uint256","name":"next_total_stake","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"withdraw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] \ No newline at end of file +[{"inputs":[{"internalType":"contract Ed25519","name":"ed","type":"address"},{"internalType":"uint256","name":"l_eth","type":"uint256"},{"internalType":"uint256","name":"l_dur","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"height","type":"uint64"},{"indexed":false,"internalType":"bytes32","name":"blockHash","type":"bytes32"}],"name":"BlockHashAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"height","type":"uint64"},{"indexed":false,"internalType":"bytes32","name":"blockHash","type":"bytes32"}],"name":"BlockHashReverted","type":"event"},{"constant":false,"inputs":[{"internalType":"bytes","name":"data","type":"bytes"}],"name":"addLightClientBlock","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"backup","outputs":[{"internalType":"uint64","name":"height","type":"uint64"},{"internalType":"bytes32","name":"epochId","type":"bytes32"},{"internalType":"bytes32","name":"nextEpochId","type":"bytes32"},{"internalType":"address","name":"submitter","type":"address"},{"internalType":"uint256","name":"validAfter","type":"uint256"},{"internalType":"bytes32","name":"hash","type":"bytes32"},{"internalType":"bytes32","name":"next_hash","type":"bytes32"},{"internalType":"uint256","name":"approvals_after_next_length","type":"uint256"},{"internalType":"uint256","name":"next_bps_length","type":"uint256"},{"internalType":"uint256","name":"next_total_stake","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"backup_prev","outputs":[{"internalType":"uint64","name":"height","type":"uint64"},{"internalType":"bytes32","name":"epochId","type":"bytes32"},{"internalType":"bytes32","name":"nextEpochId","type":"bytes32"},{"internalType":"address","name":"submitter","type":"address"},{"internalType":"uint256","name":"validAfter","type":"uint256"},{"internalType":"bytes32","name":"hash","type":"bytes32"},{"internalType":"bytes32","name":"next_hash","type":"bytes32"},{"internalType":"uint256","name":"approvals_after_next_length","type":"uint256"},{"internalType":"uint256","name":"next_bps_length","type":"uint256"},{"internalType":"uint256","name":"next_total_stake","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint64","name":"","type":"uint64"}],"name":"blockHashes","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint64","name":"","type":"uint64"}],"name":"blockMerkleRoots","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address payable","name":"receiver","type":"address"},{"internalType":"uint256","name":"signatureIndex","type":"uint256"}],"name":"challenge","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"signatureIndex","type":"uint256"}],"name":"checkBlockProducerSignatureInLastBlock","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"deposit","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes","name":"data","type":"bytes"}],"name":"initWithBlock","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes","name":"initial_validators","type":"bytes"}],"name":"initWithValidators","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"initialized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"last","outputs":[{"internalType":"uint64","name":"height","type":"uint64"},{"internalType":"bytes32","name":"epochId","type":"bytes32"},{"internalType":"bytes32","name":"nextEpochId","type":"bytes32"},{"internalType":"address","name":"submitter","type":"address"},{"internalType":"uint256","name":"validAfter","type":"uint256"},{"internalType":"bytes32","name":"hash","type":"bytes32"},{"internalType":"bytes32","name":"next_hash","type":"bytes32"},{"internalType":"uint256","name":"approvals_after_next_length","type":"uint256"},{"internalType":"uint256","name":"next_bps_length","type":"uint256"},{"internalType":"uint256","name":"next_total_stake","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"lock_duration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"lock_eth_amount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"prev","outputs":[{"internalType":"uint64","name":"height","type":"uint64"},{"internalType":"bytes32","name":"epochId","type":"bytes32"},{"internalType":"bytes32","name":"nextEpochId","type":"bytes32"},{"internalType":"address","name":"submitter","type":"address"},{"internalType":"uint256","name":"validAfter","type":"uint256"},{"internalType":"bytes32","name":"hash","type":"bytes32"},{"internalType":"bytes32","name":"next_hash","type":"bytes32"},{"internalType":"uint256","name":"approvals_after_next_length","type":"uint256"},{"internalType":"uint256","name":"next_bps_length","type":"uint256"},{"internalType":"uint256","name":"next_total_stake","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"withdraw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] \ No newline at end of file diff --git a/libs-sol/nearbridge/dist/NearBridge.full.bin b/libs-sol/nearbridge/dist/NearBridge.full.bin index 88be72b69..c94899314 100644 --- a/libs-sol/nearbridge/dist/NearBridge.full.bin +++ b/libs-sol/nearbridge/dist/NearBridge.full.bin @@ -1 +1 @@ -60806040523480156200001157600080fd5b50604051620030c5380380620030c5833981016040819052620000349162000081565b600380546001600160a01b0319166001600160a01b03949094169390931790925560015560025562000123565b80516200006e81620000fe565b92915050565b80516200006e8162000118565b6000806000606084860312156200009757600080fd5b6000620000a5868662000061565b9350506020620000b88682870162000074565b9250506040620000cb8682870162000074565b9150509250925092565b60006200006e82620000ef565b60006200006e82620000d5565b6001600160a01b031690565b90565b6200010981620000e2565b81146200011557600080fd5b50565b6200010981620000fb565b612f9280620001336000396000f3fe6080604052600436106100f35760003560e01c8063479c92541161008a57806389aca7511161005957806389aca75114610264578063acb9982814610284578063ceddcc44146102a4578063d0e30db0146102b9576100f3565b8063479c92541461020757806350a9e1271461021c5780636d2d6ae01461023157806370a0823114610244576100f3565b80631e703806116100c65780631e7038061461018757806337da8ec5146101a75780633ccfd60b146101c757806347799da8146101dc576100f3565b806309d7e8e7146100f85780630b59a2441461011a578063158ef93e14610145578063160bc0ba14610167575b600080fd5b34801561010457600080fd5b506101186101133660046123a0565b6102c1565b005b34801561012657600080fd5b5061012f61044b565b60405161013c9190612b8d565b60405180910390f35b34801561015157600080fd5b5061015a610451565b60405161013c9190612b7f565b34801561017357600080fd5b506101186101823660046123a0565b61045a565b34801561019357600080fd5b5061012f6101a23660046123f2565b610505565b3480156101b357600080fd5b5061012f6101c23660046123f2565b610517565b3480156101d357600080fd5b50610118610529565b3480156101e857600080fd5b506101f16105b3565b60405161013c9a99989796959493929190612d76565b34801561021357600080fd5b506101f16105ec565b34801561022857600080fd5b506101f1610625565b61011861023f3660046123a0565b61065e565b34801561025057600080fd5b5061012f61025f3660046122dc565b610813565b34801561027057600080fd5b5061015a61027f3660046123d4565b610825565b34801561029057600080fd5b5061011861029f3660046122fa565b61090d565b3480156102b057600080fd5b5061012f610961565b610118610967565b60005460ff16156102ed5760405162461bcd60e51b81526004016102e490612ca6565b60405180910390fd5b6102f5611f9c565b6102fe826109c0565b9050610308611fb6565b610311826109e2565b905061031c82610a72565b6103385760405162461bcd60e51b81526004016102e490612cb6565b8051516019556000805b8251518110156104425760405180604001604052808460000151838151811061036757fe5b60200260200101516020015181526020018460000151838151811061038857fe5b6020908102919091018101516040908101516001600160801b039081169093526000858152601b835281902084518051825460ff191660ff9091161782558084015151600183015590910151805160028301558201516003820155920151600490920180546001600160801b031916929091169190911790558251805161043891908390811061041457fe5b6020026020010151604001516001600160801b031683610a7e90919063ffffffff16565b9150600101610342565b50601a55505050565b60015481565b60005460ff1681565b601a546104795760405162461bcd60e51b81526004016102e490612cd6565b60005460ff161561049c5760405162461bcd60e51b81526004016102e490612ca6565b6000805460ff191660011790556104b1611f9c565b6104ba826109c0565b90506104c4611fc9565b6104cd82610aac565b90506104d882610a72565b6104f45760405162461bcd60e51b81526004016102e490612d16565b61050081846001610cef565b505050565b60296020526000908152604090205481565b60286020526000908152604090205481565b6007546001600160a01b031633141580610544575060085442115b61054d57600080fd5b600154336000908152602a602052604090205461056f9163ffffffff61131116565b336000818152602a6020526040808220939093556001549251919280156108fc02929091818181858888f193505050501580156105b0573d6000803e3d6000fd5b50565b600454600554600654600754600854600954600a54600b54600d54600e546001600160401b03909916986001600160a01b03909616958a565b601054601154601254601354601454601554601654601754601954601a546001600160401b03909916986001600160a01b03909616958a565b601c54601d54601e54601f546020546021546022546023546025546026546001600160401b03909916986001600160a01b03909616958a565b600154336000908152602a6020526040902054101561068f5760405162461bcd60e51b81526004016102e490612d56565b6008544210156106b15760405162461bcd60e51b81526004016102e490612c66565b6106b9611f9c565b6106c2826109c0565b90506106cc611fc9565b6106d582610aac565b90506106e082610a72565b6106fc5760405162461bcd60e51b81526004016102e490612d36565b6004546040820151516001600160401b0391821691161161072f5760405162461bcd60e51b81526004016102e490612c56565b60055460408201516020015114806107505750600654604082015160200151145b61076c5760405162461bcd60e51b81526004016102e490612ce6565b60065460408201516020015114156107a157608081015151156107a15760405162461bcd60e51b81526004016102e490612d46565b60055460408201516020015114156107c3576107be816010611353565b6107ce565b6107ce816004611353565b60808101515161080757806040015160c00151816080015160400151146108075760405162461bcd60e51b81526004016102e490612c86565b61050081846000610cef565b602a6020526000908152604090205481565b6000818152600c602052604081205460ff161561084457506001610908565b600454600a546000848152600c602090815260409182902082516060808201855260018301805460ff168352855191820195869052610905976001600160401b03169695929490938582019360029182019284929083019184919082845b8154815260200190600101908083116108a2575050509190925250505081526040805160608101825260038401548152600484015460208281019190915260059094015460ff1681830152918301919091526000888152601b909252902061142d565b90505b919050565b600854421061092e5760405162461bcd60e51b81526004016102e490612c36565b61093781610825565b156109545760405162461bcd60e51b81526004016102e490612cc6565b61095d82611612565b5050565b60025481565b600154341480156109855750336000908152602a6020526040902054155b61098e57600080fd5b336000908152602a60205260409020546109ae903463ffffffff610a7e16565b336000908152602a6020526040902055565b6109c8611f9c565b506040805180820190915260008152602081019190915290565b6109ea611fb6565b6109f382611904565b63ffffffff16604051908082528060200260200182016040528015610a3257816020015b610a1f612017565b815260200190600190039081610a175790505b50815260005b815151811015610a6c57610a4b8361192c565b8251805183908110610a5957fe5b6020908102919091010152600101610a38565b50919050565b60208101515190511490565b600082820183811015610aa35760405162461bcd60e51b81526004016102e490612c96565b90505b92915050565b610ab4611fc9565b610abd82611969565b8152610ac882611969565b6020820152610ad6826119b3565b6040820152610ae482611969565b6060820152610af282611a4c565b6080820152610b0082611904565b63ffffffff16604051908082528060200260200182016040528015610b3f57816020015b610b2c61203e565b815260200190600190039081610b245790505b5060a082015260005b8160a0015151811015610b8157610b5e83611b19565b8260a001518281518110610b6e57fe5b6020908102919091010152600101610b48565b50600280826040015161010001518360600151604051602001610ba5929190612afe565b60408051601f1981840301815290829052610bbf91612b24565b602060405180830381855afa158015610bdc573d6000803e3d6000fd5b5050506040513d601f19601f82011682018060405250610bff9190810190612352565b8251604051610c12929190602001612afe565b60408051601f1981840301815290829052610c2c91612b24565b602060405180830381855afa158015610c49573d6000803e3d6000fd5b5050506040513d601f19601f82011682018060405250610c6c9190810190612352565b60c08201819052602080830151604051600293610c8b93909101612afe565b60408051601f1981840301815290829052610ca591612b24565b602060405180830381855afa158015610cc2573d6000803e3d6000fd5b5050506040513d601f19601f82011682018060405250610ce59190810190612352565b60e0820152919050565b600454601c805467ffffffffffffffff19166001600160401b03909216919091179055600554601d55600654601e55600754601f80546001600160a01b0319166001600160a01b03909216919091179055600854602055600954602155600a54602255600b54602355600d54602555600e5460265560005b602554811015610de5576000818152600f6020908152604080832060279092529091208154815460ff191660ff9091161781556001808301548183015560028084015490830155600380840154908301556004928301549190920180546001600160801b0319166001600160801b0390921691909117905501610d67565b5060005b602354811015610e87576000818152600c6020908152604080832060249092529091208154815460ff918216151560ff199182161783556001808501805491850180549093169190931617815560028085019080850190610e4d908290849061205f565b50505060038281015490820155600480830154908201556005918201549101805460ff191660ff9092169190911790555050600101610de9565b506006546040840151602001511415610f92576004546010805467ffffffffffffffff19166001600160401b03909216919091179055600554601155600654601255600754601380546001600160a01b0319166001600160a01b03909216919091179055600854601455600954601555600a54601655600b54601755600d54601955600e54601a5560005b601954811015610f90576000818152600f60209081526040808320601b9092529091208154815460ff191660ff9091161781556001808301548183015560028084015490830155600380840154908301556004928301549190920180546001600160801b0319166001600160801b0390921691909117905501610f12565b505b6000805b84608001516020015151811015610fc857610fbe856080015160200151828151811061041457fe5b9150600101610f96565b5060408051610140810182528582018051516001600160401b03168252805160209081015190830152518201519181019190915233606082015260808101836110245760025461101f90429063ffffffff610a7e16565b611027565b60005b815284516020808701919091208183015260e08781015160408085019190915260a0808a0151516060808701919091526080808c0151860151518188015295820188905286516004805467ffffffffffffffff19166001600160401b03909216919091179055938601516005559085015160065591840151600780546001600160a01b0319166001600160a01b039092169190911790559183015160085582015160095560c0820151600a55810151600b55610100810151600d556101200151600e5560005b846080015160200151518110156111c6576040518060400160405280866080015160200151838151811061111d57fe5b6020026020010151602001518152602001866080015160200151838151811061114257fe5b6020908102919091018101516040908101516001600160801b039081169093526000858152600f835281902084518051825460ff191660ff90911617825580840151516001808401919091559201518051600283015583015160038201559390910151600490930180546001600160801b03191693909216929092179055016110ed565b5060005b8460a0015151811015611283578460a0015181815181106111e757fe5b6020908102919091018101516000838152600c8352604090208151815490151560ff1991821617825582840151805160018401805460ff9290921691909316178255938401518051939492936002808601916112459183919061209a565b5050506040918201518051600383015560208101516004830155909101516005909101805460ff191660ff90921691909117905550506001016111ca565b5060c084015160408086018051516001600160401b0390811660009081526028602081815285832096909655925160e0810151905183168252602986528482205560045490911680825291909352918190205490517f5d45c22c440038a3aaf9f8134e7aa1fa59aa2a7fa411d7e818d7701c63827d7e9161130391612b8d565b60405180910390a250505050565b6000610aa383836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611b48565b80600901548260a00151511461137b5760405162461bcd60e51b81526004016102e490612d26565b6000805b8360a00151518110156113e5578360a00151818151811061139c57fe5b6020026020010151600001516113dd576000818152600b840160205260409020600401546113da9083906001600160801b031663ffffffff610a7e16565b91505b60010161137f565b5061140f6003611403600285600a0154611b7490919063ffffffff16565b9063ffffffff611bae16565b81116105005760405162461bcd60e51b81526004016102e490612c46565b6000606060008561144088600201611bf0565b60405161145593929190600090602001612b37565b60408051601f19818403018152919052845190915060ff1661153c57600080828060200190516114889190810190612370565b60018701549193509150158015906115325750600354600186015460208881015151805191015160405163ebd1b95160e01b81526001600160a01b039094169363ebd1b951936114e2939092909188908890600401612b9b565b60206040518083038186803b1580156114fa57600080fd5b505afa15801561150e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506115329190810190612334565b935050505061160a565b60028301546003840154604051611557929190602001612afe565b6040516020818303038152906040528051906020012060001c6001600160a01b031660018280519060200120601b87604001516040015160ff161061159d5760006115a0565b601b5b604080890151808201518151602092830151845160008152909301938490526115d0959490910192909190612be7565b6020604051602081039080840390855afa1580156115f2573d6000803e3d6000fd5b505050602060405103516001600160a01b0316149150505b949350505050565b6001546007546001600160a01b03166000908152602a602052604090205461163f9163ffffffff61131116565b6007546001600160a01b039081166000908152602a6020526040808220939093556001549251918416926002900480156108fc02929091818181858888f19350505050158015611693573d6000803e3d6000fd5b50600060019054906101000a90046001600160a01b03166001600160a01b03166108fc6002600154816116c257fe5b04600154039081150290604051600060405180830381858888f193505050501580156116f2573d6000803e3d6000fd5b50600480546001600160401b039081166000908152602860208181526040808420849055855485168452602982528084208490559454909316808352925282902054915190917f4e9ddd5df7d5ac983348809fe8a0617e2e53415abf6f504c73ee2b2b22076ef6916117649190612b8d565b60405180910390a2601c546004805467ffffffffffffffff19166001600160401b03909216919091179055601d54600555601e54600655601f54600780546001600160a01b0319166001600160a01b03909216919091179055602054600855602154600955602254600a55602354600b55602554600d55602654600e5560005b600d54811015611862576000818152602760209081526040808320600f9092529091208154815460ff191660ff9091161781556001808301548183015560028084015490830155600380840154908301556004928301549190920180546001600160801b0319166001600160801b03909216919091179055016117e4565b5060005b600b5481101561095d576000818152602460209081526040808320600c9092529091208154815460ff918216151560ff1991821617835560018085018054918501805490931691909316178155600280850190808501906118ca908290849061205f565b50505060038281015490820155600480830154908201556005918201549101805460ff191660ff9092169190911790555050600101611866565b600061190f82611c4f565b61ffff169050601061192083611c4f565b61ffff16901b17919050565b611934612017565b61193d82611c75565b815261194882611cf6565b602082015261195682611d5f565b6001600160801b03166040820152919050565b60008160208082600001510182602001515110156119995760405162461bcd60e51b81526004016102e490612c76565b602080850151945190940190930151815190930190525090565b6119bb6120c8565b6119cc8260d063ffffffff611d9116565b6101008201526119db82611da6565b6001600160401b031681526119ef82611969565b60208201526119fd82611969565b6040820152611a0b82611969565b6060820152611a1982611969565b6080820152611a2782611da6565b6001600160401b031660a0820152611a3e82611969565b60c0820152610ce582611969565b611a54612114565b611a5d82611dd2565b60ff1615808252610908578151611a7383611904565b63ffffffff16604051908082528060200260200182016040528015611ab257816020015b611a9f612017565b815260200190600190039081611a975790505b50602083015260005b826020015151811015611af457611ad18461192c565b83602001518281518110611ae157fe5b6020908102919091010152600101611abb565b508251818452611b0c8483830363ffffffff611d9116565b6040840152835250919050565b611b2161203e565b611b2a82611dd2565b60ff161580825261090857611b3e82611e29565b6020820152919050565b60008184841115611b6c5760405162461bcd60e51b81526004016102e49190612c25565b505050900390565b600082611b8357506000610aa6565b82820282848281611b9057fe5b0414610aa35760405162461bcd60e51b81526004016102e490612cf6565b6000610aa383836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611e7e565b602081811b67ffffffff000000001663ffffffff9290911c9190911617601081811b67ffff0000ffff00001665ffff0000ffff9290911c9190911617600881811b67ff00ff00ff00ff001666ff00ff00ff00ff9290911c919091161790565b6000611c5a82611dd2565b60ff1690506008611c6a83611dd2565b60ff16901b17919050565b6060611c8082611904565b63ffffffff166040519080825280601f01601f191660200182016040528015611cb0576020820181803883390190505b50905060005b8151811015610a6c57611cc883611dd2565b60f81b828281518110611cd757fe5b60200101906001600160f81b031916908160001a905350600101611cb6565b611cfe61213a565b611d0782611dd2565b60ff16808252611d2457611d1a82611eb5565b6020820152610908565b806000015160ff1660011415611d4757611d3d82611ecd565b6040820152610908565b60405162461bcd60e51b81526004016102e490612d06565b6000611d6a82611da6565b6001600160401b031690506040611d8083611da6565b6001600160401b0316901b17919050565b6000610aa38360200151846000015184611ee9565b6000611db182611904565b63ffffffff1690506020611dc483611904565b63ffffffff16901b17919050565b6000816001808260000151018260200151511015611e025760405162461bcd60e51b81526004016102e490612c76565b6020840151845181518110611e1357fe5b0160200151825190910190915260f81c92915050565b611e31612164565b611e3a82611dd2565b60ff16808252611e4d57611d1a82611f0b565b806000015160ff1660011415611e6657611d3d82611f33565b60405162461bcd60e51b81526004016102e490612d66565b60008183611e9f5760405162461bcd60e51b81526004016102e49190612c25565b506000838581611eab57fe5b0495945050505050565b611ebd61218e565b611ec682611969565b8152919050565b611ed56121a0565b611ede82611f6a565b8152611b3e82611f6a565b6000611ef36121ba565b6020818486602089010160025afa5051949350505050565b611f136121d8565b611f1c82611969565b815152611f2882611969565b815160200152919050565b611f3b6121eb565b611f4482611969565b8152611f4f82611969565b6020820152611f5d82611dd2565b60ff166040820152919050565b6000611f7582611d5f565b6001600160801b031690506080611f8b83611d5f565b6001600160801b0316901b17919050565b604051806040016040528060008152602001606081525090565b6040518060200160405280606081525090565b604080516101008101825260008082526020820152908101611fe96120c8565b815260006020820152604001611ffd612114565b815260606020820181905260006040830181905291015290565b60405180606001604052806060815260200161203161213a565b8152600060209091015290565b604051806040016040528060001515815260200161205a612164565b905290565b826002810192821561208a579182015b8281111561208a57825482559160010191906001019061206f565b5061209692915061220b565b5090565b826002810192821561208a579160200282015b8281111561208a5782518255916020019190600101906120ad565b6040805161012081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e0810182905261010081019190915290565b604051806060016040528060001515815260200160608152602001600080191681525090565b6040518060600160405280600060ff16815260200161215761218e565b815260200161205a6121a0565b6040518060600160405280600060ff1681526020016121816121d8565b815260200161205a6121eb565b60408051602081019091526000815290565b604051806040016040528060008152602001600081525090565b60405180602001604052806001906020820280388339509192915050565b604051806020016040528061205a612228565b604080516060810182526000808252602082018190529181019190915290565b61222591905b808211156120965760008155600101612211565b90565b60405180604001604052806002906020820280388339509192915050565b8035610aa681612f17565b8051610aa681612f2b565b8051610aa681612f34565b8051610aa681612f3d565b600082601f83011261228357600080fd5b813561229661229182612e31565b612e0b565b915080825260208301602083018583830111156122b257600080fd5b6122bd838284612eaf565b50505092915050565b8035610aa681612f34565b8035610aa681612f46565b6000602082840312156122ee57600080fd5b600061160a8484612246565b6000806040838503121561230d57600080fd5b60006123198585612246565b925050602061232a858286016122c6565b9150509250929050565b60006020828403121561234657600080fd5b600061160a8484612251565b60006020828403121561236457600080fd5b600061160a848461225c565b6000806040838503121561238357600080fd5b600061238f858561225c565b925050602061232a85828601612267565b6000602082840312156123b257600080fd5b81356001600160401b038111156123c857600080fd5b61160a84828501612272565b6000602082840312156123e657600080fd5b600061160a84846122c6565b60006020828403121561240457600080fd5b600061160a84846122d1565b61241981612e65565b82525050565b61241981612e70565b61241961243482612e75565b612225565b61241981612225565b61241961243482612225565b61241981612e84565b600061246282612e58565b61246c8185610908565b935061247c818560208601612ebb565b9290920192915050565b600061249182612e58565b61249b8185612e5c565b93506124ab818560208601612ebb565b6124b481612f01565b9093019392505050565b60006124cb601a83612e5c565b7f4c6f636b20706572696f6420616c726561647920706173736564000000000000815260200192915050565b6000612504603783612e5c565b7f4e6561724272696467653a204c657373207468616e20322f3320766f7465642081527f62792074686520626c6f636b206166746572206e657874000000000000000000602082015260400192915050565b6000612563602c83612e5c565b7f4e6561724272696467653a20486569676874206f662074686520626c6f636b2081526b1a5cc81b9bdd081d985b1a5960a21b602082015260400192915050565b60006125b1602283612e5c565b7f5761697420756e74696c206c61737420626c6f636b206265636f6d652076616c8152611a5960f21b602082015260400192915050565b60006125f5601383612e5c565b72426f7273683a204f7574206f662072616e676560681b815260200192915050565b6000612624603083612e5c565b7f4e6561724272696467653a2048617368206f6620626c6f636b2070726f64756381526f0cae4e640c8de40dcdee840dac2e8c6d60831b602082015260400192915050565b6000612676601b83612e5c565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815260200192915050565b60006126af601f83612e5c565b7f4e6561724272696467653a20616c726561647920696e697469616c697a656400815260200192915050565b60006126e8604783612e5c565b7f4e6561724272696467653a206f6e6c7920696e697469616c2076616c6964617481527f6f72732073686f756c6420626520706173736564206173207365636f6e6420616020820152661c99dd5b595b9d60ca1b604082015260600192915050565b6000612757601f83612e5c565b7f43616e2774206368616c6c656e67652076616c6964207369676e617475726500815260200192915050565b6000612790603383612e5c565b7f4e6561724272696467653a2076616c696461746f7273206e65656420746f206281527219481a5b9a5d1a585b1a5e995908199a5c9cdd606a1b602082015260400192915050565b60006127e5602e83612e5c565b7f4e6561724272696467653a2045706f6368206964206f662074686520626c6f6381526d1ac81a5cc81b9bdd081d985b1a5960921b602082015260400192915050565b6000612835602183612e5c565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f8152607760f81b602082015260400192915050565b6000612878604083612e5c565b7f4e6561724272696467653a204f6e6c79204544323535313920616e642053454381527f503235364b31207075626c6963206b6579732061726520737570706f72746564602082015260400192915050565b60006128d7604683612e5c565b7f4e6561724272696467653a206f6e6c79206c6967687420636c69656e7420626c81527f6f636b2073686f756c642062652070617373656420617320666972737420617260208201526519dd5b595b9d60d21b604082015260600192915050565b6000612945603a83612e5c565b7f4e6561724272696467653a206e756d626572206f66204250732073686f756c6481527f206d61746368206e756d626572206f6620617070726f76616c73000000000000602082015260400192915050565b60006129a4603483612e5c565b7f4e6561724272696467653a206f6e6c79206c6967687420636c69656e7420626c8152731bd8dac81cda1bdd5b19081899481c185cdcd95960621b602082015260400192915050565b60006129fa602b83612e5c565b7f4e6561724272696467653a204e657874206e6578745f6270732073686f756c6481526a206e6f206265204e6f6e6560a81b602082015260400192915050565b6000612a47601583612e5c565b74084c2d8c2dcc6ca40d2e640dcdee840cadcdeeaced605b1b815260200192915050565b6000612a78603f83612e5c565b7f4e6561724272696467653a204f6e6c79204544323535313920616e642053454381527f503235364b31207369676e6174757265732061726520737570706f7274656400602082015260400192915050565b61241981612e9d565b612419612adf82612e9d565b612eeb565b61241981612ea9565b612419612af982612ea9565b612ef6565b6000612b0a8285612442565b602082019150612b1a8284612442565b5060200192915050565b6000612b308284612457565b9392505050565b6000612b438287612aed565b600182019150612b538286612442565b602082019150612b638285612ad3565b600882019150612b738284612428565b50601701949350505050565b60208101610aa6828461241f565b60208101610aa68284612439565b60a08101612ba98288612439565b612bb66020830187612439565b612bc36040830186612439565b612bd06060830185612439565b612bdd608083018461244e565b9695505050505050565b60808101612bf58287612439565b612c026020830186612ae4565b612c0f6040830185612439565b612c1c6060830184612439565b95945050505050565b60208082528101610aa38184612486565b60208082528101610905816124be565b60208082528101610905816124f7565b6020808252810161090581612556565b60208082528101610905816125a4565b60208082528101610905816125e8565b6020808252810161090581612617565b6020808252810161090581612669565b60208082528101610905816126a2565b60208082528101610905816126db565b602080825281016109058161274a565b6020808252810161090581612783565b60208082528101610905816127d8565b6020808252810161090581612828565b602080825281016109058161286b565b60208082528101610905816128ca565b6020808252810161090581612938565b6020808252810161090581612997565b60208082528101610905816129ed565b6020808252810161090581612a3a565b6020808252810161090581612a6b565b6101408101612d85828d612aca565b612d92602083018c612439565b612d9f604083018b612439565b612dac606083018a612410565b612db96080830189612439565b612dc660a0830188612439565b612dd360c0830187612439565b612de060e0830186612439565b612dee610100830185612439565b612dfc610120830184612439565b9b9a5050505050505050505050565b6040518181016001600160401b0381118282101715612e2957600080fd5b604052919050565b60006001600160401b03821115612e4757600080fd5b506020601f91909101601f19160190565b5190565b90815260200190565b600061090582612e91565b151590565b68ffffffffffffffffff191690565b6001600160b81b03191690565b6001600160a01b031690565b6001600160401b031690565b60ff1690565b82818337506000910152565b60005b83811015612ed6578181015183820152602001612ebe565b83811115612ee5576000848401525b50505050565b600061090582612f0b565b600061090582612f11565b601f01601f191690565b60c01b90565b60f81b90565b612f2081612e65565b81146105b057600080fd5b612f2081612e70565b612f2081612225565b612f2081612e84565b612f2081612e9d56fea365627a7a72315820371a5fd0d3322cd2160f17b33836fadc478406afbcbf2770df2d7c14ffe1a9926c6578706572696d656e74616cf564736f6c63430005100040 \ No newline at end of file +60806040523480156200001157600080fd5b506040516200332b3803806200332b833981016040819052620000349162000092565b600380546001600160a01b0319166001600160a01b03949094169390931790925560015560025560008054610100600160a81b031916905562000134565b80516200007f816200010f565b92915050565b80516200007f8162000129565b600080600060608486031215620000a857600080fd5b6000620000b6868662000072565b9350506020620000c98682870162000085565b9250506040620000dc8682870162000085565b9150509250925092565b60006200007f8262000100565b60006200007f82620000e6565b6001600160a01b031690565b90565b6200011a81620000f3565b81146200012657600080fd5b50565b6200011a816200010c565b6131e780620001446000396000f3fe6080604052600436106100fe5760003560e01c806347799da81161009557806370a082311161006457806370a082311461026457806389aca75114610284578063acb99828146102a4578063ceddcc44146102c4578063d0e30db0146102d9576100fe565b806347799da814610212578063479c92541461022757806350a9e1271461023c5780636d2d6ae014610251576100fe565b80631e703806116100d15780631e7038061461019257806326bf8ab5146101b257806337da8ec5146101dd5780633ccfd60b146101fd576100fe565b806309d7e8e7146101035780630b59a24414610125578063158ef93e14610150578063160bc0ba14610172575b600080fd5b34801561010f57600080fd5b5061012361011e3660046125f5565b6102e1565b005b34801561013157600080fd5b5061013a61046b565b6040516101479190612de2565b60405180910390f35b34801561015c57600080fd5b50610165610471565b6040516101479190612dd4565b34801561017e57600080fd5b5061012361018d3660046125f5565b61047a565b34801561019e57600080fd5b5061013a6101ad366004612647565b610525565b3480156101be57600080fd5b506101c7610537565b6040516101479a99989796959493929190612fcb565b3480156101e957600080fd5b5061013a6101f8366004612647565b610570565b34801561020957600080fd5b50610123610582565b34801561021e57600080fd5b506101c761060c565b34801561023357600080fd5b506101c7610645565b34801561024857600080fd5b506101c761067e565b61012361025f3660046125f5565b6106b7565b34801561027057600080fd5b5061013a61027f366004612531565b61086c565b34801561029057600080fd5b5061016561029f366004612629565b61087e565b3480156102b057600080fd5b506101236102bf36600461254f565b610966565b3480156102d057600080fd5b5061013a6109ba565b6101236109c0565b60005460ff161561030d5760405162461bcd60e51b815260040161030490612efb565b60405180910390fd5b6103156121f1565b61031e82610a19565b905061032861220b565b61033182610a3b565b905061033c82610acb565b6103585760405162461bcd60e51b815260040161030490612f0b565b8051516019556000805b8251518110156104625760405180604001604052808460000151838151811061038757fe5b6020026020010151602001518152602001846000015183815181106103a857fe5b6020908102919091018101516040908101516001600160801b039081169093526000858152601b835281902084518051825460ff191660ff9091161782558084015151600183015590910151805160028301558201516003820155920151600490920180546001600160801b031916929091169190911790558251805161045891908390811061043457fe5b6020026020010151604001516001600160801b031683610ad790919063ffffffff16565b9150600101610362565b50601a55505050565b60015481565b60005460ff1681565b601a546104995760405162461bcd60e51b815260040161030490612f2b565b60005460ff16156104bc5760405162461bcd60e51b815260040161030490612efb565b6000805460ff191660011790556104d16121f1565b6104da82610a19565b90506104e461221e565b6104ed82610b05565b90506104f882610acb565b6105145760405162461bcd60e51b815260040161030490612f6b565b61052081846001610d48565b505050565b60356020526000908152604090205481565b602854602954602a54602b54602c54602d54602e54602f546031546032546001600160401b03909916986001600160a01b03909616958a565b60346020526000908152604090205481565b6007546001600160a01b03163314158061059d575060085442115b6105a657600080fd5b600154336000908152603660205260409020546105c89163ffffffff61146216565b33600081815260366020526040808220939093556001549251919280156108fc02929091818181858888f19350505050158015610609573d6000803e3d6000fd5b50565b600454600554600654600754600854600954600a54600b54600d54600e546001600160401b03909916986001600160a01b03909616958a565b601054601154601254601354601454601554601654601754601954601a546001600160401b03909916986001600160a01b03909616958a565b601c54601d54601e54601f546020546021546022546023546025546026546001600160401b03909916986001600160a01b03909616958a565b6001543360009081526036602052604090205410156106e85760405162461bcd60e51b815260040161030490612fab565b60085442101561070a5760405162461bcd60e51b815260040161030490612ebb565b6107126121f1565b61071b82610a19565b905061072561221e565b61072e82610b05565b905061073982610acb565b6107555760405162461bcd60e51b815260040161030490612f8b565b6004546040820151516001600160401b039182169116116107885760405162461bcd60e51b815260040161030490612eab565b60055460408201516020015114806107a95750600654604082015160200151145b6107c55760405162461bcd60e51b815260040161030490612f3b565b60065460408201516020015114156107fa57608081015151156107fa5760405162461bcd60e51b815260040161030490612f9b565b600554604082015160200151141561081c576108178160106114a4565b610827565b6108278160046114a4565b60808101515161086057806040015160c00151816080015160400151146108605760405162461bcd60e51b815260040161030490612edb565b61052081846000610d48565b60366020526000908152604090205481565b6000818152600c602052604081205460ff161561089d57506001610961565b600454600a546000848152600c602090815260409182902082516060808201855260018301805460ff16835285519182019586905261095e976001600160401b03169695929490938582019360029182019284929083019184919082845b8154815260200190600101908083116108fb575050509190925250505081526040805160608101825260038401548152600484015460208281019190915260059094015460ff1681830152918301919091526000888152601b909252902061157e565b90505b919050565b60085442106109875760405162461bcd60e51b815260040161030490612e8b565b6109908161087e565b156109ad5760405162461bcd60e51b815260040161030490612f1b565b6109b682611763565b5050565b60025481565b600154341480156109de575033600090815260366020526040902054155b6109e757600080fd5b33600090815260366020526040902054610a07903463ffffffff610ad716565b33600090815260366020526040902055565b610a216121f1565b506040805180820190915260008152602081019190915290565b610a4361220b565b610a4c82611b59565b63ffffffff16604051908082528060200260200182016040528015610a8b57816020015b610a7861226c565b815260200190600190039081610a705790505b50815260005b815151811015610ac557610aa483611b81565b8251805183908110610ab257fe5b6020908102919091010152600101610a91565b50919050565b60208101515190511490565b600082820183811015610afc5760405162461bcd60e51b815260040161030490612eeb565b90505b92915050565b610b0d61221e565b610b1682611bbe565b8152610b2182611bbe565b6020820152610b2f82611c08565b6040820152610b3d82611bbe565b6060820152610b4b82611ca1565b6080820152610b5982611b59565b63ffffffff16604051908082528060200260200182016040528015610b9857816020015b610b85612293565b815260200190600190039081610b7d5790505b5060a082015260005b8160a0015151811015610bda57610bb783611d6e565b8260a001518281518110610bc757fe5b6020908102919091010152600101610ba1565b50600280826040015161010001518360600151604051602001610bfe929190612d53565b60408051601f1981840301815290829052610c1891612d79565b602060405180830381855afa158015610c35573d6000803e3d6000fd5b5050506040513d601f19601f82011682018060405250610c5891908101906125a7565b8251604051610c6b929190602001612d53565b60408051601f1981840301815290829052610c8591612d79565b602060405180830381855afa158015610ca2573d6000803e3d6000fd5b5050506040513d601f19601f82011682018060405250610cc591908101906125a7565b60c08201819052602080830151604051600293610ce493909101612d53565b60408051601f1981840301815290829052610cfe91612d79565b602060405180830381855afa158015610d1b573d6000803e3d6000fd5b5050506040513d601f19601f82011682018060405250610d3e91908101906125a7565b60e0820152919050565b600454601c805467ffffffffffffffff19166001600160401b03909216919091179055600554601d55600654601e55600754601f80546001600160a01b0319166001600160a01b03909216919091179055600854602055600954602155600a54602255600b54602355600d54602555600e5460265560005b602554811015610e3e576000818152600f6020908152604080832060279092529091208154815460ff191660ff9091161781556001808301548183015560028084015490830155600380840154908301556004928301549190920180546001600160801b0319166001600160801b0390921691909117905501610dc0565b5060005b602354811015610ee0576000818152600c6020908152604080832060249092529091208154815460ff918216151560ff199182161783556001808501805491850180549093169190931617815560028085019080850190610ea690829084906122b4565b50505060038281015490820155600480830154908201556005918201549101805460ff191660ff9092169190911790555050600101610e42565b5060065460408401516020015114156110e3576010546028805467ffffffffffffffff19166001600160401b03909216919091179055601154602955601254602a55601354602b80546001600160a01b0319166001600160a01b03909216919091179055601454602c55601554602d55601654602e55601754602f55601954603155601a5460325560005b603154811015610fea576000818152601b6020908152604080832060339092529091208154815460ff191660ff9091161781556001808301548183015560028084015490830155600380840154908301556004928301549290910180546001600160801b0319166001600160801b039093169290921790915501610f6b565b506004546010805467ffffffffffffffff19166001600160401b03909216919091179055600554601155600654601255600754601380546001600160a01b0319166001600160a01b03909216919091179055600854601455600954601555600a54601655600b54601755600d54601955600e54601a5560005b6019548110156110e1576000818152600f60209081526040808320601b9092529091208154815460ff191660ff9091161781556001808301548183015560028084015490830155600380840154908301556004928301549190920180546001600160801b0319166001600160801b0390921691909117905501611063565b505b6000805b846080015160200151518110156111195761110f856080015160200151828151811061043457fe5b91506001016110e7565b5060408051610140810182528582018051516001600160401b03168252805160209081015190830152518201519181019190915233606082015260808101836111755760025461117090429063ffffffff610ad716565b611178565b60005b815284516020808701919091208183015260e08781015160408085019190915260a0808a0151516060808701919091526080808c0151860151518188015295820188905286516004805467ffffffffffffffff19166001600160401b03909216919091179055938601516005559085015160065591840151600780546001600160a01b0319166001600160a01b039092169190911790559183015160085582015160095560c0820151600a55810151600b55610100810151600d556101200151600e5560005b84608001516020015151811015611317576040518060400160405280866080015160200151838151811061126e57fe5b6020026020010151602001518152602001866080015160200151838151811061129357fe5b6020908102919091018101516040908101516001600160801b039081169093526000858152600f835281902084518051825460ff191660ff90911617825580840151516001808401919091559201518051600283015583015160038201559390910151600490930180546001600160801b031916939092169290921790550161123e565b5060005b8460a00151518110156113d4578460a00151818151811061133857fe5b6020908102919091018101516000838152600c8352604090208151815490151560ff1991821617825582840151805160018401805460ff929092169190931617825593840151805193949293600280860191611396918391906122ef565b5050506040918201518051600383015560208101516004830155909101516005909101805460ff191660ff909216919091179055505060010161131b565b5060c084015160408086018051516001600160401b0390811660009081526034602081815285832096909655925160e0810151905183168252603586528482205560045490911680825291909352918190205490517f5d45c22c440038a3aaf9f8134e7aa1fa59aa2a7fa411d7e818d7701c63827d7e9161145491612de2565b60405180910390a250505050565b6000610afc83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611d9d565b80600901548260a0015151146114cc5760405162461bcd60e51b815260040161030490612f7b565b6000805b8360a0015151811015611536578360a0015181815181106114ed57fe5b60200260200101516000015161152e576000818152600b8401602052604090206004015461152b9083906001600160801b031663ffffffff610ad716565b91505b6001016114d0565b506115606003611554600285600a0154611dc990919063ffffffff16565b9063ffffffff611e0316565b81116105205760405162461bcd60e51b815260040161030490612e9b565b6000606060008561159188600201611e45565b6040516115a693929190600090602001612d8c565b60408051601f19818403018152919052845190915060ff1661168d57600080828060200190516115d991908101906125c5565b60018701549193509150158015906116835750600354600186015460208881015151805191015160405163ebd1b95160e01b81526001600160a01b039094169363ebd1b95193611633939092909188908890600401612df0565b60206040518083038186803b15801561164b57600080fd5b505afa15801561165f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506116839190810190612589565b935050505061175b565b600283015460038401546040516116a8929190602001612d53565b6040516020818303038152906040528051906020012060001c6001600160a01b031660018280519060200120601b87604001516040015160ff16106116ee5760006116f1565b601b5b60408089015180820151815160209283015184516000815290930193849052611721959490910192909190612e3c565b6020604051602081039080840390855afa158015611743573d6000803e3d6000fd5b505050602060405103516001600160a01b0316149150505b949350505050565b6001546007546001600160a01b03166000908152603660205260409020546117909163ffffffff61146216565b6007546001600160a01b03908116600090815260366020526040808220939093556001549251918416926002900480156108fc02929091818181858888f193505050501580156117e4573d6000803e3d6000fd5b50600060019054906101000a90046001600160a01b03166001600160a01b03166108fc60026001548161181357fe5b04600154039081150290604051600060405180830381858888f19350505050158015611843573d6000803e3d6000fd5b50600480546001600160401b039081166000908152603460208181526040808420849055855485168452603582528084208490559454909316808352925282902054915190917f4e9ddd5df7d5ac983348809fe8a0617e2e53415abf6f504c73ee2b2b22076ef6916118b59190612de2565b60405180910390a2600554601d54146119c1576028546010805467ffffffffffffffff19166001600160401b03909216919091179055602954601155602a54601255602b54601380546001600160a01b0319166001600160a01b03909216919091179055602c54601455602d54601555602e54601655602f54601755603154601955603254601a5560005b6019548110156119bf576000818152603360209081526040808320601b9092529091208154815460ff191660ff9091161781556001808301548183015560028084015490830155600380840154908301556004928301549290910180546001600160801b0319166001600160801b039093169290921790915501611940565b505b601c546004805467ffffffffffffffff19166001600160401b03909216919091179055601d54600555601e54600655601f54600780546001600160a01b0319166001600160a01b03909216919091179055602054600855602154600955602254600a55602354600b55602554600d55602654600e5560005b600d54811015611ab7576000818152602760209081526040808320600f9092529091208154815460ff191660ff9091161781556001808301548183015560028084015490830155600380840154908301556004928301549190920180546001600160801b0319166001600160801b0390921691909117905501611a39565b5060005b600b548110156109b6576000818152602460209081526040808320600c9092529091208154815460ff918216151560ff199182161783556001808501805491850180549093169190931617815560028085019080850190611b1f90829084906122b4565b50505060038281015490820155600480830154908201556005918201549101805460ff191660ff9092169190911790555050600101611abb565b6000611b6482611ea4565b61ffff1690506010611b7583611ea4565b61ffff16901b17919050565b611b8961226c565b611b9282611eca565b8152611b9d82611f4b565b6020820152611bab82611fb4565b6001600160801b03166040820152919050565b6000816020808260000151018260200151511015611bee5760405162461bcd60e51b815260040161030490612ecb565b602080850151945190940190930151815190930190525090565b611c1061231d565b611c218260d063ffffffff611fe616565b610100820152611c3082611ffb565b6001600160401b03168152611c4482611bbe565b6020820152611c5282611bbe565b6040820152611c6082611bbe565b6060820152611c6e82611bbe565b6080820152611c7c82611ffb565b6001600160401b031660a0820152611c9382611bbe565b60c0820152610d3e82611bbe565b611ca9612369565b611cb282612027565b60ff1615808252610961578151611cc883611b59565b63ffffffff16604051908082528060200260200182016040528015611d0757816020015b611cf461226c565b815260200190600190039081611cec5790505b50602083015260005b826020015151811015611d4957611d2684611b81565b83602001518281518110611d3657fe5b6020908102919091010152600101611d10565b508251818452611d618483830363ffffffff611fe616565b6040840152835250919050565b611d76612293565b611d7f82612027565b60ff161580825261096157611d938261207e565b6020820152919050565b60008184841115611dc15760405162461bcd60e51b81526004016103049190612e7a565b505050900390565b600082611dd857506000610aff565b82820282848281611de557fe5b0414610afc5760405162461bcd60e51b815260040161030490612f4b565b6000610afc83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506120d3565b602081811b67ffffffff000000001663ffffffff9290911c9190911617601081811b67ffff0000ffff00001665ffff0000ffff9290911c9190911617600881811b67ff00ff00ff00ff001666ff00ff00ff00ff9290911c919091161790565b6000611eaf82612027565b60ff1690506008611ebf83612027565b60ff16901b17919050565b6060611ed582611b59565b63ffffffff166040519080825280601f01601f191660200182016040528015611f05576020820181803883390190505b50905060005b8151811015610ac557611f1d83612027565b60f81b828281518110611f2c57fe5b60200101906001600160f81b031916908160001a905350600101611f0b565b611f5361238f565b611f5c82612027565b60ff16808252611f7957611f6f8261210a565b6020820152610961565b806000015160ff1660011415611f9c57611f9282612122565b6040820152610961565b60405162461bcd60e51b815260040161030490612f5b565b6000611fbf82611ffb565b6001600160401b031690506040611fd583611ffb565b6001600160401b0316901b17919050565b6000610afc836020015184600001518461213e565b600061200682611b59565b63ffffffff169050602061201983611b59565b63ffffffff16901b17919050565b60008160018082600001510182602001515110156120575760405162461bcd60e51b815260040161030490612ecb565b602084015184518151811061206857fe5b0160200151825190910190915260f81c92915050565b6120866123b9565b61208f82612027565b60ff168082526120a257611f6f82612160565b806000015160ff16600114156120bb57611f9282612188565b60405162461bcd60e51b815260040161030490612fbb565b600081836120f45760405162461bcd60e51b81526004016103049190612e7a565b50600083858161210057fe5b0495945050505050565b6121126123e3565b61211b82611bbe565b8152919050565b61212a6123f5565b612133826121bf565b8152611d93826121bf565b600061214861240f565b6020818486602089010160025afa5051949350505050565b61216861242d565b61217182611bbe565b81515261217d82611bbe565b815160200152919050565b612190612440565b61219982611bbe565b81526121a482611bbe565b60208201526121b282612027565b60ff166040820152919050565b60006121ca82611fb4565b6001600160801b0316905060806121e083611fb4565b6001600160801b0316901b17919050565b604051806040016040528060008152602001606081525090565b6040518060200160405280606081525090565b60408051610100810182526000808252602082015290810161223e61231d565b815260006020820152604001612252612369565b815260606020820181905260006040830181905291015290565b60405180606001604052806060815260200161228661238f565b8152600060209091015290565b60405180604001604052806000151581526020016122af6123b9565b905290565b82600281019282156122df579182015b828111156122df5782548255916001019190600101906122c4565b506122eb929150612460565b5090565b82600281019282156122df579160200282015b828111156122df578251825591602001919060010190612302565b6040805161012081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e0810182905261010081019190915290565b604051806060016040528060001515815260200160608152602001600080191681525090565b6040518060600160405280600060ff1681526020016123ac6123e3565b81526020016122af6123f5565b6040518060600160405280600060ff1681526020016123d661242d565b81526020016122af612440565b60408051602081019091526000815290565b604051806040016040528060008152602001600081525090565b60405180602001604052806001906020820280388339509192915050565b60405180602001604052806122af61247d565b604080516060810182526000808252602082018190529181019190915290565b61247a91905b808211156122eb5760008155600101612466565b90565b60405180604001604052806002906020820280388339509192915050565b8035610aff8161316c565b8051610aff81613180565b8051610aff81613189565b8051610aff81613192565b600082601f8301126124d857600080fd5b81356124eb6124e682613086565b613060565b9150808252602083016020830185838301111561250757600080fd5b612512838284613104565b50505092915050565b8035610aff81613189565b8035610aff8161319b565b60006020828403121561254357600080fd5b600061175b848461249b565b6000806040838503121561256257600080fd5b600061256e858561249b565b925050602061257f8582860161251b565b9150509250929050565b60006020828403121561259b57600080fd5b600061175b84846124a6565b6000602082840312156125b957600080fd5b600061175b84846124b1565b600080604083850312156125d857600080fd5b60006125e485856124b1565b925050602061257f858286016124bc565b60006020828403121561260757600080fd5b81356001600160401b0381111561261d57600080fd5b61175b848285016124c7565b60006020828403121561263b57600080fd5b600061175b848461251b565b60006020828403121561265957600080fd5b600061175b8484612526565b61266e816130ba565b82525050565b61266e816130c5565b61266e612689826130ca565b61247a565b61266e8161247a565b61266e6126898261247a565b61266e816130d9565b60006126b7826130ad565b6126c18185610961565b93506126d1818560208601613110565b9290920192915050565b60006126e6826130ad565b6126f081856130b1565b9350612700818560208601613110565b61270981613156565b9093019392505050565b6000612720601a836130b1565b7f4c6f636b20706572696f6420616c726561647920706173736564000000000000815260200192915050565b60006127596037836130b1565b7f4e6561724272696467653a204c657373207468616e20322f3320766f7465642081527f62792074686520626c6f636b206166746572206e657874000000000000000000602082015260400192915050565b60006127b8602c836130b1565b7f4e6561724272696467653a20486569676874206f662074686520626c6f636b2081526b1a5cc81b9bdd081d985b1a5960a21b602082015260400192915050565b60006128066022836130b1565b7f5761697420756e74696c206c61737420626c6f636b206265636f6d652076616c8152611a5960f21b602082015260400192915050565b600061284a6013836130b1565b72426f7273683a204f7574206f662072616e676560681b815260200192915050565b60006128796030836130b1565b7f4e6561724272696467653a2048617368206f6620626c6f636b2070726f64756381526f0cae4e640c8de40dcdee840dac2e8c6d60831b602082015260400192915050565b60006128cb601b836130b1565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815260200192915050565b6000612904601f836130b1565b7f4e6561724272696467653a20616c726561647920696e697469616c697a656400815260200192915050565b600061293d6047836130b1565b7f4e6561724272696467653a206f6e6c7920696e697469616c2076616c6964617481527f6f72732073686f756c6420626520706173736564206173207365636f6e6420616020820152661c99dd5b595b9d60ca1b604082015260600192915050565b60006129ac601f836130b1565b7f43616e2774206368616c6c656e67652076616c6964207369676e617475726500815260200192915050565b60006129e56033836130b1565b7f4e6561724272696467653a2076616c696461746f7273206e65656420746f206281527219481a5b9a5d1a585b1a5e995908199a5c9cdd606a1b602082015260400192915050565b6000612a3a602e836130b1565b7f4e6561724272696467653a2045706f6368206964206f662074686520626c6f6381526d1ac81a5cc81b9bdd081d985b1a5960921b602082015260400192915050565b6000612a8a6021836130b1565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f8152607760f81b602082015260400192915050565b6000612acd6040836130b1565b7f4e6561724272696467653a204f6e6c79204544323535313920616e642053454381527f503235364b31207075626c6963206b6579732061726520737570706f72746564602082015260400192915050565b6000612b2c6046836130b1565b7f4e6561724272696467653a206f6e6c79206c6967687420636c69656e7420626c81527f6f636b2073686f756c642062652070617373656420617320666972737420617260208201526519dd5b595b9d60d21b604082015260600192915050565b6000612b9a603a836130b1565b7f4e6561724272696467653a206e756d626572206f66204250732073686f756c6481527f206d61746368206e756d626572206f6620617070726f76616c73000000000000602082015260400192915050565b6000612bf96034836130b1565b7f4e6561724272696467653a206f6e6c79206c6967687420636c69656e7420626c8152731bd8dac81cda1bdd5b19081899481c185cdcd95960621b602082015260400192915050565b6000612c4f602b836130b1565b7f4e6561724272696467653a204e657874206e6578745f6270732073686f756c6481526a206e6f206265204e6f6e6560a81b602082015260400192915050565b6000612c9c6015836130b1565b74084c2d8c2dcc6ca40d2e640dcdee840cadcdeeaced605b1b815260200192915050565b6000612ccd603f836130b1565b7f4e6561724272696467653a204f6e6c79204544323535313920616e642053454381527f503235364b31207369676e6174757265732061726520737570706f7274656400602082015260400192915050565b61266e816130f2565b61266e612d34826130f2565b613140565b61266e816130fe565b61266e612d4e826130fe565b61314b565b6000612d5f8285612697565b602082019150612d6f8284612697565b5060200192915050565b6000612d8582846126ac565b9392505050565b6000612d988287612d42565b600182019150612da88286612697565b602082019150612db88285612d28565b600882019150612dc8828461267d565b50601701949350505050565b60208101610aff8284612674565b60208101610aff828461268e565b60a08101612dfe828861268e565b612e0b602083018761268e565b612e18604083018661268e565b612e25606083018561268e565b612e3260808301846126a3565b9695505050505050565b60808101612e4a828761268e565b612e576020830186612d39565b612e64604083018561268e565b612e71606083018461268e565b95945050505050565b60208082528101610afc81846126db565b6020808252810161095e81612713565b6020808252810161095e8161274c565b6020808252810161095e816127ab565b6020808252810161095e816127f9565b6020808252810161095e8161283d565b6020808252810161095e8161286c565b6020808252810161095e816128be565b6020808252810161095e816128f7565b6020808252810161095e81612930565b6020808252810161095e8161299f565b6020808252810161095e816129d8565b6020808252810161095e81612a2d565b6020808252810161095e81612a7d565b6020808252810161095e81612ac0565b6020808252810161095e81612b1f565b6020808252810161095e81612b8d565b6020808252810161095e81612bec565b6020808252810161095e81612c42565b6020808252810161095e81612c8f565b6020808252810161095e81612cc0565b6101408101612fda828d612d1f565b612fe7602083018c61268e565b612ff4604083018b61268e565b613001606083018a612665565b61300e608083018961268e565b61301b60a083018861268e565b61302860c083018761268e565b61303560e083018661268e565b61304361010083018561268e565b61305161012083018461268e565b9b9a5050505050505050505050565b6040518181016001600160401b038111828210171561307e57600080fd5b604052919050565b60006001600160401b0382111561309c57600080fd5b506020601f91909101601f19160190565b5190565b90815260200190565b600061095e826130e6565b151590565b68ffffffffffffffffff191690565b6001600160b81b03191690565b6001600160a01b031690565b6001600160401b031690565b60ff1690565b82818337506000910152565b60005b8381101561312b578181015183820152602001613113565b8381111561313a576000848401525b50505050565b600061095e82613160565b600061095e82613166565b601f01601f191690565b60c01b90565b60f81b90565b613175816130ba565b811461060957600080fd5b613175816130c5565b6131758161247a565b613175816130d9565b613175816130f256fea365627a7a7231582010992b2b8189fe2f6d521e0b6518da0fc79788dca03ff6c5f038cbce620629bf6c6578706572696d656e74616cf564736f6c63430005100040 \ No newline at end of file diff --git a/libs-sol/nearbridge/dist/NearBridge.full.sol b/libs-sol/nearbridge/dist/NearBridge.full.sol index 9780317eb..00cd9c627 100644 --- a/libs-sol/nearbridge/dist/NearBridge.full.sol +++ b/libs-sol/nearbridge/dist/NearBridge.full.sol @@ -1854,6 +1854,7 @@ contract NearBridge is INearBridge { State public last; State public prev; State public backup; + State public backup_prev; mapping(uint64 => bytes32) public blockHashes; mapping(uint64 => bytes32) public blockMerkleRoots; mapping(address => uint256) public balanceOf; @@ -1872,6 +1873,7 @@ contract NearBridge is INearBridge { edwards = ed; lock_eth_amount = l_eth; lock_duration = l_dur; + burner = address(0); } function deposit() public payable { @@ -1923,6 +1925,14 @@ contract NearBridge is INearBridge { blockHashes[last.height] ); + if (backup.epochId != last.epochId) { + // Revert first block in epoch, should also revert prev + prev = backup_prev; + for (uint i = 0; i < prev.next_bps_length; i++) { + prev.next_bps[i] = backup_prev.next_bps[i]; + } + } + last = backup; for (uint i = 0; i < last.next_bps_length; i++) { last.next_bps[i] = backup.next_bps[i]; @@ -2035,6 +2045,11 @@ contract NearBridge is INearBridge { // If next epoch if (nearBlock.inner_lite.epoch_id == last.nextEpochId) { + backup_prev = prev; + for (uint i = 0; i < backup_prev.next_bps_length; i++) { + backup_prev.next_bps[i] = prev.next_bps[i]; + } + prev = last; for (uint i = 0; i < prev.next_bps_length; i++) { prev.next_bps[i] = last.next_bps[i];