Skip to content

Commit

Permalink
Merge pull request #131 from Concordium/protocol-p7
Browse files Browse the repository at this point in the history
Support genesis generation for protocol version 7
  • Loading branch information
td202 authored Dec 15, 2023
2 parents 8499659 + fb7ce19 commit 6421dca
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 10 deletions.
1 change: 1 addition & 0 deletions chain-prometheus-exporter/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions generator/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions genesis-creator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

- Support genesis data format of protocol version 7.

## 0.2.0

- Support genesis data format of protocol version 6.
Expand Down
1 change: 1 addition & 0 deletions genesis-creator/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions genesis-creator/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ pub enum ProtocolConfig {
P6 {
parameters: GenesisParametersConfigV1,
},
#[serde(rename = "7")]
P7 {
parameters: GenesisParametersConfigV1,
},
}

impl ProtocolConfig {
Expand All @@ -261,6 +265,7 @@ impl ProtocolConfig {
ProtocolConfig::P4 { .. } => ProtocolVersion::P4,
ProtocolConfig::P5 { .. } => ProtocolVersion::P5,
ProtocolConfig::P6 { .. } => ProtocolVersion::P6,
ProtocolConfig::P7 { .. } => ProtocolVersion::P7,
}
}
}
25 changes: 25 additions & 0 deletions genesis-creator/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,10 @@ pub enum GenesisData {
core: CoreGenesisParametersV1,
initial_state: GenesisStateCPV2,
},
P7 {
core: CoreGenesisParametersV1,
initial_state: GenesisStateCPV2,
},
}

impl GenesisData {
Expand Down Expand Up @@ -661,6 +665,16 @@ impl GenesisData {
core.serial(&mut hasher);
initial_state.serial(&mut hasher);
}
GenesisData::P7 {
core,
initial_state,
} => {
ProtocolVersion::P7.serial(&mut hasher);
// tag of initial genesis
0u8.serial(&mut hasher);
core.serial(&mut hasher);
initial_state.serial(&mut hasher);
}
}
let bytes: [u8; 32] = hasher.finalize().into();
bytes.into()
Expand Down Expand Up @@ -688,6 +702,7 @@ pub fn make_genesis_data_cpv0(
ProtocolVersion::P4 => None,
ProtocolVersion::P5 => None,
ProtocolVersion::P6 => None,
ProtocolVersion::P7 => None,
}
}

Expand Down Expand Up @@ -755,6 +770,16 @@ impl Serial for GenesisData {
core.serial(out);
initial_state.serial(out)
}
GenesisData::P7 {
core,
initial_state,
} => {
9u8.serial(out);
// tag of initial genesis
0u8.serial(out);
core.serial(out);
initial_state.serial(out)
}
}
}
}
32 changes: 24 additions & 8 deletions genesis-creator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ pub fn handle_assemble(config_path: &Path, verbose: bool) -> anyhow::Result<()>
}
}
}
ProtocolConfig::P6 { parameters } => {
ProtocolConfig::P6 { parameters } | ProtocolConfig::P7 { parameters } => {
let update_keys = read_json(&make_relative(config_path, &config.governance_keys)?)?;

let initial_state = GenesisStateCPV2 {
Expand All @@ -983,9 +983,17 @@ pub fn handle_assemble(config_path: &Path, verbose: bool) -> anyhow::Result<()>
leadership_election_nonce: parameters.leadership_election_nonce,
accounts,
};
GenesisData::P6 {
core: parameters.core.try_into()?,
initial_state,
let core = parameters.core.try_into()?;
match protocol_version {
ProtocolVersion::P6 => GenesisData::P6 {
core,
initial_state,
},
ProtocolVersion::P7 => GenesisData::P7 {
core,
initial_state,
},
_ => unreachable!("Already checked."),
}
}
};
Expand Down Expand Up @@ -1189,7 +1197,7 @@ pub fn handle_generate(config_path: &Path, verbose: bool) -> anyhow::Result<()>
}
}
}
ProtocolConfig::P6 { parameters } => {
ProtocolConfig::P6 { parameters } | ProtocolConfig::P7 { parameters } => {
let update_keys = updates_v1(config.out.update_keys, config.updates)?;

let initial_state = GenesisStateCPV2 {
Expand All @@ -1201,9 +1209,17 @@ pub fn handle_generate(config_path: &Path, verbose: bool) -> anyhow::Result<()>
leadership_election_nonce: parameters.leadership_election_nonce,
accounts,
};
GenesisData::P6 {
core: parameters.core.try_into()?,
initial_state,
let core = parameters.core.try_into()?;
match protocol_version {
ProtocolVersion::P6 => GenesisData::P6 {
core,
initial_state,
},
ProtocolVersion::P7 => GenesisData::P7 {
core,
initial_state,
},
_ => unreachable!("Already checked."),
}
}
};
Expand Down
1 change: 1 addition & 0 deletions id-verifier/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions kpi-tracker/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion recover-id-object/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions state-compare/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6421dca

Please sign in to comment.