Skip to content

Commit 3f113e5

Browse files
Merge branch 'unstable' into single-attestation-take-3
2 parents 4334687 + 59afe41 commit 3f113e5

File tree

3 files changed

+56
-67
lines changed

3 files changed

+56
-67
lines changed

consensus/types/src/fork_context.rs

Lines changed: 16 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -22,61 +22,22 @@ impl ForkContext {
2222
genesis_validators_root: Hash256,
2323
spec: &ChainSpec,
2424
) -> Self {
25-
let mut fork_to_digest = vec![(
26-
ForkName::Base,
27-
ChainSpec::compute_fork_digest(spec.genesis_fork_version, genesis_validators_root),
28-
)];
29-
30-
// Only add Altair to list of forks if it's enabled
31-
// Note: `altair_fork_epoch == None` implies altair hasn't been activated yet on the config.
32-
if spec.altair_fork_epoch.is_some() {
33-
fork_to_digest.push((
34-
ForkName::Altair,
35-
ChainSpec::compute_fork_digest(spec.altair_fork_version, genesis_validators_root),
36-
));
37-
}
38-
39-
// Only add Bellatrix to list of forks if it's enabled
40-
// Note: `bellatrix_fork_epoch == None` implies bellatrix hasn't been activated yet on the config.
41-
if spec.bellatrix_fork_epoch.is_some() {
42-
fork_to_digest.push((
43-
ForkName::Bellatrix,
44-
ChainSpec::compute_fork_digest(
45-
spec.bellatrix_fork_version,
46-
genesis_validators_root,
47-
),
48-
));
49-
}
50-
51-
if spec.capella_fork_epoch.is_some() {
52-
fork_to_digest.push((
53-
ForkName::Capella,
54-
ChainSpec::compute_fork_digest(spec.capella_fork_version, genesis_validators_root),
55-
));
56-
}
57-
58-
if spec.deneb_fork_epoch.is_some() {
59-
fork_to_digest.push((
60-
ForkName::Deneb,
61-
ChainSpec::compute_fork_digest(spec.deneb_fork_version, genesis_validators_root),
62-
));
63-
}
64-
65-
if spec.electra_fork_epoch.is_some() {
66-
fork_to_digest.push((
67-
ForkName::Electra,
68-
ChainSpec::compute_fork_digest(spec.electra_fork_version, genesis_validators_root),
69-
));
70-
}
71-
72-
if spec.fulu_fork_epoch.is_some() {
73-
fork_to_digest.push((
74-
ForkName::Fulu,
75-
ChainSpec::compute_fork_digest(spec.fulu_fork_version, genesis_validators_root),
76-
));
77-
}
78-
79-
let fork_to_digest: HashMap<ForkName, [u8; 4]> = fork_to_digest.into_iter().collect();
25+
let fork_to_digest: HashMap<ForkName, [u8; 4]> = ForkName::list_all()
26+
.into_iter()
27+
.filter_map(|fork| {
28+
if fork.fork_epoch(spec).is_some() {
29+
Some((
30+
fork,
31+
ChainSpec::compute_fork_digest(
32+
ForkName::fork_version(fork, spec),
33+
genesis_validators_root,
34+
),
35+
))
36+
} else {
37+
None
38+
}
39+
})
40+
.collect();
8041

8142
let digest_to_fork = fork_to_digest
8243
.clone()

consensus/types/src/fork_name.rs

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,37 @@ impl ForkName {
3434
}
3535

3636
pub fn list_all_fork_epochs(spec: &ChainSpec) -> Vec<(ForkName, Option<Epoch>)> {
37-
vec![
38-
(ForkName::Altair, spec.altair_fork_epoch),
39-
(ForkName::Bellatrix, spec.bellatrix_fork_epoch),
40-
(ForkName::Capella, spec.capella_fork_epoch),
41-
(ForkName::Deneb, spec.deneb_fork_epoch),
42-
(ForkName::Electra, spec.electra_fork_epoch),
43-
(ForkName::Fulu, spec.fulu_fork_epoch),
44-
]
37+
ForkName::list_all()
38+
.into_iter()
39+
// Skip Base
40+
.skip(1)
41+
.map(|fork| (fork, fork.fork_epoch(spec)))
42+
.collect()
43+
}
44+
45+
pub fn fork_epoch(self, spec: &ChainSpec) -> Option<Epoch> {
46+
match self {
47+
Self::Base => Some(Epoch::new(0)),
48+
Self::Altair => spec.altair_fork_epoch,
49+
Self::Bellatrix => spec.bellatrix_fork_epoch,
50+
Self::Capella => spec.capella_fork_epoch,
51+
Self::Deneb => spec.deneb_fork_epoch,
52+
Self::Electra => spec.electra_fork_epoch,
53+
Self::Fulu => spec.fulu_fork_epoch,
54+
}
55+
}
56+
57+
/// Returns the fork version of a fork
58+
pub fn fork_version(self, spec: &ChainSpec) -> [u8; 4] {
59+
match self {
60+
Self::Base => spec.genesis_fork_version,
61+
Self::Altair => spec.altair_fork_version,
62+
Self::Bellatrix => spec.bellatrix_fork_version,
63+
Self::Capella => spec.capella_fork_version,
64+
Self::Deneb => spec.deneb_fork_version,
65+
Self::Electra => spec.electra_fork_version,
66+
Self::Fulu => spec.fulu_fork_version,
67+
}
4568
}
4669

4770
pub fn latest() -> ForkName {

testing/execution_engine_integration/src/geth.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ use std::{env, fs};
77
use tempfile::TempDir;
88
use unused_port::unused_tcp4_port;
99

10-
const GETH_BRANCH: &str = "master";
10+
// This is not currently used due to the following breaking changes in geth that requires updating our tests:
11+
// 1. removal of `personal` namespace in v1.14.12: See #30704
12+
// 2. removal of `totalDifficulty` field from RPC in v1.14.11. See #30386.
13+
// const GETH_BRANCH: &str = "master";
1114
const GETH_REPO_URL: &str = "https://github.com/ethereum/go-ethereum";
1215

1316
pub fn build_result(repo_dir: &Path) -> Output {
@@ -27,12 +30,14 @@ pub fn build(execution_clients_dir: &Path) {
2730
}
2831

2932
// Get the latest tag on the branch
30-
let last_release = build_utils::get_latest_release(&repo_dir, GETH_BRANCH).unwrap();
31-
build_utils::checkout(&repo_dir, dbg!(&last_release)).unwrap();
33+
// let last_release = build_utils::get_latest_release(&repo_dir, GETH_BRANCH).unwrap();
34+
// Using an older release due to breaking changes in recent releases. See comment on `GETH_BRANCH` const.
35+
let release_tag = "v1.14.10";
36+
build_utils::checkout(&repo_dir, dbg!(release_tag)).unwrap();
3237

3338
// Build geth
3439
build_utils::check_command_output(build_result(&repo_dir), || {
35-
format!("geth make failed using release {last_release}")
40+
format!("geth make failed using release {release_tag}")
3641
});
3742
}
3843

0 commit comments

Comments
 (0)