Skip to content

Commit

Permalink
Bump to v0.9.38 (#775)
Browse files Browse the repository at this point in the history
* Bump to v0.9.38

* Remove ethereum-light-client from workspace

* Fix ci breaking

* Remove snowbridge-xcm-support from runtime

* Fix ci

* Move initialize script to hook

* Fix ci test

* Refactor: move to initialize hook & some cleanup

* For ci

* Fix husky

* Fix: speed test

* Update foundry libs with submodule

* Upgrade go-substrate-rpc-client & stop-gap of relaychain

* For #12345 and #12530

* env for goerli

* Fix for production deployment

* Sync dependencies from release

* Remove test parachain node

* More cleanup

* Use host runner

* Fix wrong commit

* Sync dev setup

* Sync pnpm-lock file & Remove fmt in CI

* Fix format[skip ci]

* Sync toolchain[skip ci]

* Fix for geth 1.11

* Suppress warning in building parachain

* Ron/polkadot v0.9.38 12857 (#780)

* Sync #12857

* Remove test chain

* For #12857

* For #12857

* #12857

* Fix build[skip ci]

* Workaround for current mmr api

* Test CI with foundry

* Fix ci breaking

* Add cargo fmt to husky & ignore some merkle tests cause ci breaking

* Sync dev setup

* Revert to use next beefy block

* Comment for paritytech/polkadot#6577

* Fix for geth 1.11

* For paritytech/polkadot#6577

* For paritytech/polkadot#6577

* Bump substrate-rpc
  • Loading branch information
yrong authored Mar 3, 2023
1 parent 5d7dd5b commit 525126e
Show file tree
Hide file tree
Showing 82 changed files with 7,239 additions and 4,376 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/ethereum.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ name: ethereum
on:
push:
paths:
- 'core/**'
- '!core/**/README.md'
- "core/**"
- "!core/**/README.md"
branches:
- main
pull_request:
paths:
- 'core/**'
- '!core/**/README.md'
- "core/**"
- "!core/**/README.md"

jobs:
build:
runs-on: ubuntu-22.04
runs-on: snowbridge-runner
timeout-minutes: 15
steps:
- uses: actions/checkout@v1
Expand All @@ -27,11 +27,13 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18.12.1
cache: 'pnpm'
cache: "pnpm"
cache-dependency-path: core/pnpm-lock.yaml
- name: Install dependencies
working-directory: core
run: pnpm install --frozen-lockfile
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Build
working-directory: core
run: pnpm build
Expand Down
62 changes: 17 additions & 45 deletions .github/workflows/parachain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,20 @@ name: parachain
on:
push:
paths:
- 'parachain/**'
- '!parachain/README.md'
- '!parachain/LICENSE'
- "parachain/**"
- "!parachain/README.md"
- "!parachain/LICENSE"
branches:
- main
pull_request:
paths:
- 'parachain/**'
- '!parachain/README.md'
- '!parachain/LICENSE'
- "parachain/**"
- "!parachain/README.md"
- "!parachain/LICENSE"
workflow_dispatch:

jobs:
fmt:
runs-on: ubuntu-20.04
env:
CARGO_INCREMENTAL: 0
RUST_BACKTRACE: 1
RUSTFLAGS: -C debuginfo=1
SKIP_WASM_BUILD: 1
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v1
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('parachain/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
target: wasm32-unknown-unknown
components: rustfmt
- name: cargo fmt
run: cd parachain && cargo +nightly fmt -- --check --config-path rustfmt.toml && cd -

check:
runs-on: ubuntu-20.04
runs-on: snowbridge-runner
env:
CARGO_INCREMENTAL: 0
RUST_BACKTRACE: 1
Expand All @@ -66,22 +39,21 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.62.1
toolchain: nightly-2022-11-15
target: wasm32-unknown-unknown
- name: cargo check
uses: actions-rs/cargo@v1
with:
command: check
toolchain: 1.62.1
toolchain: nightly-2022-11-15
args: >-
--manifest-path parachain/Cargo.toml
--workspace
--exclude snowbridge
--features runtime-benchmarks
test:
needs: check
runs-on: ubuntu-20.04
runs-on: snowbridge-runner
env:
CARGO_INCREMENTAL: 0
RUST_BACKTRACE: 1
Expand All @@ -99,10 +71,11 @@ jobs:
key: ${{ runner.os }}-cargo-${{ hashFiles('parachain/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- uses: arduino/setup-protoc@v1
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.62.1
toolchain: nightly-2022-11-15
target: wasm32-unknown-unknown
- name: test beacon client with minimal feature
uses: actions-rs/cargo@v1
Expand All @@ -114,7 +87,7 @@ jobs:
--package snowbridge-ethereum-beacon-client
--features runtime-benchmarks
--features minimal
toolchain: 1.62.1
toolchain: nightly-2022-11-15
- uses: actions-rs/install@v0.1.2
with:
crate: cargo-tarpaulin
Expand All @@ -127,12 +100,11 @@ jobs:
args: >-
--manifest-path parachain/Cargo.toml
--verbose --workspace
--exclude snowbridge
--exclude snowbridge-runtime
--exclude snowblink-runtime
--exclude snowbridge
--exclude snowbridge-runtime
--exclude snowblink-runtime
--exclude snowbase-runtime
--exclude-files '*/mock.rs,*/tests.rs'
--features runtime-benchmarks
--avoid-cfg-tarpaulin
--coveralls ${{ secrets.COVERALLS_REPO_TOKEN }}
toolchain: 1.62.1
toolchain: nightly-2022-11-15
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
release:
runs-on: ubuntu-20.04
runs-on: snowbridge-runner
env:
CARGO_INCREMENTAL: 0
RUST_BACKTRACE: 1
Expand All @@ -25,14 +25,14 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable-2022-01-20
toolchain: nightly-2022-11-15
target: wasm32-unknown-unknown
- name: build
uses: actions-rs/cargo@v1
with:
command: build
args: --manifest-path parachain/Cargo.toml --release
args: --manifest-path parachain/Cargo.toml --workspace --release
- uses: actions/upload-artifact@v1
with:
name: artemis-node
path: parachain/target/release/artemis-node
name: snowbridge-node
path: parachain/target/release/snowbridge
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ node_modules/
# asdf plugin versions
.tool-versions

relaychain/
/relaychain/
.vscode

.rustup
Expand All @@ -23,3 +23,4 @@ relaychain/

.direnv
.envrc
parachain/build_rs_cov.profraw
7 changes: 5 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ echo 'Running pre-commit hook...'
chronic typos .

# lint and format for core contracts and typescript codes
cd core && chronic pnpm lint && chronic pnpm format && cd ..
(cd core && chronic pnpm lint && chronic pnpm format)

# lint and format for relayer codes
cd relayer && chronic mage lint && chronic go fmt ./...
(cd relayer && chronic mage lint && chronic go fmt ./...)

# cargo fmt
(cd parachain && SKIP_WASM_BUILD= cargo fmt --all)

echo 'Pre-commit hook successful!'
1 change: 1 addition & 0 deletions core/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.turbo
.deps
6 changes: 4 additions & 2 deletions core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
"lint": "turbo run lint",
"format": "turbo run format",
"size": "turbo run size",
"coverage": "turbo run coverage"
"coverage": "turbo run coverage",
"remixd": "./node_modules/.bin/remixd"
},
"devDependencies": {
"husky": "^8.0.1",
"turbo": "^1.6.3",
"pnpm-deduplicate": "^0.4.1"
"pnpm-deduplicate": "^0.4.1",
"@remix-project/remixd": "^0.6.1"
}
}
1 change: 1 addition & 0 deletions core/packages/contracts/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ cache/
broadcast/
test/ffiWrapper.js
tsconfig.tsbuildinfo
test/**/data/*.json.keep
6 changes: 3 additions & 3 deletions core/packages/contracts/contracts/BasicInboundChannel.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity ^0.8.9;

import "./ParachainClient.sol";
import "./utils/MerkleProof.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";

contract BasicInboundChannel {
uint256 public constant MAX_GAS_PER_MESSAGE = 100000;
Expand All @@ -27,10 +27,10 @@ contract BasicInboundChannel {
function submit(
Message calldata message,
bytes32[] calldata leafProof,
bool[] calldata hashSides,
bytes calldata parachainHeaderProof
) external {
bytes32 commitment = MerkleProof.processProof(message, leafProof, hashSides);
bytes32 leafHash = keccak256(abi.encode(message));
bytes32 commitment = MerkleProof.processProof(leafProof, leafHash);
require(
parachainClient.verifyCommitment(commitment, parachainHeaderProof),
"Invalid proof"
Expand Down
17 changes: 4 additions & 13 deletions core/packages/contracts/contracts/BeefyClient.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ pragma solidity ^0.8.9;

import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "./utils/Bitfield.sol";
import "./utils/MMRProof.sol";
import "./ScaleCodec.sol";
import "./utils/MerkleProof.sol";

/**
* @title BeefyClient
Expand Down Expand Up @@ -210,7 +210,7 @@ contract BeefyClient is Ownable {
ValidatorProof calldata proof
) internal {
// Check if merkle proof is valid based on the validatorSetRoot
if (!isValidatorInSet(vset, proof.account, proof.index, proof.proof)) {
if (!isValidatorInSet(vset, proof.account, proof.proof)) {
revert InvalidValidatorProof();
}

Expand Down Expand Up @@ -463,7 +463,7 @@ contract BeefyClient is Ownable {
revert InvalidValidatorProof();
}

if (!isValidatorInSet(vset, proof.account, proof.index, proof.proof)) {
if (!isValidatorInSet(vset, proof.account, proof.proof)) {
revert InvalidValidatorProof();
}

Expand Down Expand Up @@ -507,25 +507,16 @@ contract BeefyClient is Ownable {
/**
* @dev Checks if a validators address is a member of the merkle tree
* @param addr The address of the validator to check
* @param index The index of the validator to check, starting at 0
* @param proof Merkle proof required for validation of the address
* @return true if the validator is in the set
*/
function isValidatorInSet(
ValidatorSet memory vset,
address addr,
uint256 index,
bytes32[] calldata proof
) internal pure returns (bool) {
bytes32 hashedLeaf = keccak256(abi.encodePacked(addr));
return
MerkleProof.verifyMerkleLeafAtPosition(
vset.root,
hashedLeaf,
index,
vset.length,
proof
);
return MerkleProof.verify(proof, vset.root, hashedLeaf);
}

/**
Expand Down
9 changes: 3 additions & 6 deletions core/packages/contracts/contracts/ParachainClient.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity ^0.8.9;

import "./BeefyClient.sol";
import "./utils/MerkleProof.sol";
import "./ScaleCodec.sol";

contract ParachainClient {
Expand Down Expand Up @@ -54,11 +53,9 @@ contract ParachainClient {
);

// Compute the merkle root hash of all parachain heads
bytes32 parachainHeadsRoot = MerkleProof.computeRootFromProofAtPosition(
parachainHeadHash,
proof.headProof.pos,
proof.headProof.width,
proof.headProof.proof
bytes32 parachainHeadsRoot = MerkleProof.processProof(
proof.headProof.proof,
parachainHeadHash
);

bytes32 leafHash = createMMRLeaf(proof.leafPartial, parachainHeadsRoot);
Expand Down
Loading

0 comments on commit 525126e

Please sign in to comment.