Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into add-near-plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
karim-en committed Oct 23, 2023
2 parents 0323f3e + 3420dc7 commit 17ccf69
Show file tree
Hide file tree
Showing 218 changed files with 22,140 additions and 88,016 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/contracts-eth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,13 @@ jobs:

name: ${{ matrix.job-name }}
steps:
- name: Install LFS
run: apt-get install git-lfs

- name: Clone the repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
lfs: 'true'

- name: Execute
run: ${{ matrix.cmd }}
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/contracts-near.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,16 @@ jobs:

name: ${{ matrix.job-name }}
steps:
- name: Install LFS
run: apt-get install git-lfs

- name: Clone the repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
lfs: 'true'

- name: Checkout LFS objects
run: git lfs checkout

- name: Execute
env:
Expand Down
11 changes: 9 additions & 2 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,15 @@ jobs:

name: ${{ matrix.job-name }}
steps:
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "16.x"

- name: Clone the repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
lfs: 'true'

- name: Install nearup
run: |
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ jobs:
runs-on: self-hosted
name: Lint
steps:
- name: Install LFS
run: apt-get install git-lfs

- name: Clone the repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
lfs: 'true'

- name: Lint
run: |
yarn
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/security-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
on:
push:
branches:
- master
pull_request:
schedule:
- cron: "50 10 * * *"
workflow_dispatch:

name: "Contract Security Analysis"
jobs:
contract_analysis:
name: "Shared"
uses: aurora-is-near/.github/.github/workflows/security_analysis.yml@master
secrets: inherit
with:
ignore_failures: "true"
7 changes: 6 additions & 1 deletion .github/workflows/sigma-prime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ jobs:
name: Sigma Prime security testing
steps:

- name: Install LFS
run: apt-get install git-lfs

- name: Clone the repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
lfs: 'true'

- name: Clone sigma prime security testing repository
uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.env
*.env
node_modules
artifacts
cache
coverage
coverage.json
node_modules
target
testdata
vendor
.history
.DS_Store
Expand All @@ -20,4 +20,4 @@ eth2near/ethashproof/cmd/relayer/relayer

.gitsecret/keys/random_seed
!*.secret
eth2near/eth2near-block-relay-rs/data/API_KEY
eth2near/eth2near-block-relay-rs/data/API_KEY
3 changes: 1 addition & 2 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# CODEOWNERS: https://help.github.com/articles/about-codeowners/
* @mfornet
* @sept-en
* @karim-en
14 changes: 13 additions & 1 deletion cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const {
} = require('rainbow-bridge-testing')
const { ETHDump } = require('./commands/eth-dump')
const { NearDump } = require('./commands/near-dump')
const { ethToNearFindProof } = require('rainbow-bridge-eth2near-block-relay')
const { ethToNearFindProof, ethToNearFindStorageProof } = require('rainbow-bridge-eth2near-block-relay')
const { RainbowConfig } = require('rainbow-bridge-utils')
const { UpdateDagMerkleRoots } = require('./commands/update-dag-merkle-roots')
const {
Expand Down Expand Up @@ -649,6 +649,18 @@ RainbowConfig.addOptions(
]
)

RainbowConfig.addOptions(
program
.command('eth-to-near-find-storage-proof <contract-address> <storage_key> <block-number>')
.description('Get eth-to-near storage proof for provided storage key.'),
async (contractAddress, storageKey, blockNumber, args) => {
await ethToNearFindStorageProof({ contractAddress, storageKey, blockNumber, ...args })
},
[
'eth-node-url'
]
)

// Testing commands
const testingCommand = program
.command('TESTING')
Expand Down
2 changes: 1 addition & 1 deletion cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"dependencies": {
"bn.js": "^5.1.3",
"commander": "^5.1.0",
"eth-object": "https://github.com/near/eth-object#383b6ea68c7050bea4cab6950c1d5a7fa553e72b",
"eth-object": "https://github.com/aurora-is-near/eth-object#a84d1420fdde87a768b96c6a3b3d0ee435998f72",
"eth-util-lite": "near/eth-util-lite#master",
"ethereumjs-util": "^6.2.0",
"node-fetch": "^2.6.7",
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
2 changes: 2 additions & 0 deletions contracts/eth/nearbridge/.catalog-info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
system: bridge-protocol
deployedAt:
- contract:ethereum/mainnet/0x88f975d5a1153ea92af66e7c4292576a329c04b6
- contract:ethereum/goerli/0x6f2C9EbFB1e3Ff065E6725A715B458EF13206097
interactsWith: []
---
apiVersion: backstage.io/v1alpha1
Expand All @@ -43,6 +44,7 @@ spec:
system: bridge-protocol
deployedAt:
- contract:ethereum/mainnet/0x3FEFc5A4B1c02f21cBc8D3613643ba0635b9a873
- contract:ethereum/goerli/0x37c2d89b55bfd95532637554711441017efabfef
interactsWith:
- relayer:ethereum/mainnet/0x015e634c7c1311a9034220c28d3d12b7f710a3b1
deprecated:
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
Loading

0 comments on commit 17ccf69

Please sign in to comment.