Skip to content

Commit 9d5bb51

Browse files
authored
versions: collapse post per-epoch reward upgrades into V6 (0.6) (#4304)
* include requested height in cert2 not-found error * versions: collapse DA, VID2, and cliquenet to v0.6 * fix version in tests * more cleanup * remove v6 from devnode * update AGENTS.md * more cleanup
1 parent ce075c9 commit 9d5bb51

28 files changed

Lines changed: 138 additions & 267 deletions

File tree

AGENTS.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ just demo-native # Full local network via process-compose
7070
- Use `forge fmt` before committing
7171
- Upgradeable contracts: V2 extends V1, never modify V1 storage
7272
- Events: Emit for all state changes that external systems need to track
73-
- Contract ABIs are supersets: V3 includes all V2 types, V2 includes all V1 types. Always use the
74-
latest version's Rust bindings (`StakeTableV3`) for runtime code (contract calls, event decoding).
75-
V1/V2 bindings are only needed in deploy/upgrade code.
73+
- Contract ABIs are supersets: V3 includes all V2 types, V2 includes all V1 types. Always use the latest version's Rust
74+
bindings (`StakeTableV3`) for runtime code (contract calls, event decoding). V1/V2 bindings are only needed in
75+
deploy/upgrade code.
7676

7777
## Architecture Overview
7878

@@ -212,14 +212,14 @@ table sync.
212212
Versions in `crates/espresso/types/src/v0/mod.rs`. `SequencerVersions<Base, Upgrade>` defines version pairs for network
213213
operation.
214214

215-
| Version | Alias | Key Changes |
216-
| ------- | ---------------------------- | -------------------------------------------------------------------------- |
217-
| V0_1 | - | Base types: Header, ChainConfig, Transaction, ADVZ VID proofs |
218-
| V0_2 | `FeeVersion` | Fee support (version marker) |
219-
| V0_3 | `EpochVersion` | PoS: stake_table_contract, reward_merkle_tree, AvidM VID proofs |
220-
| V0_4 | `DrbAndHeaderUpgradeVersion` | Header adds timestamp_millis, total_reward_distributed, RewardMerkleTreeV2 |
221-
| V0_5 | `DaUpgradeVersion` | DA upgrade (version marker) |
222-
| V0_6 | `Vid2UpgradeVersion` | VID2 (AvidmGf2) proofs |
215+
| Version | Alias | Key Changes |
216+
| ------- | ---------------------------- | ------------------------------------------------------------------------------- |
217+
| V0_1 | - | Base types: Header, ChainConfig, Transaction, ADVZ VID proofs |
218+
| V0_2 | `FeeVersion` | Fee support (version marker) |
219+
| V0_3 | `EpochVersion` | PoS: stake_table_contract, reward_merkle_tree, AvidM VID proofs |
220+
| V0_4 | `DrbAndHeaderUpgradeVersion` | Header adds timestamp_millis, total_reward_distributed, RewardMerkleTreeV2 |
221+
| V0_5 | `EpochRewardVersion` | Epoch reward / DRB fix |
222+
| V0_6 | `NEW_PROTOCOL_VERSION` | DA upgrade + VID2 (AvidmGf2) proofs + cliquenet + new protocol (bundled at 0.6) |
223223

224224
## Consensus Upgrades
225225

crates/espresso/dev-node/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ pub enum DevNodeVersion {
4242
V0_4,
4343
#[value(name = "0.5")]
4444
V0_5,
45-
#[value(name = "0.6")]
46-
V0_6,
4745
}
4846

4947
impl fmt::Display for DevNodeVersion {
@@ -52,7 +50,6 @@ impl fmt::Display for DevNodeVersion {
5250
DevNodeVersion::V0_3 => write!(f, "0.3"),
5351
DevNodeVersion::V0_4 => write!(f, "0.4"),
5452
DevNodeVersion::V0_5 => write!(f, "0.5"),
55-
DevNodeVersion::V0_6 => write!(f, "0.6"),
5653
}
5754
}
5855
}

crates/espresso/dev-node/src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,6 @@ async fn async_main(migrated_envs: Vec<(&str, &str)>) -> anyhow::Result<()> {
670670
DevNodeVersion::V0_3 => Upgrade::trivial(versions::version(0, 3)),
671671
DevNodeVersion::V0_4 => Upgrade::trivial(versions::version(0, 4)),
672672
DevNodeVersion::V0_5 => Upgrade::trivial(versions::version(0, 5)),
673-
DevNodeVersion::V0_6 => Upgrade::trivial(versions::version(0, 6)),
674673
};
675674
TestNetwork::new(config, u).await
676675
};

crates/espresso/dev-node/tests/dev_node_tests.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,7 @@ impl Drop for BackgroundProcess {
4747
#[rstest::rstest]
4848
#[test_log::test(tokio::test(flavor = "multi_thread"))]
4949
async fn slow_dev_node_test(
50-
#[values(
51-
DevNodeVersion::V0_3,
52-
DevNodeVersion::V0_4,
53-
DevNodeVersion::V0_5,
54-
DevNodeVersion::V0_6
55-
)]
50+
#[values(DevNodeVersion::V0_3, DevNodeVersion::V0_4, DevNodeVersion::V0_5)]
5651
version: DevNodeVersion,
5752
) {
5853
let builder_port = reserve_tcp_port().unwrap();

crates/espresso/keyset/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ impl TryFrom<KeySetOptions> for KeySet {
175175
bail!("neither mnemonic, key file nor full set of private keys was provided")
176176
};
177177

178-
// TODO: remove this fallback once the network upgrades to CLIQUENET_VERSION and x25519
178+
// TODO: remove this fallback once the network upgrades to NEW_PROTOCOL_VERSION and x25519
179179
// keys become required. For now, generate a random key so existing deployments without an
180180
// x25519 key configured can still start.
181181
let x25519 = match x25519 {

crates/espresso/node/src/api.rs

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3257,7 +3257,10 @@ mod test {
32573257
};
32583258
use tokio::time::sleep;
32593259
use vbs::version::StaticVersion;
3260-
use versions::{DRB_AND_HEADER_UPGRADE_VERSION, EPOCH_VERSION, FEE_VERSION, Upgrade, version};
3260+
use versions::{
3261+
DRB_AND_HEADER_UPGRADE_VERSION, EPOCH_REWARD_VERSION, EPOCH_VERSION, FEE_VERSION, Upgrade,
3262+
version,
3263+
};
32613264

32623265
use self::{
32633266
data_source::testing::TestableSequencerDataSource, options::HotshotEvents,
@@ -4983,7 +4986,7 @@ mod test {
49834986
const EPOCH_HEIGHT: u64 = 10;
49844987
const NUM_NODES: usize = 5;
49854988

4986-
const V6: Upgrade = Upgrade::trivial(version(0, 6));
4989+
const V5: Upgrade = Upgrade::trivial(EPOCH_REWARD_VERSION);
49874990

49884991
let network_config = TestConfigBuilder::default()
49894992
.epoch_height(EPOCH_HEIGHT)
@@ -5014,12 +5017,12 @@ mod test {
50145017
&NoMetrics,
50155018
)
50165019
}))
5017-
.pos_hook(DelegationConfig::MultipleDelegators, Default::default(), V6)
5020+
.pos_hook(DelegationConfig::MultipleDelegators, Default::default(), V5)
50185021
.await
50195022
.unwrap()
50205023
.build();
50215024

5022-
let _network = TestNetwork::new(config, V6).await;
5025+
let _network = TestNetwork::new(config, V5).await;
50235026
let client: Client<ServerError, SequencerApiVersion> =
50245027
Client::new(format!("http://localhost:{api_port}").parse().unwrap());
50255028

@@ -5088,7 +5091,7 @@ mod test {
50885091
const EPOCH_HEIGHT: u64 = 10;
50895092
const NUM_NODES: usize = 5;
50905093

5091-
const V6: Upgrade = Upgrade::trivial(version(0, 6));
5094+
const V5: Upgrade = Upgrade::trivial(EPOCH_REWARD_VERSION);
50925095

50935096
let network_config = TestConfigBuilder::default()
50945097
.epoch_height(EPOCH_HEIGHT)
@@ -5119,12 +5122,12 @@ mod test {
51195122
&NoMetrics,
51205123
)
51215124
}))
5122-
.pos_hook(DelegationConfig::MultipleDelegators, Default::default(), V6)
5125+
.pos_hook(DelegationConfig::MultipleDelegators, Default::default(), V5)
51235126
.await
51245127
.unwrap()
51255128
.build();
51265129

5127-
let _network = TestNetwork::new(config, V6).await;
5130+
let _network = TestNetwork::new(config, V5).await;
51285131
let client: Client<ServerError, SequencerApiVersion> =
51295132
Client::new(format!("http://localhost:{api_port}").parse().unwrap());
51305133

@@ -5205,7 +5208,7 @@ mod test {
52055208
const EPOCH_HEIGHT: u64 = 10;
52065209
const NUM_NODES: usize = 5;
52075210
const NUM_EPOCHS: u64 = 6;
5208-
const V6: Upgrade = Upgrade::trivial(version(0, 6));
5211+
const V5: Upgrade = Upgrade::trivial(EPOCH_REWARD_VERSION);
52095212

52105213
let network_config = TestConfigBuilder::default()
52115214
.epoch_height(EPOCH_HEIGHT)
@@ -5236,12 +5239,12 @@ mod test {
52365239
&NoMetrics,
52375240
)
52385241
}))
5239-
.pos_hook(DelegationConfig::MultipleDelegators, Default::default(), V6)
5242+
.pos_hook(DelegationConfig::MultipleDelegators, Default::default(), V5)
52405243
.await
52415244
.unwrap()
52425245
.build();
52435246

5244-
let network = TestNetwork::new(config, V6).await;
5247+
let network = TestNetwork::new(config, V5).await;
52455248
let client: Client<ServerError, SequencerApiVersion> =
52465249
Client::new(format!("http://localhost:{api_port}").parse().unwrap());
52475250

@@ -5298,13 +5301,13 @@ mod test {
52985301
Ok(())
52995302
}
53005303

5301-
/// Verifies that the `leader_counts` array in V6 headers is correct.
5304+
/// Verifies that the `leader_counts` array in V5+ headers is correct.
53025305
#[test_log::test(tokio::test(flavor = "multi_thread"))]
53035306
async fn test_epoch_leader_counts() -> anyhow::Result<()> {
53045307
const EPOCH_HEIGHT: u64 = 10;
53055308
const NUM_NODES: usize = 5;
53065309
const NUM_EPOCHS: u64 = 6;
5307-
const V6: Upgrade = Upgrade::trivial(version(0, 6));
5310+
const V5: Upgrade = Upgrade::trivial(EPOCH_REWARD_VERSION);
53085311

53095312
let network_config = TestConfigBuilder::default()
53105313
.epoch_height(EPOCH_HEIGHT)
@@ -5335,12 +5338,12 @@ mod test {
53355338
&NoMetrics,
53365339
)
53375340
}))
5338-
.pos_hook(DelegationConfig::MultipleDelegators, Default::default(), V6)
5341+
.pos_hook(DelegationConfig::MultipleDelegators, Default::default(), V5)
53395342
.await
53405343
.unwrap()
53415344
.build();
53425345

5343-
let network = TestNetwork::new(config, V6).await;
5346+
let network = TestNetwork::new(config, V5).await;
53445347
let client: Client<ServerError, SequencerApiVersion> =
53455348
Client::new(format!("http://localhost:{api_port}").parse().unwrap());
53465349

@@ -5369,7 +5372,7 @@ mod test {
53695372

53705373
let header_leader_counts = header
53715374
.leader_counts()
5372-
.expect("V6 header must have leader_counts");
5375+
.expect("V5+ header must have leader_counts");
53735376

53745377
// Reset counts at the start of a new epoch
53755378
let is_epoch_start = (height - 1) % EPOCH_HEIGHT == 0;

crates/espresso/node/src/api/light_client.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,11 @@ where
9696
.load_earliest_cert2(requested_height)
9797
.await
9898
.map_err(internal)?
99-
.ok_or_else(|| not_found("no cert2 finality proof available"))?;
99+
.ok_or_else(|| {
100+
not_found(format!(
101+
"no cert2 finality proof available at or after height {requested_height}"
102+
))
103+
})?;
100104

101105
let cert2_height = cert2.data.block_number;
102106
if cert2_height < requested_height {

crates/espresso/node/src/consensus_handle.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use hotshot_types::{
3030
};
3131
use tokio::spawn;
3232
use tokio_util::task::AbortOnDropHandle;
33-
use versions::version;
33+
use versions::NEW_PROTOCOL_VERSION;
3434

3535
// TODO: `ConsensusOutput::LeafDecided` still carries fields (leaves +
3636
// vid_shares) rather than a `Vec<LeafInfo>`. This is because `Consensus` doesn't own `StateManager`
@@ -173,7 +173,7 @@ where
173173
.hotshot
174174
.upgrade_lock
175175
.version_infallible(view)
176-
>= version(0, 8)
176+
>= NEW_PROTOCOL_VERSION
177177
}
178178

179179
async fn new_protocol(&self) -> bool {

crates/espresso/node/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,10 +464,10 @@ where
464464
);
465465

466466
// Publish our cliquenet `connect_info` into the stake table from
467-
// `CLIQUENET_VERSION` on, so peers can dial us. Modify `validator_config`
467+
// `NEW_PROTOCOL_VERSION` on, so peers can dial us. Modify `validator_config`
468468
// in place so the same `connect_info` is sent later when posting to
469469
// `/ready` (the orchestrator equality-checks against `known_nodes_with_stake`).
470-
if genesis.base_version >= versions::CLIQUENET_VERSION {
470+
if genesis.base_version >= versions::NEW_PROTOCOL_VERSION {
471471
let advertise_addr = network_params.cliquenet_advertise_addr.clone().context(
472472
"ESPRESSO_NODE_CLIQUENET_ADVERTISE_ADDRESS must be set when bootstrapping a \
473473
Cliquenet network from the orchestrator",
@@ -856,7 +856,7 @@ async fn check_cliquenet_info_registered(
856856
stake_table_contract: Option<alloy::primitives::Address>,
857857
l1_client: &espresso_types::v0::L1Client,
858858
) {
859-
if current_version != versions::VID2_UPGRADE_VERSION {
859+
if current_version != versions::EPOCH_REWARD_VERSION {
860860
return;
861861
}
862862
let Some(addr) = stake_table_contract else {

crates/espresso/types/src/reference_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ fn reference_stake_table_hash() -> StakeTableHash {
220220
let events: Vec<(EventKey, StakeTableEvent)> = serde_json::from_str(&events_json).unwrap();
221221

222222
// Reconstruct stake table from events
223-
// TODO: once V3 fixtures include x25519/p2p data, exercise CLIQUENET_VERSION here too.
223+
// TODO: once V3 fixtures include x25519/p2p data, exercise NEW_PROTOCOL_VERSION here too.
224224
ValidatorSet::from_l1_events(events.into_iter().map(|(_, e)| e), EPOCH_VERSION)
225225
.unwrap()
226226
.stake_table_hash

0 commit comments

Comments
 (0)