diff --git a/data/genesis/demo.toml b/data/genesis/demo.toml index 3493200e6..23d80dd1a 100644 --- a/data/genesis/demo.toml +++ b/data/genesis/demo.toml @@ -22,3 +22,10 @@ base_fee = '1 wei' max_block_size = '1mb' fee_recipient = '0x0000000000000000000000000000000000000000' fee_contract = '0xa15bb66138824a1c7167f5e85b957d04dd34e468' + +[[upgrade]] +version = "0.4" +start_proposing_view = 5 +stop_proposing_view = 15 + +[upgrade.marketplace] \ No newline at end of file diff --git a/data/messages.bin b/data/messages.bin index 046ea94db..64ba1cde6 100644 Binary files a/data/messages.bin and b/data/messages.bin differ diff --git a/data/messages.json b/data/messages.json index 66c20bee9..e79962a85 100644 --- a/data/messages.json +++ b/data/messages.json @@ -7,33 +7,41 @@ "_pd": null, "data": { "block_header": { - "block_merkle_tree_root": "MERKLE_COMM~AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAQA", - "builder_commitment": "BUILDER_COMMITMENT~tEvs0rxqOiMCvfe2R0omNNaphSlUiEDrb2q0IZpRcgA_", - "builder_signature": null, - "chain_config": { + "fields": { + "block_merkle_tree_root": "MERKLE_COMM~AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAQA", + "builder_commitment": "BUILDER_COMMITMENT~tEvs0rxqOiMCvfe2R0omNNaphSlUiEDrb2q0IZpRcgA_", + "builder_signature": null, "chain_config": { - "Left": { - "base_fee": "0", - "chain_id": "35353", - "fee_contract": null, - "fee_recipient": "0x0000000000000000000000000000000000000000", - "max_block_size": "30720" + "chain_config": { + "Left": { + "base_fee": "0", + "chain_id": "35353", + "fee_contract": null, + "fee_recipient": "0x0000000000000000000000000000000000000000", + "max_block_size": "30720" + } } - } - }, - "fee_info": { - "account": "0x0000000000000000000000000000000000000000", - "amount": "0" - }, - "fee_merkle_tree_root": "MERKLE_COMM~AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAKA", - "height": 0, - "l1_finalized": null, - "l1_head": 0, - "ns_table": { - "bytes": "AAAAAA==" + }, + "fee_info": { + "account": "0x0000000000000000000000000000000000000000", + "amount": "0" + }, + "fee_merkle_tree_root": "MERKLE_COMM~AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAKA", + "height": 0, + "l1_finalized": null, + "l1_head": 0, + "ns_table": { + "bytes": "AAAAAA==" + }, + "payload_commitment": "HASH~AazstQer_ho1SqgGT0r10_Gs0BnjfbPBHJdSO3HHbp29", + "timestamp": 0 }, - "payload_commitment": "HASH~AazstQer_ho1SqgGT0r10_Gs0BnjfbPBHJdSO3HHbp29", - "timestamp": 0 + "version": { + "Version": { + "major": 0, + "minor": 2 + } + } }, "justify_qc": { "_pd": null, diff --git a/data/v2/header.bin b/data/v2/header.bin index 6faa7f07f..93174ba7a 100644 Binary files a/data/v2/header.bin and b/data/v2/header.bin differ diff --git a/data/v3/chain_config.bin b/data/v3/chain_config.bin new file mode 100644 index 000000000..92c05b086 Binary files /dev/null and b/data/v3/chain_config.bin differ diff --git a/data/v3/chain_config.json b/data/v3/chain_config.json new file mode 100644 index 000000000..5c39b238a --- /dev/null +++ b/data/v3/chain_config.json @@ -0,0 +1,8 @@ +{ + "base_fee": "0", + "bid_recipient": "0x0000000000000000000000000000000000000000", + "chain_id": "35353", + "fee_contract": "0x0000000000000000000000000000000000000000", + "fee_recipient": "0x0000000000000000000000000000000000000000", + "max_block_size": "10240" +} \ No newline at end of file diff --git a/data/v3/header.bin b/data/v3/header.bin index f9331c9ac..8e50a6eba 100644 Binary files a/data/v3/header.bin and b/data/v3/header.bin differ diff --git a/data/v3/header.json b/data/v3/header.json index 2d3423adb..2b8fa1234 100644 --- a/data/v3/header.json +++ b/data/v3/header.json @@ -18,7 +18,7 @@ "chain_config": { "Left": { "base_fee": "0", - "bid_recipient": null, + "bid_recipient": "0x0000000000000000000000000000000000000000", "chain_id": "35353", "fee_contract": "0x0000000000000000000000000000000000000000", "fee_recipient": "0x0000000000000000000000000000000000000000", diff --git a/types/src/reference_tests.rs b/types/src/reference_tests.rs index 13045b804..238513ac2 100755 --- a/types/src/reference_tests.rs +++ b/types/src/reference_tests.rs @@ -24,7 +24,6 @@ use std::{fmt::Debug, path::Path, str::FromStr}; use committable::Committable; -use es_version::SequencerVersion; use hotshot_query_service::availability::QueryablePayload; use hotshot_types::traits::{ block_contents::vid_commitment, signature_key::BuilderSignatureKey, BlockPayload, EncodeBytes, @@ -42,11 +41,13 @@ use vbs::{ }; use crate::{ - v0_3::ChainConfig, FeeAccount, FeeInfo, Header, L1BlockInfo, NamespaceId, NsTable, Payload, - SeqTypes, Transaction, ValidatedState, + v0_1, FeeAccount, FeeInfo, Header, L1BlockInfo, NamespaceId, NsTable, Payload, SeqTypes, + Transaction, ValidatedState, }; -type Serializer = vbs::Serializer; +type V1Serializer = vbs::Serializer>; +type V2Serializer = vbs::Serializer>; +type V3Serializer = vbs::Serializer>; async fn reference_payload() -> Payload { const NUM_NS_IDS: usize = 3; @@ -91,20 +92,23 @@ fn reference_l1_block() -> L1BlockInfo { const REFERENCE_L1_BLOCK_COMMITMENT: &str = "L1BLOCK~4HpzluLK2Isz3RdPNvNrDAyQcWOF2c9JeLZzVNLmfpQ9"; -fn reference_chain_config() -> ChainConfig { - ChainConfig { +fn reference_chain_config() -> crate::v0_3::ChainConfig { + crate::v0_3::ChainConfig { chain_id: 0x8a19.into(), max_block_size: 10240.into(), base_fee: 0.into(), fee_contract: Some(Default::default()), fee_recipient: Default::default(), - bid_recipient: None, + bid_recipient: Some(Default::default()), } } -const REFERENCE_CHAIN_CONFIG_COMMITMENT: &str = +const REFERENCE_V1_CHAIN_CONFIG_COMMITMENT: &str = "CHAIN_CONFIG~L6HmMktJbvnEGgpmRrsiYvQmIBstSj9UtDM7eNFFqYFO"; +const REFERENCE_V3_CHAIN_CONFIG_COMMITMENT: &str = + "CHAIN_CONFIG~1mJTBiaJ0Nyuu4Ir5IZTamyI8CjexbktPkRr6R1rtnGh"; + fn reference_fee_info() -> FeeInfo { FeeInfo::new( FeeAccount::from_str("0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266").unwrap(), @@ -150,7 +154,7 @@ async fn reference_header(version: Version) -> Header { const REFERENCE_V1_HEADER_COMMITMENT: &str = "BLOCK~dh1KpdvvxSvnnPpOi2yI3DOg8h6ltr2Kv13iRzbQvtN2"; const REFERENCE_V2_HEADER_COMMITMENT: &str = "BLOCK~V0GJjL19nCrlm9n1zZ6gaOKEekSMCT6uR5P-h7Gi6UJR"; -const REFERENCE_V3_HEADER_COMMITMENT: &str = "BLOCK~pD6_in2J8VzT6SshvvFUkNyMbx_h_gTtlU3WTmC6WedD"; +const REFERENCE_V3_HEADER_COMMITMENT: &str = "BLOCK~oqbUzqJdG4JfWCDpCQWsLDjb47Rx_OH6KVsKQFOl4S2n"; fn reference_transaction(ns_id: NamespaceId, rng: &mut R) -> Transaction where @@ -223,7 +227,13 @@ change in the serialization of this data structure. // Check that the reference object matches the expected binary form. let expected = std::fs::read(data_dir.join(format!("{name}.bin"))).unwrap(); - let actual = Serializer::serialize(&reference).unwrap(); + // todo (ab) : cleanup + let actual = match version { + "v1" => V1Serializer::serialize(&reference).unwrap(), + "v2" => V2Serializer::serialize(&reference).unwrap(), + "v3" => V3Serializer::serialize(&reference).unwrap(), + _ => panic!("invalid version"), + }; if actual != expected { // Write the actual output to a file to make it easier to compare with/replace the expected // file if the serialization change was actually intended. @@ -246,7 +256,14 @@ change in the serialization of this data structure. } // Check that we can deserialize from the reference binary object. - let parsed: T = Serializer::deserialize(&expected).unwrap(); + // todo: (ab) cleanup + let parsed: T = match version { + "v1" => V1Serializer::deserialize(&expected).unwrap(), + "v2" => V2Serializer::deserialize(&expected).unwrap(), + "v3" => V3Serializer::deserialize(&expected).unwrap(), + _ => panic!("invalid version"), + }; + assert_eq!( *reference, parsed, "Reference object commitment does not match commitment of parsed binary object. This is @@ -320,12 +337,22 @@ fn test_reference_l1_block() { } #[test] -fn test_reference_chain_config() { +fn test_reference_v1_chain_config() { reference_test( "v1", "chain_config", + v0_1::ChainConfig::from(reference_chain_config()), + REFERENCE_V1_CHAIN_CONFIG_COMMITMENT, + ); +} + +#[test] +fn test_reference_v3_chain_config() { + reference_test( + "v3", + "chain_config", reference_chain_config(), - REFERENCE_CHAIN_CONFIG_COMMITMENT, + REFERENCE_V3_CHAIN_CONFIG_COMMITMENT, ); } @@ -340,21 +367,27 @@ fn test_reference_fee_info() { } #[async_std::test] -async fn test_reference_header() { +async fn test_reference_header_v1() { reference_test( "v1", "header", reference_header(StaticVersion::<0, 1>::version()).await, REFERENCE_V1_HEADER_COMMITMENT, ); +} +#[async_std::test] +async fn test_reference_header_v2() { reference_test( "v2", "header", reference_header(StaticVersion::<0, 2>::version()).await, REFERENCE_V2_HEADER_COMMITMENT, ); +} +#[async_std::test] +async fn test_reference_header_v3() { reference_test( "v3", "header", @@ -362,7 +395,6 @@ async fn test_reference_header() { REFERENCE_V3_HEADER_COMMITMENT, ); } - #[test] fn test_reference_transaction() { reference_test(