Skip to content

Commit

Permalink
Add backward compatibility
Browse files Browse the repository at this point in the history
Signed-off-by: Danil <[email protected]>
  • Loading branch information
Deniallugo committed May 30, 2024
1 parent aab3a7f commit a18939c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
20 changes: 15 additions & 5 deletions core/lib/protobuf_config/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,21 @@ impl ProtoRepr for proto::Genesis {
type Type = configs::GenesisConfig;
fn read(&self) -> anyhow::Result<Self::Type> {
let prover = required(&self.prover).context("prover")?;
let protocol_version = if let Some(protocol_version) =
&self.genesis_protocol_semantic_version
{
ProtocolSemanticVersion::from_str(protocol_version).context("protocol_version")?
} else {
let minor_version = *required(&self.genesis_protocol_version).context("Either genesis_protocol_version or genesis_protocol_semantic_version should be presented")?;
ProtocolSemanticVersion::new(
(minor_version as u16)
.try_into()
.context("Wrong protocol version")?,
0.into(),
)
};
Ok(Self::Type {
protocol_version: Some(
required(&self.genesis_protocol_semantic_version)
.and_then(|x| ProtocolSemanticVersion::from_str(x).map_err(Into::into))
.context("protocol_version")?,
),
protocol_version: Some(protocol_version),
genesis_root_hash: Some(
required(&self.genesis_root)
.and_then(|x| parse_h256(x))
Expand Down Expand Up @@ -98,6 +107,7 @@ impl ProtoRepr for proto::Genesis {
genesis_root: this.genesis_root_hash.map(|x| format!("{:?}", x)),
genesis_rollup_leaf_index: this.rollup_last_leaf_index,
genesis_batch_commitment: this.genesis_commitment.map(|x| format!("{:?}", x)),
genesis_protocol_version: this.protocol_version.map(|x| x.minor as u64),
genesis_protocol_semantic_version: this.protocol_version.map(|x| x.to_string()),
default_aa_hash: this.default_aa_hash.map(|x| format!("{:?}", x)),
bootloader_hash: this.bootloader_hash.map(|x| format!("{:?}", x)),
Expand Down
16 changes: 8 additions & 8 deletions core/lib/protobuf_config/src/proto/config/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ message Prover {


message Genesis {
optional string genesis_root = 1; // optional; h256
optional uint64 genesis_rollup_leaf_index = 2; // optional;
optional string genesis_batch_commitment = 3; // optional; h256
optional string default_aa_hash = 5; // optional; h256
optional string bootloader_hash = 6; // optional; h256
optional uint64 l1_chain_id = 7; // optional;
optional uint64 l2_chain_id = 8; // optional;
optional string genesis_root = 1; // required; h256
optional uint64 genesis_rollup_leaf_index = 2; // required;
optional string genesis_batch_commitment = 3; // required; h256
optional uint64 genesis_protocol_version = 4; // optional;
optional string default_aa_hash = 5; // required; h256
optional string bootloader_hash = 6; // required; h256
optional uint64 l1_chain_id = 7; // required;
optional uint64 l2_chain_id = 8; // required;
optional string fee_account = 9; // h160
optional Prover prover = 10;
optional L1BatchCommitDataGeneratorMode l1_batch_commit_data_generator_mode = 29; // optional, default to rollup
optional string genesis_protocol_semantic_version = 12; // optional;
reserved 4; reserved "genesis_protocol_version";
reserved 11; reserved "shared_bridge";
}
2 changes: 2 additions & 0 deletions etc/env/file_based/genesis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ genesis_root: 0xabdb766b18a479a5c783a4b80e12686bc8ea3cc2d8a3050491b701d72370ebb5
genesis_rollup_leaf_index: 54
genesis_batch_commitment: 0x2d00e5f8d77afcebf58a6b82ae56ba967566fe7dfbcb6760319fb0d215d18ffd
genesis_protocol_semantic_version: '0.24.0'
# deprecated
genesis_protocol_version: 24,
default_aa_hash: 0x01000563374c277a2c1e34659a2a1e87371bb6d852ce142022d497bfb50b9e32
bootloader_hash: 0x010008e742608b21bf7eb23c1a9d0602047e3618b464c9b59c0fba3b3d7ab66e
l1_chain_id: 9
Expand Down

0 comments on commit a18939c

Please sign in to comment.