diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index f196cf923..9fb74bdec 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -116,6 +116,24 @@ steps: export PATH=$$GOPATH/bin:$$GOROOT/bin:$$PATH npm i -g ganache-cli git submodule update --init --recursive + + # 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 + 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 + cd environment/vendor/ethashproof ./build.sh cd - @@ -123,6 +141,8 @@ steps: rustup target add wasm32-unknown-unknown ci/e2e.sh + artifact_paths: + - "*.log" timeout: 40 agents: diff --git a/environment/lib/borsh/nearProof.js b/environment/lib/borsh/nearProof.js index cca97dc0f..baa1fbfe6 100644 --- a/environment/lib/borsh/nearProof.js +++ b/environment/lib/borsh/nearProof.js @@ -1,7 +1,7 @@ const Web3 = require('web3'); const bs58 = require('bs58'); -function borshifyOutcomeProof (proof) { +function borshifyOutcomeProof(proof) { const statusToBuffer = status => { console.log(status.SuccessValue); if ('SuccessValue' in status) { @@ -61,7 +61,8 @@ function borshifyOutcomeProof (proof) { bs58.decode(proof.block_header_lite.inner_lite.next_epoch_id), bs58.decode(proof.block_header_lite.inner_lite.prev_state_root), bs58.decode(proof.block_header_lite.inner_lite.outcome_root), - Web3.utils.toBN(proof.block_header_lite.inner_lite.timestamp).toBuffer('le', 8), + // for backward compatible in tests with old dumps + Web3.utils.toBN(proof.block_header_lite.inner_lite.timestamp_nanosec || proof.block_header_lite.inner_lite.timestamp).toBuffer('le', 8), bs58.decode(proof.block_header_lite.inner_lite.next_bp_hash), bs58.decode(proof.block_header_lite.inner_lite.block_merkle_root), diff --git a/libs-sol/nearprover/test/NearProver.js b/libs-sol/nearprover/test/NearProver.js index a8e213e77..226193aa9 100644 --- a/libs-sol/nearprover/test/NearProver.js +++ b/libs-sol/nearprover/test/NearProver.js @@ -25,6 +25,18 @@ contract('NearProver', function ([_, addr1]) { expect(await this.prover.proveOutcome(proof4, 5563)).to.be.true; }); + it('should be ok 2', async function () { + const proof5 = require('./proof5.json'); + await this.bridge.setBlockMerkleRoot(384, '0xa9cd8eb4dd92ba5f2fef47d68e1d73ac8c57047959f6f8a2dcc664419e74e4b8'); + expect(await this.prover.proveOutcome(borshifyOutcomeProof(proof5), 384)).to.be.true; + }); + + it('should be ok 3', async function () { + const proof6 = require('./proof6.json'); + await this.bridge.setBlockMerkleRoot(377, '0xcc3954a51b7c1a86861df8809f79c2bf839741e3e380e28360b8b3970a5d90bd'); + expect(await this.prover.proveOutcome(borshifyOutcomeProof(proof6), 377)).to.be.true; + }); + if (process.env['NEAR_PROOFS_DIR']) { it('should able to verify proofs from dump', async function () { this.timeout(0); diff --git a/libs-sol/nearprover/test/proof5.json b/libs-sol/nearprover/test/proof5.json new file mode 100644 index 000000000..63be48630 --- /dev/null +++ b/libs-sol/nearprover/test/proof5.json @@ -0,0 +1,69 @@ +{ + "outcome_proof": { + "proof": [], + "block_hash": "836bGij79WLpoGTJfMS7wHyeNDzcrR6Fjcnv7k5s35Zs", + "id": "C7bVNak4z9JQgXrQLS5ZAotqyJHCfD8ntgHorMaLVCFN", + "outcome": { + "logs": [], + "receipt_ids": [ + "Bt88L3Zw5HiKd21VQJHBtPMqNk62CEbomD6zzJRQrFrG" + ], + "gas_burnt": 4328442536275, + "tokens_burnt": "4328442536275000000000", + "executor_id": "nearfuntoken", + "status": { + "SuccessValue": "AQAAAAAAAAAAAAAAAAAAAOyL4aVjA2QpLlbQESno7oqVeNfY" + } + } + }, + "outcome_root_proof": [], + "block_header_lite": { + "prev_block_hash": "3Ygc9DBL6L3eZkfqjC39yoqpLdtrFa73v1Pij8WaLMXP", + "inner_rest_hash": "CDu5ma6FyugzXNJFgZLvrqJ6QchmnEsuC9ybjx8uf4Ve", + "inner_lite": { + "height": 382, + "epoch_id": "JAHuDz5JnQ8AR2bsX8iYjRMR6GUh66qsa4ikUCkmJVKF", + "next_epoch_id": "3eBVUeAYLVNQCQGiQLX7m4VSdYr8L17m5ZtMoHLtsJTi", + "prev_state_root": "GctVMceieDngovPKdnGwza1pDjX3L6c4XB9Gg72QdtUr", + "outcome_root": "9gu8iYjW89gw9HC2Y3gh74mt8h1i6WXkxGyHyGRQnXgD", + "timestamp": 1595963616139902200, + "timestamp_nanosec": "1595963616139902322", + "next_bp_hash": "HV5FPYQ9sPbB6MrtKcpjyiTfpLRMRqH8YLL2VQ9FrGU4", + "block_merkle_root": "CxbeXAcVWyygiQzojvHER832pxrZ9KLcSZNF7rLnkN1T" + } + }, + "block_proof": [ + { + "hash": "3fzvjNT4ZHrMwXg5nweVoEsLrRfHwXcb7Q5bEKpsfEHo", + "direction": "Right" + }, + { + "hash": "5vMJodboQKRgrtFb2pGaKDfHC5kAPTxKtnHoxVNm2oAk", + "direction": "Left" + }, + { + "hash": "7xgpkyrDo61vUTzZz2jjF4HogGrUsaTG4fo26jUj3p83", + "direction": "Left" + }, + { + "hash": "8nTpPqjbLKadmGszN4WffFscYAfEYPq796nprPNXUAjn", + "direction": "Left" + }, + { + "hash": "G5XQf9jzSuwmHGqJfoapDjZBkeQ7mBH7vS8dGfusRQqG", + "direction": "Left" + }, + { + "hash": "HdNY8yxMyZM2nxxV3XF5FbbiR6J5AoA2CxNbyYWEe4aG", + "direction": "Left" + }, + { + "hash": "76idRjn59X54cnSKUxqUtRygeqzaxDsCE7frJ57avbT9", + "direction": "Left" + }, + { + "hash": "ArxmcYkRzQaKEPGTFE4mySbzPu6qPQ7X5gtbNEiWtKb6", + "direction": "Left" + } + ] +} \ No newline at end of file diff --git a/libs-sol/nearprover/test/proof6.json b/libs-sol/nearprover/test/proof6.json new file mode 100644 index 000000000..e47f9c3be --- /dev/null +++ b/libs-sol/nearprover/test/proof6.json @@ -0,0 +1,69 @@ +{ + "outcome_proof": { + "proof": [], + "block_hash": "DJ7CrNVFWG9xRUddbDB2N3o1tgFzqh2zL9PyjVgWhTr1", + "id": "7UGbrQMEmhCUS5uSitiqDLBYpnuu13hzxJVDBRMU33JK", + "outcome": { + "logs": [], + "receipt_ids": [ + "2NJvxcFsUmYtfecMe5dAsYbK27efj7gMx5btq6UvWhrh" + ], + "gas_burnt": 4326379475896, + "tokens_burnt": "4326379475896000000000", + "executor_id": "nearfuntoken", + "status": { + "SuccessValue": "AQAAAAAAAAAAAAAAAAAAAOyL4aVjA2QpLlbQESno7oqVeNfY" + } + } + }, + "outcome_root_proof": [], + "block_header_lite": { + "prev_block_hash": "3xGtPdbfL6JbJ2qxf83GVjfuVgjhnUxGryz3RDjo9DGw", + "inner_rest_hash": "C4RVt5Vfp6AJvuM43Q4PaM3RCD9VGoXFCS7Q9DyR4LWF", + "inner_lite": { + "height": 358, + "epoch_id": "G2zVpfirbS8mDpkqhQXvkWfn2BPyJK7AyGtdkbfmmWSC", + "next_epoch_id": "FUJuQchgouiJVgdQmnXb2eXHY2ZwLKc4iJmUTGaZ1CEA", + "prev_state_root": "4Xi5gd345XM3KXmUKL7JB8zuWEzhEnNdt69kq91Fwcxw", + "outcome_root": "9gbMSq8kPPvnrUjPEqMVq6vMSP12scW4vnHY3cn5uXsP", + "timestamp": 1595961718661674000, + "timestamp_nanosec": "1595961718661674000", + "next_bp_hash": "DBqtF8zBxVgR9xpu9uVr3fikjwasUmntV6aruR3u8CYe", + "block_merkle_root": "8BLeevKH5iWxmWyGwKwghFkxG9TxYqucD72BitMvzDZD" + } + }, + "block_proof": [ + { + "hash": "7MHvRCw9YCptNxpcYNvnfnndygQniNsKC2nTgeusArcV", + "direction": "Right" + }, + { + "hash": "7Cyx5oWucX6pz5GRXPEneBCHSezCaG5Zq26nkp8zSbUb", + "direction": "Left" + }, + { + "hash": "AZFaMDqLKEUe5qmzWyaw4CV4z3VMWbtE4BmbJhpRn6jy", + "direction": "Left" + }, + { + "hash": "7Y3YueQZS2X21DocNsQcXXtSxcjEjawxgxd4o6xu9M2E", + "direction": "Right" + }, + { + "hash": "9GoDSqLs53L5KY5KRuJRK8D39MCJvcdD3JzzAwwXR91q", + "direction": "Right" + }, + { + "hash": "DcGqQCdBUkGS8xxarpZSyCiWCKTzLKQtPydkXeBsvQxf", + "direction": "Left" + }, + { + "hash": "9gVqrMoPeTqWFCXxZp8gBDXpsvCdqLiE3V3DjZUXEw2a", + "direction": "Left" + }, + { + "hash": "BqrgC11cz1TKZdX76FRXEhuZLL7NkyXg48PSkxJJh1yM", + "direction": "Left" + } + ] +} \ No newline at end of file