Skip to content

Commit

Permalink
Fix invalid proof error in ci e2e (#227)
Browse files Browse the repository at this point in the history
* success near prove from local e2e, now get output from ci e2e

* fix invalid proof

Co-authored-by: Maksym Zavershynskyi <[email protected]>
  • Loading branch information
ailisp and MaksymZavershynskyi authored Jul 29, 2020
1 parent c5de0dc commit 5f0caaf
Show file tree
Hide file tree
Showing 5 changed files with 173 additions and 2 deletions.
20 changes: 20 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,33 @@ 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 -
rustup default stable
rustup target add wasm32-unknown-unknown
ci/e2e.sh

artifact_paths:
- "*.log"
timeout: 40

agents:
Expand Down
5 changes: 3 additions & 2 deletions environment/lib/borsh/nearProof.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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),

Expand Down
12 changes: 12 additions & 0 deletions libs-sol/nearprover/test/NearProver.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
69 changes: 69 additions & 0 deletions libs-sol/nearprover/test/proof5.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
69 changes: 69 additions & 0 deletions libs-sol/nearprover/test/proof6.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}

0 comments on commit 5f0caaf

Please sign in to comment.