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

Snowbridge - Ethereum Electra Upgrade Support #7075

Open
wants to merge 82 commits into
base: master
Choose a base branch
from

Conversation

claravanstaden
Copy link
Contributor

@claravanstaden claravanstaden commented Jan 7, 2025

Description

Adds support for the upcoming Ethereum Electra upgrade, while maintaining backwards compatibility for the current Deneb fork.

Integration

Relayers should be updated to send updated Electra consensus data structures.

Review Notes

The Ethereum Electra hard-fork consensus changes affecting the Ethereum light client are mainly isolated to the Generalized Indexes of data structures changing. Before Electra, these values were hardcoded in config. For Electra, these values change and needed to the updated. Methods were added to return the correct g-index for the current fork version.

Data structures used by the Ethereum client did not change in this hard-fork. The BeaconState container has been updated with additional changes, but because the on-chain code does not reference the BeaconState directly (only indirectly through merkle proofs), it is not a concern. Off-chain relayers use the BeaconState to generate proofs, and so the relayer code has been updated accordingly.

Companion PR for off-chain relayers

Snowfork/snowbridge#1283

claravanstaden and others added 30 commits February 8, 2024 13:37
* pallet order

* fmt

* adds test for bridge order

* revert unintended change

---------

Co-authored-by: claravanstaden <Cats 4 life!>
* fix coverage

* fix codecov config

---------

Co-authored-by: claravanstaden <Cats 4 life!>
# Conflicts:
#	.github/workflows/check-labels.yml
#	.github/workflows/check-prdoc.yml
#	.github/workflows/check-workspace.yml
#	.github/workflows/gitspiegel-trigger.yml
#	.github/workflows/release-99_notif-published.yml
#	bridges/snowbridge/README.md
#	bridges/snowbridge/runtime/test-common/src/lib.rs
#	bridges/snowbridge/scripts/contribute-upstream.sh
#	cumulus/parachains/runtimes/assets/test-utils/src/test_cases_over_bridge.rs
#	cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/tests/snowbridge.rs
#	polkadot/node/subsystem-bench/src/approval/mod.rs
#	polkadot/node/subsystem-bench/src/availability/mod.rs
#	polkadot/node/subsystem-bench/src/cli.rs
#	polkadot/node/subsystem-bench/src/core/environment.rs
#	polkadot/node/subsystem-bench/src/subsystem-bench.rs
* extract ethereum chain id

* remove cargo.toml

* fix chain id data type

* fix missing chain id param

* fix missing chain id param

* fix coverage and missing param

* fix CI

* fix CI

* revert scripts

* revert coverage jobs

* revert formatting

---------

Co-authored-by: claravanstaden <Cats 4 life!>
* Ignore rewarding when funds unavailable

* More tests

* Fix taplo

* Fix emulated test

* Improve comments

* Update bridges/snowbridge/pallets/inbound-queue/src/lib.rs

Co-authored-by: Vincent Geddes <[email protected]>

* Fix format

---------

Co-authored-by: Vincent Geddes <[email protected]>
* test e2e scripts in GA

* fix GA

* test current dir

* fix path

* install moreutils

* sponge

* install go

* export path

* try something else

* run nix

* switch branch

* nix develop

* check setup

* use nix setup

* e2e stack script

* e2e stack script

* run command

* check current dir

* correct dir

* correct dir

* just cd

* try something else

* rn e2e script

* adds submodules

* ls

* print vars

* remove ls

* cd instead of pushdir

* try checking out differently

* ls

* ls

* change checkout order

* check what is in a dir

* check what is in a dir

* check something

* check something

* try something

* try something

* try e2e script again

* remove ls

* cleanup script

* adds ssz gen

* install js components

* install js components

* fix dir

* adds output dir

* create dir

* try something else

* bump

* fix config paths

* test output dir

* adds wasm target

* check wasm target

* setup rustup in nix

* missing quote

* install rustup stable

* adds e2e script in again

* remove skip wasm flag

* comment out things

* start lodestar

* print out log

* print out log

* print out lodestar

* check geth version

* bump

* remove commented out code

* update go files

* adds smoketests

* create dir

* adjust scripts

* only redirect start-services.sh output

* only redirect start-services.sh output

* switch dir

* permissions

* check script

* allow service to be down

* bump

* last run, hopefully

* fix tests

* fixes

* bump

* fix

* check lodestar

* check lodestar

* check lodestar

* bump

* bump

* try again

* try again

* bump

* bump

* update go

* update go

* cleanup

* check what is happening now

* lodestar should run the background

* run init.sh

* check what happens with the download

* change OS check

* remove other steps to see what is happening

* bump

* run smoketests

* run smoketests

* cleanup jobs

* extract ethereum chain id

* remove cargo.toml

* fix chain id data type

* fix missing chain id param

* fix missing chain id param

* fix coverage and missing param

* fix CI

* fix CI

* revert scripts

* revert coverage jobs

* revert formatting

* check log

* fix log

* separate steps

* cleanup job

* remove running smoketests on a PR, only when merged

* update branch

* remove http endpoint from relayer

* update nightly, revert unrelated changes

* check rust version

* chaneg branch for testing

* adds beacon relay log

* increase slot time

* increase block time check

* lower block check count

* only run smoketests on merge to snowbridge

---------

Co-authored-by: claravanstaden <Cats 4 life!>
* Sync execution update on demand

* Fix updating LatestExecutionState

* Revert change unrelated

* Remove unused

* Remove execution header from update & Remove LatestExecutionState
* adds finalized header gap check

* fix comment

* fmt

* use constant for max gap

* remove redundant config

* fmt

* fix tests

* fix again

* fmt

* test works

* revert change

* Update bridges/snowbridge/pallets/ethereum-client/src/lib.rs

Co-authored-by: Vincent Geddes <[email protected]>

* fmt

---------

Co-authored-by: claravanstaden <Cats 4 life!>
Co-authored-by: Vincent Geddes <[email protected]>
…ion header storage (paritytech#125)

* Remove execution header storage & submit inbound message with execution update

* Fix ci breaking

* More refactoring

* Update beacon test fixtures

* Format code

* Initialize storage with finalized checkpoint for benchmark

* Update weights include verify the execution proof

* Fix breaking test

* Remove fixture not in use

* Add detail for InvalidExecutionProof

* Initialize checkpoint for tests on demand

* Revert error as NotBootstrapped for submit_update_with_missing_bootstrap

* Add verify_execution_header tests back

* Add error test back

* Cleanup templates

* Update bridges/snowbridge/primitives/beacon/src/types.rs

Co-authored-by: Vincent Geddes <[email protected]>

* Narrowed inputs

* Remove fields irrelevant from proof

* Update bridges/snowbridge/primitives/core/src/inbound.rs

Co-authored-by: Vincent Geddes <[email protected]>

* Update bridges/snowbridge/pallets/ethereum-client/src/impls.rs

Co-authored-by: Vincent Geddes <[email protected]>

* Polish

---------

Co-authored-by: Vincent Geddes <[email protected]>
* fix smoketests ci

* remove merge from upstream

* first commit before pulling from master

---------

Co-authored-by: claravanstaden <Cats 4 life!>
* Add fee multiplier

* fmt

* fmt

* Update test mock

* Swap order for parameters to calculate_fee

---------

Co-authored-by: claravanstaden <Cats 4 life!>
# Conflicts:
#	.github/scripts/check-workspace.py
#	.github/scripts/common/lib.sh
#	.github/workflows/check-licenses.yml
#	.github/workflows/check-prdoc.yml
#	.github/workflows/release-50_publish-docker.yml
#	.github/workflows/release-99_notif-published.yml
#	Cargo.lock
#	bridges/snowbridge/pallets/ethereum-client/Cargo.toml
#	bridges/snowbridge/pallets/ethereum-client/src/tests.rs
#	bridges/snowbridge/pallets/inbound-queue/Cargo.toml
#	bridges/snowbridge/pallets/inbound-queue/src/mock.rs
#	bridges/snowbridge/pallets/outbound-queue/Cargo.toml
#	bridges/snowbridge/pallets/outbound-queue/merkle-tree/Cargo.toml
#	bridges/snowbridge/pallets/outbound-queue/runtime-api/Cargo.toml
#	bridges/snowbridge/pallets/outbound-queue/src/lib.rs
#	bridges/snowbridge/pallets/system/Cargo.toml
#	bridges/snowbridge/pallets/system/runtime-api/Cargo.toml
#	bridges/snowbridge/primitives/beacon/Cargo.toml
#	bridges/snowbridge/primitives/core/Cargo.toml
#	bridges/snowbridge/primitives/ethereum/Cargo.toml
#	bridges/snowbridge/runtime/runtime-common/Cargo.toml
#	bridges/snowbridge/runtime/test-common/Cargo.toml
# Conflicts:
#	.github/CODEOWNERS
#	.github/scripts/common/lib.sh
#	bridges/snowbridge/pallets/ethereum-client/src/tests.rs
#	bridges/snowbridge/pallets/inbound-queue/fixtures/src/register_token_with_insufficient_fee.rs
#	cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs
* forward message id to destination chain

* fix import
Co-authored-by: claravanstaden <Cats 4 life!>
# Conflicts:
#	.github/scripts/common/lib.sh
#	.github/workflows/check-links.yml
#	.github/workflows/srtool.yml
#	.github/workflows/subsystem-benchmarks.yml
#	bridges/snowbridge/pallets/inbound-queue/src/lib.rs
#	cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs
* update rust version to stable

* pin to rust 1.76

* fix tests and warning

* fix import

* update nightly version

---------

Co-authored-by: claravanstaden <Cats 4 life!>
paritytech#145)

* sync committee handover fix

* remove comment

* Update bridges/snowbridge/pallets/ethereum-client/src/lib.rs

Co-authored-by: Vincent Geddes <[email protected]>

* add extra check

* move checks around

* remove extra validation

* fix compiler error

* reject updates in next period without sync committee

* fix test

* polish

* Update bridges/snowbridge/pallets/ethereum-client/src/lib.rs

Co-authored-by: Vincent Geddes <[email protected]>

---------

Co-authored-by: Vincent Geddes <[email protected]>
# Conflicts:
#	.github/workflows/check-features.yml
#	.github/workflows/check-licenses.yml
#	.github/workflows/issues-auto-label.yml
#	.github/workflows/misc-notify-burnin-label.yml
#	.github/workflows/misc-review-bot-merge-queue.yml
#	.github/workflows/publish-check-crates.yml
#	.github/workflows/publish-claim-crates.yml
#	.github/workflows/publish-subsystem-benchmarks.yml
#	.github/workflows/release-99_notif-published.yml
#	.github/workflows/release-build-and-attach-runtimes.yml
#	.github/workflows/release-check-runtimes.yml
#	.github/workflows/release-srtool.yml
#	.github/workflows/review-bot.yml
#	.github/workflows/review-trigger.yml
#	cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs
* add channel id to events

* fixed channel

* fix formatting
* cleanup

* cleanup ethereum mods

* start on migration work

* migration tests

* more test refining

* finish off feature

* fixes

* fmt

* fix missing feature

* zepter

* taplo

* remove workflow files

* Updates weights

* remove comment

* updates weight

* fix weights
* Enable bridge config on westend

* Update bridge config for asset hub westend

* Use BridgeHubMessageRouter

* Add unit tests

* Update asset hub config

* Add emulated test
# Conflicts:
#	.github/review-bot.yml
#	.github/scripts/check-workspace.py
#	.github/scripts/common/lib.sh
#	.github/workflows/check-licenses.yml
#	.github/workflows/check-links.yml
#	.github/workflows/check-prdoc.yml
#	.github/workflows/check-runtime-migration.yml
#	.github/workflows/check-semver.yml
#	.github/workflows/checks-quick.yml
#	.github/workflows/misc-sync-templates.yml
#	.github/workflows/publish-check-crates.yml
#	.github/workflows/publish-claim-crates.yml
#	.github/workflows/release-10_rc-automation.yml
#	.github/workflows/release-30_publish_release_draft.yml
#	.github/workflows/release-50_publish-docker.yml
#	.github/workflows/release-srtool.yml
#	.github/workflows/tests-linux-stable.yml
#	.github/workflows/tests.yml
#	Cargo.lock
#	bridges/snowbridge/pallets/ethereum-client/Cargo.toml
#	bridges/snowbridge/pallets/ethereum-client/src/mock.rs
#	cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/Cargo.toml
#	cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/Cargo.toml
#	cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/lib.rs
#	cumulus/parachains/runtimes/assets/asset-hub-westend/Cargo.toml
#	cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs
#	cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml
#	cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs
#	cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/Cargo.toml
#	cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs
@@ -125,6 +108,28 @@ impl<T: Config> Pallet<T> {
},
}

// Gets the hash tree root of the execution header, in preparation for the execution
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Comment on lines +5 to +6
pub mod altair;
pub mod electra;
Copy link
Contributor Author

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.

},
electra: Fork {
version: [5, 0, 0, 0], // 0x05000000
epoch: 80000000000,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set to the future, so current Westend tests still test Deneb.

@@ -0,0 +1,926 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2023 Snowfork <[email protected]>
pub use crate::mock_electra::*;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full test suite for Electra. These tests can be moved to tests.rs once Electra has been merged, and this file can be deleted. The same applies to mock_electra.rs.

@claravanstaden claravanstaden marked this pull request as ready for review January 16, 2025 08:08
@paritytech-review-bot paritytech-review-bot bot requested a review from a team January 16, 2025 08:09
@claravanstaden
Copy link
Contributor Author

@alistair-singh @vgeddes @yrong please review. :)

Copy link
Contributor

@vgeddes vgeddes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to support the updated get_lc_execution_root in pectra?

bridges/snowbridge/pallets/ethereum-client/src/lib.rs Outdated Show resolved Hide resolved
bridges/snowbridge/pallets/ethereum-client/src/lib.rs Outdated Show resolved Hide resolved
bridges/snowbridge/pallets/ethereum-client/src/impls.rs Outdated Show resolved Hide resolved
bridges/snowbridge/pallets/ethereum-client/src/lib.rs Outdated Show resolved Hide resolved
bridges/snowbridge/pallets/ethereum-client/src/lib.rs Outdated Show resolved Hide resolved
]
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing final newline

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in a25a8b8.

],
"execution_header": null,
"execution_branch": null
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing final newline

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in a25a8b8.

"0x6dd3b9955d892d92338b19976fd07084bfe88a76c3063482b7f30ee60feb2a58",
"0x940522efb5e2581496c5e254e388423781dd70d9ce959cc5ff65382471de0b16"
]
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing final newline

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in a25a8b8.

pub fn sync_committee_participation_is_supermajority_errors_when_not_supermajority() {
new_tester().execute_with(|| {
let participation: [u8; 512] = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0,
Copy link
Contributor

@vgeddes vgeddes Jan 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not important, but would prefer this array to hex-encoded, as its more compact. Just a note for next time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, addressed in a25a8b8.

@claravanstaden
Copy link
Contributor Author

Do we need to support the updated get_lc_execution_root in pectra?

@vgeddes I do not think so, because the ExecutionPayloadHeader does not change in Electra, so we keep using the same data structure that we defined with Deneb.

},
electra: Fork {
version: [5, 0, 0, 0], // 0x05000000
epoch: 2000000,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems the Sepolia upgrade scheduler is not finalized, so this is just a placeholder in advance?

Comment on lines 169 to 176
deneb: Fork {
version: [144, 0, 0, 115], // 0x90000073
epoch: 132608,
version: [80,99,118,36], // 0x50637624
epoch: 0,
},
electra: Fork {
version: [96,99,118,36], // 0x60637624
epoch: 256,
},
Copy link
Contributor

@yrong yrong Jan 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious why changing the ForkVersions here, IIUC this is the configuration for Sepolia as declared in https://github.com/eth-clients/sepolia/blob/da5654742513435bdd6dbc5fd033cf593ce57a0f/metadata/config.yaml#L36

Will that break the Westend-Sepolia testnet?

@yrong
Copy link
Contributor

yrong commented Jan 20, 2025

Overall LGTM. Just a bit concern about the switching process from Deneb to Electra.

Seems the upgrade on Sepolia is scheduled on early Feb, we may need to merge before that and test it first on Westend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants