-
Notifications
You must be signed in to change notification settings - Fork 781
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
Snowbridge - Ethereum Electra Upgrade Support #7075
Open
claravanstaden
wants to merge
82
commits into
paritytech:master
Choose a base branch
from
claravanstaden:electra
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,208
−110
Open
Changes from all commits
Commits
Show all changes
82 commits
Select commit
Hold shift + click to select a range
2536e78
adds snowbridge
bc607a0
Test pallet order (#112)
claravanstaden 4cede80
Fix coverage (#115)
claravanstaden 7bbe297
Merge branch 'master' into snowbridge
78c6c9b
Extract Ethereum chain id in tests (#117)
claravanstaden 66505a7
Ignore reward when funds unavailable (#118)
yrong 628b251
Increase MaxExecutionHeadersToKeep (#120)
yrong e553417
Smoke Tests in CI (#113)
claravanstaden 5bac4ee
Sync execution update on demand (#123)
yrong 8be52c9
Adds finalized header gap check (#124)
claravanstaden 4c850e8
Inline execution update into proof of inbound message & Remove execut…
yrong cbcc449
Fix Smoketests CI (#126)
claravanstaden 5da7df7
Add a linear fee multiplier to ensure safety margins (#127)
vgeddes 9293295
Merge branch 'master' into snowbridge
aa3a75a
Remove MaxExecutionHeadersToKeep (#129)
yrong 7fd2ea4
Merge branch 'master' into snowbridge
9368712
Forward message id to destination chain (#134)
alistair-singh cedc585
fix ci (#136)
claravanstaden 0893dad
Merge branch 'master' into snowbridge
68ab248
Merge branch 'master' into snowbridge
3f495e5
Update Rust version (#138)
claravanstaden d95751b
Reject finalized updates without a sync committee in next store perio…
claravanstaden 1816f4f
Merge branch 'master' into snowbridge
claravanstaden c13f7c7
fmt
claravanstaden 5ca8277
Emit channel on Message Queue (#147)
alistair-singh e96ce3a
fix tests (#149)
alistair-singh d79ef62
Execution Header Cleanup Multi-Block Migration (#148)
claravanstaden f7054e7
Fix the format ci (#154)
yrong f0abb7e
Snowbridge on westend (#157)
yrong 543f4ee
Merge branch 'master' into snowbridge
claravanstaden eaf4c43
merge fixes
claravanstaden f29f6d2
audit fixes (#161)
claravanstaden aa208a9
Merge remote-tracking branch 'origin/snowbridge' into snowbridge
claravanstaden 3e8a9a0
merge fixes
claravanstaden 2cef4bd
another fixes
claravanstaden c7cbd99
Free finalized Ethereum updates (#159)
claravanstaden df4bad7
Westend by default for local setup (#163)
yrong dfee885
Short epoch from ENV (#170)
yrong b19c1e1
Polkadot assets on ethereum (#128)
yrong 64c2a29
electra upgrade
claravanstaden 207cc10
electra progress
claravanstaden 241c644
tests
claravanstaden 29df723
relayer progress
claravanstaden a956c9c
electra header differences
claravanstaden 7280cee
fix benchmarks
claravanstaden 09ab053
fixes
claravanstaden ab01c19
missing fork version
claravanstaden 56cffc2
fixes
claravanstaden ed9dac8
merge damage
claravanstaden 94e811f
add deleted files
claravanstaden 2d9b24e
revert unrelated changes
claravanstaden 6704fd0
prdoc
claravanstaden f505570
Merge branch 'master' into electra
claravanstaden e1c9e52
Merge remote-tracking branch 'origin/electra' into electra
claravanstaden 1913738
fmt
claravanstaden 41e4a49
merge damage
claravanstaden 7c0b1fe
cleanup
claravanstaden 25c32b8
cleanup
claravanstaden 0691e5d
ci fixes
claravanstaden 5628817
Merge branch 'master' into electra
claravanstaden 8fc15da
clippy
claravanstaden f1d5b25
Merge remote-tracking branch 'origin/electra' into electra
claravanstaden 9308de9
add test files
claravanstaden c9a1a1e
progress
claravanstaden 97f2bc8
revert log
claravanstaden 42430f2
adds tests
claravanstaden 54270e3
Merge branch 'master' into electra
claravanstaden 81171b2
cleanup
claravanstaden a09b9fb
fmt
claravanstaden 14000cc
Merge branch 'master' into electra
claravanstaden 6ce330c
fix test and semver
claravanstaden a469eb1
remove unnecessary logs
claravanstaden 8cfa781
Merge remote-tracking branch 'origin/electra' into electra
claravanstaden b3e0d8a
cleanup logs
claravanstaden 97e3a9c
Merge branch 'master' into electra
claravanstaden 96836c9
Update bridges/snowbridge/pallets/ethereum-client/src/benchmarking/mo…
claravanstaden 66fa5f6
Update bridges/snowbridge/pallets/ethereum-client/src/lib.rs
claravanstaden 3000cfa
Update bridges/snowbridge/pallets/ethereum-client/src/lib.rs
claravanstaden 76d0b3d
Update bridges/snowbridge/pallets/ethereum-client/src/impls.rs
claravanstaden 6b58968
Update bridges/snowbridge/pallets/ethereum-client/src/lib.rs
claravanstaden 6d032fb
Update bridges/snowbridge/pallets/ethereum-client/src/lib.rs
claravanstaden a25a8b8
pr comments
claravanstaden File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
bridges/snowbridge/pallets/ethereum-client/src/config/altair.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-FileCopyrightText: 2023 Snowfork <[email protected]> | ||
|
||
/// Generalized Indices | ||
/// related to Merkle proofs | ||
/// get_generalized_index(BeaconState, 'block_roots') | ||
pub const BLOCK_ROOTS_INDEX: usize = 37; | ||
/// get_generalized_index(BeaconState, 'finalized_checkpoint', 'root') | ||
pub const FINALIZED_ROOT_INDEX: usize = 105; | ||
/// get_generalized_index(BeaconState, 'current_sync_committee') | ||
pub const CURRENT_SYNC_COMMITTEE_INDEX: usize = 54; | ||
/// get_generalized_index(BeaconState, 'next_sync_committee') | ||
pub const NEXT_SYNC_COMMITTEE_INDEX: usize = 55; | ||
/// get_generalized_index(BeaconBlockBody, 'execution_payload') | ||
pub const EXECUTION_HEADER_INDEX: usize = 25; |
15 changes: 15 additions & 0 deletions
15
bridges/snowbridge/pallets/ethereum-client/src/config/electra.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-FileCopyrightText: 2023 Snowfork <[email protected]> | ||
|
||
/// Generalized Indices | ||
/// related to Merkle proofs | ||
/// get_generalized_index(BeaconState, 'block_roots') | ||
pub const BLOCK_ROOTS_INDEX: usize = 69; | ||
/// get_generalized_index(BeaconState, 'finalized_checkpoint', 'root') | ||
pub const FINALIZED_ROOT_INDEX: usize = 169; | ||
/// get_generalized_index(BeaconState, 'current_sync_committee') | ||
pub const CURRENT_SYNC_COMMITTEE_INDEX: usize = 86; | ||
/// get_generalized_index(BeaconState, 'next_sync_committee') | ||
pub const NEXT_SYNC_COMMITTEE_INDEX: usize = 87; | ||
/// get_generalized_index(BeaconBlockBody, 'execution_payload') | ||
pub const EXECUTION_HEADER_INDEX: usize = 25; |
30 changes: 2 additions & 28 deletions
30
bridges/snowbridge/pallets/ethereum-client/src/config/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,9 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-FileCopyrightText: 2023 Snowfork <[email protected]> | ||
use snowbridge_beacon_primitives::merkle_proof::{generalized_index_length, subtree_index}; | ||
use static_assertions::const_assert; | ||
|
||
/// Generalized Indices | ||
/// related to Merkle proofs | ||
/// get_generalized_index(BeaconState, 'block_roots') | ||
pub const BLOCK_ROOTS_INDEX: usize = 37; | ||
pub const BLOCK_ROOTS_SUBTREE_INDEX: usize = subtree_index(BLOCK_ROOTS_INDEX); | ||
pub const BLOCK_ROOTS_DEPTH: usize = generalized_index_length(BLOCK_ROOTS_INDEX); | ||
|
||
/// get_generalized_index(BeaconState, 'finalized_checkpoint', 'root') | ||
pub const FINALIZED_ROOT_INDEX: usize = 105; | ||
pub const FINALIZED_ROOT_SUBTREE_INDEX: usize = subtree_index(FINALIZED_ROOT_INDEX); | ||
pub const FINALIZED_ROOT_DEPTH: usize = generalized_index_length(FINALIZED_ROOT_INDEX); | ||
|
||
/// get_generalized_index(BeaconState, 'current_sync_committee') | ||
pub const CURRENT_SYNC_COMMITTEE_INDEX: usize = 54; | ||
pub const CURRENT_SYNC_COMMITTEE_SUBTREE_INDEX: usize = subtree_index(CURRENT_SYNC_COMMITTEE_INDEX); | ||
pub const CURRENT_SYNC_COMMITTEE_DEPTH: usize = | ||
generalized_index_length(CURRENT_SYNC_COMMITTEE_INDEX); | ||
|
||
/// get_generalized_index(BeaconState, 'next_sync_committee') | ||
pub const NEXT_SYNC_COMMITTEE_INDEX: usize = 55; | ||
pub const NEXT_SYNC_COMMITTEE_SUBTREE_INDEX: usize = subtree_index(NEXT_SYNC_COMMITTEE_INDEX); | ||
pub const NEXT_SYNC_COMMITTEE_DEPTH: usize = generalized_index_length(NEXT_SYNC_COMMITTEE_INDEX); | ||
|
||
/// get_generalized_index(BeaconBlockBody, 'execution_payload') | ||
pub const EXECUTION_HEADER_INDEX: usize = 25; | ||
pub const EXECUTION_HEADER_SUBTREE_INDEX: usize = subtree_index(EXECUTION_HEADER_INDEX); | ||
pub const EXECUTION_HEADER_DEPTH: usize = generalized_index_length(EXECUTION_HEADER_INDEX); | ||
pub mod altair; | ||
pub mod electra; | ||
|
||
/// Sizes related to SSZ encoding | ||
pub const MAX_EXTRA_DATA_BYTES: usize = 32; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ use super::*; | |
use frame_support::ensure; | ||
use snowbridge_beacon_primitives::ExecutionProof; | ||
|
||
use snowbridge_beacon_primitives::merkle_proof::{generalized_index_length, subtree_index}; | ||
use snowbridge_core::inbound::{ | ||
VerificationError::{self, *}, | ||
*, | ||
|
@@ -13,8 +14,9 @@ use snowbridge_ethereum::Receipt; | |
impl<T: Config> Verifier for Pallet<T> { | ||
/// Verify a message by verifying the existence of the corresponding | ||
/// Ethereum log in a block. Returns the log if successful. The execution header containing | ||
/// the log should be in the beacon client storage, meaning it has been verified and is an | ||
/// ancestor of a finalized beacon block. | ||
/// the log is sent with the message. The beacon header containing the execution header | ||
/// is also sent with the message, to check if the header is an ancestor of a finalized | ||
/// header. | ||
fn verify(event_log: &Log, proof: &Proof) -> Result<(), VerificationError> { | ||
Self::verify_execution_proof(&proof.execution_proof) | ||
.map_err(|e| InvalidExecutionProof(e.into()))?; | ||
|
@@ -80,25 +82,6 @@ impl<T: Config> Pallet<T> { | |
Error::<T>::HeaderNotFinalized | ||
); | ||
|
||
// Gets the hash tree root of the execution header, in preparation for the execution | ||
// header proof (used to check that the execution header is rooted in the beacon | ||
// header body. | ||
let execution_header_root: H256 = execution_proof | ||
.execution_header | ||
.hash_tree_root() | ||
.map_err(|_| Error::<T>::BlockBodyHashTreeRootFailed)?; | ||
|
||
ensure!( | ||
verify_merkle_branch( | ||
execution_header_root, | ||
&execution_proof.execution_branch, | ||
config::EXECUTION_HEADER_SUBTREE_INDEX, | ||
config::EXECUTION_HEADER_DEPTH, | ||
execution_proof.header.body_root | ||
), | ||
Error::<T>::InvalidExecutionHeaderProof | ||
); | ||
|
||
let beacon_block_root: H256 = execution_proof | ||
.header | ||
.hash_tree_root() | ||
|
@@ -125,6 +108,28 @@ impl<T: Config> Pallet<T> { | |
}, | ||
} | ||
|
||
// Gets the hash tree root of the execution header, in preparation for the execution | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed the order of operations here, as suggested by the Oak Security audit. |
||
// header proof (used to check that the execution header is rooted in the beacon | ||
// header body. | ||
let execution_header_root: H256 = execution_proof | ||
.execution_header | ||
.hash_tree_root() | ||
.map_err(|_| Error::<T>::BlockBodyHashTreeRootFailed)?; | ||
|
||
let execution_header_gindex = Self::execution_header_gindex_at_slot( | ||
execution_proof.header.slot, | ||
T::ForkVersions::get(), | ||
); | ||
ensure!( | ||
verify_merkle_branch( | ||
execution_header_root, | ||
&execution_proof.execution_branch, | ||
subtree_index(execution_header_gindex), | ||
generalized_index_length(execution_header_gindex), | ||
execution_proof.header.body_root | ||
), | ||
Error::<T>::InvalidExecutionHeaderProof | ||
); | ||
Ok(()) | ||
} | ||
|
||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Config is now based on fork version, so add a module per fork specific settings.