Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI fix: verify-near-headers, verify-near-proofs #898

Merged
merged 18 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
name: E2E tests
jobs:
test:
runs-on: self-hosted
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
Expand All @@ -30,8 +30,10 @@ jobs:

name: ${{ matrix.job-name }}
steps:
- name: Install LFS
run: apt-get install git-lfs
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "16.x"

- name: Clone the repository
uses: actions/checkout@v3
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ coverage
coverage.json
node_modules
target
testdata
vendor
.history
.DS_Store
Expand Down
5 changes: 0 additions & 5 deletions contracts/eth/ci/test_verify_near_headers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ set -euo pipefail
CI_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
ROOT_DIR=$CI_DIR/..

mkdir -p $ROOT_DIR/testdata
cd $ROOT_DIR/testdata
curl https://s3-us-west-1.amazonaws.com/rainbow-bridge.nearprotocol.com/test-data/near-headers.tar.gz -o near-headers.tar.gz
tar zxf near-headers.tar.gz

cd $ROOT_DIR
yarn

Expand Down
5 changes: 0 additions & 5 deletions contracts/eth/ci/test_verify_near_proofs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ set -euo pipefail
CI_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
ROOT_DIR=$CI_DIR/..

mkdir -p $ROOT_DIR/testdata
cd $ROOT_DIR/testdata
curl https://s3-us-west-1.amazonaws.com/rainbow-bridge.nearprotocol.com/test-data/near-proofs.tar.gz -o near-proofs.tar.gz
tar zxf near-proofs.tar.gz

cd $ROOT_DIR
yarn

Expand Down
44 changes: 0 additions & 44 deletions contracts/eth/nearbridge/test/181.json

This file was deleted.

38 changes: 0 additions & 38 deletions contracts/eth/nearbridge/test/368.json

This file was deleted.

1 change: 0 additions & 1 deletion contracts/eth/nearbridge/test/369.json

This file was deleted.

37 changes: 16 additions & 21 deletions contracts/eth/nearbridge/test/NearBridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,42 +24,37 @@ beforeEach(async function () {
});

it('should be ok', async function () {
// Skip until tests are upgraded having blocks after nearcore 1.23.0
this.skip();
const block91425093 = borshify(require('./block_91425093.json'));
const block91468293 = borshify(require('./block_91468293.json'));
const block91511493 = borshify(require('./block_91511493.json'));

const block120998 = borshify(require('./block_120998.json'));
const block121498 = borshify(require('./block_121498.json'));
const block121998 = borshify(require('./block_121998.json'));

// We should use previous epoch's next_bps to initWithBlock with block_120998, but they happens to be same
await NearBridge.initWithValidators(borshifyInitialValidators(require('./block_120998.json').next_bps));
await NearBridge.initWithBlock(block120998);
expect(await NearBridge.blockHashes(120998)).to.be.equal(
'0x1a7a07b5eee1f4d8d7e47864d533143972f858464bacdc698774d167fb1b40e6',
// We should use previous epoch's next_bps to initWithBlock with block_91425093, but they happens to be same
await NearBridge.initWithValidators(borshifyInitialValidators(require('./block_91425093.json').next_bps));
await NearBridge.initWithBlock(block91425093);
expect(await NearBridge.blockHashes(91425093)).to.be.equal(
'0x25d3099add104e19078cc02f5e13eff79386cdde07a841b59d9a078e1f8e6384',
);

await NearBridge.addLightClientBlock(block121498);
await NearBridge.addLightClientBlock(block91468293);
expect(await NearBridge.checkBlockProducerSignatureInHead(0)).to.be.true;

await expect(NearBridge.addLightClientBlock(block121998)).to.be.revertedWith('Epoch id of the block is not valid');
await expect(NearBridge.addLightClientBlock(block91511493)).to.be.revertedWith('Epoch id of the block is not valid');
await increaseTime(3600);
expect(await NearBridge.blockHashes(121498)).to.be.equal(
'0x508307e7af9bdbb297afa7af0541130eb32f0f028151319f5a4f7ae68b0ecc56',
expect(await NearBridge.blockHashes(91468293)).to.be.equal(
'0xee41bd80c7f770caefb4788876e1c027871e42a333d6aabf894a6ce38ade8d33',
);

await NearBridge.addLightClientBlock(block121998);
expect(await NearBridge.checkBlockProducerSignatureInHead(0)).to.be.true;
await NearBridge.addLightClientBlock(block91511493);
expect(await NearBridge.checkBlockProducerSignatureInHead(1)).to.be.true;

await increaseTime(3600);
expect(await NearBridge.blockHashes(121998)).to.be.equal(
'0x2358c4881bbd111d2e4352b6a7e6c7595fb39d3c9897d3c624006be1ef809abf',
expect(await NearBridge.blockHashes(91511493)).to.be.equal(
'0x0552d0022ce2a9c83d96f11126090c9fe6b866198be715228f95ad700d8fb19c',
);
});

if (process.env.NEAR_HEADERS_DIR) {
it('ok with many block headers', async function () {
// Skip until tests are upgraded having blocks after nearcore 1.23.0
this.skip();

this.timeout(0);
const blockFiles = await fs.readdir(process.env.NEAR_HEADERS_DIR);
Expand Down
100 changes: 46 additions & 54 deletions contracts/eth/nearbridge/test/NearBridge2.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,32 +43,29 @@ it('should be ok', async function () {

});

it('2020-09-09 Example', async function () {
// Skip until tests are upgraded having blocks after nearcore 1.23.0
this.skip();

const block_15178713 = borshify(require('./block_15178713.json'));
const block_15178760 = borshify(require('./block_15178760.json'));
const block_15204402 = borshify(require('./block_15204402.json'));
const block_15248583 = borshify(require('./block_15248583.json'));
olga24912 marked this conversation as resolved.
Show resolved Hide resolved

await NearBridge.initWithValidators(borshifyInitialValidators(require('./init_validators_15178713.json')));
await NearBridge.initWithBlock(block_15178713);
it('2023-05-09 Example', async function () {
const block_91425093 = borshify(require('./block_91425093.json'));
const block_91468293 = borshify(require('./block_91468293.json'));
const block_91511493 = borshify(require('./block_91511493.json'));
const block_91522568 = borshify(require('./block_91522568.json'));

await NearBridge.initWithValidators(borshifyInitialValidators(require('./init_validators_91425093.json')));
await NearBridge.initWithBlock(block_91425093);
await increaseTime(3600);
await NearBridge.addLightClientBlock(block_15178760);
await NearBridge.addLightClientBlock(block_91468293);
await increaseTime(3600);
await NearBridge.addLightClientBlock(block_15204402);
await NearBridge.addLightClientBlock(block_91511493);
await increaseTime(3600);
await NearBridge.addLightClientBlock(block_15248583);
await NearBridge.addLightClientBlock(block_91522568);
});

it('Add second block in first epoch should be verifiable', async function () {
// Get "initial validators" that will produce block 304
const block244 = require('./244.json');
const block244 = require('./block_244.json');
const initialValidators = block244.next_bps;

const block304 = require('./304.json');
const block308 = require('./308.json');
const block304 = require('./block_304.json');
const block308 = require('./block_308.json');

await NearBridge.initWithValidators(borshifyInitialValidators(initialValidators));
await NearBridge.initWithBlock(borshify(block304));
Expand All @@ -87,68 +84,63 @@ it('Add second block in first epoch should be verifiable', async function () {
});

it('Test adding blocks in new epoch when bps change', async function () {
// Skip until tests are upgraded having blocks after nearcore 1.23.0
this.skip();

const block181 = require('./181.json');
const block244 = require('./244.json');
const block304 = require('./304.json');
const block308 = require('./308.json');
const block368 = require('./368.json');
const block369 = require('./369.json');
const block126313429 = require('./block_126313429.json');
const block126315547 = require('./block_126315547.json');
const block126315744 = require('./block_126315744.json');
const block126315811 = require('./block_126315811.json');
const block126315892 = require('./block_126315892.json');
const block126315927 = require('./block_126315927.json');

await NearBridge.initWithValidators(borshifyInitialValidators(block181.next_bps));
await NearBridge.initWithBlock(borshify(block244));
await NearBridge.blockHashes(244);
await NearBridge.initWithValidators(borshifyInitialValidators(block126313429.next_bps));
await NearBridge.initWithBlock(borshify(block126315547));
await NearBridge.blockHashes(126315547);

await increaseTime(3600);

await NearBridge.addLightClientBlock(borshify(block304));
await NearBridge.blockHashes(304);
await NearBridge.addLightClientBlock(borshify(block126315744));
await NearBridge.blockHashes(126315744);

await increaseTime(3600);

await NearBridge.addLightClientBlock(borshify(block308));
await NearBridge.blockHashes(308);
await NearBridge.addLightClientBlock(borshify(block126315811));
await NearBridge.blockHashes(126315811);

await increaseTime(3600);

await NearBridge.addLightClientBlock(borshify(block368));
await NearBridge.blockHashes(368);
await NearBridge.addLightClientBlock(borshify(block126315892));
await NearBridge.blockHashes(126315892);

await increaseTime(3600);

await NearBridge.addLightClientBlock(borshify(block369));
await NearBridge.blockHashes(369);
await NearBridge.addLightClientBlock(borshify(block126315927));
await NearBridge.blockHashes(126315927);
});

it('After challenge prev should be revert to prev epoch of latest valid block', async function () {
// Skip until tests are upgraded having blocks after nearcore 1.23.0
this.skip();

const block181 = require('./181.json');
const block244 = require('./244.json');
const block304 = require('./304.json');
const block308 = require('./308.json');
const block368 = require('./368.json');
const block126313429 = require('./block_126313429.json');
const block126315547 = require('./block_126315547.json');
const block126315744 = require('./block_126315744.json');
const block126315811 = require('./block_126315811.json');
const block126315892 = require('./block_126315892.json');

await NearBridge.initWithValidators(borshifyInitialValidators(block181.next_bps));
await NearBridge.initWithBlock(borshify(block244));
await NearBridge.blockHashes(244);
await NearBridge.initWithValidators(borshifyInitialValidators(block126313429.next_bps));
await NearBridge.initWithBlock(borshify(block126315547));
await NearBridge.blockHashes(126315547);

await increaseTime(3600);
await NearBridge.addLightClientBlock(borshify(block304));
await NearBridge.blockHashes(304);
await NearBridge.addLightClientBlock(borshify(block126315744));
await NearBridge.blockHashes(126315744);

await increaseTime(3600);
await NearBridge.addLightClientBlock(borshify(block308));
await NearBridge.blockHashes(308);
await NearBridge.addLightClientBlock(borshify(block126315811));
await NearBridge.blockHashes(126315811);

await increaseTime(3600);

block368.approvals_after_next[0] = block368.approvals_after_next[1];
await NearBridge.addLightClientBlock(borshify(block368));
await NearBridge.blockHashes(368);
block126315892.approvals_after_next[0] = block126315892.approvals_after_next[1];
await NearBridge.addLightClientBlock(borshify(block126315892));
await NearBridge.blockHashes(126315892);
expect((await NearBridge.lastValidAt())).to.not.be.equal(0);

await NearBridge.challenge(ethers.constants.AddressZero, 0)
Expand Down
25 changes: 0 additions & 25 deletions contracts/eth/nearbridge/test/block_120998.json

This file was deleted.

Loading
Loading