From 8438ed495c2b11f4c72872eaf9df16d243ce48c2 Mon Sep 17 00:00:00 2001 From: simonjiao Date: Fri, 24 May 2024 09:39:20 +0800 Subject: [PATCH] update genesis files for halley/proxima (#4113) * avoid failure when creating block * fix init_scripts for stdlib 12 * add tests for halley/proxima * fix config test --- config/example/proxima/genesis_config.json | 2 +- config/src/genesis_config.rs | 6 ++-- executor/tests/executor_test.rs | 33 +++++++++++++++++++-- genesis/generated/halley/genesis | Bin 92739 -> 92748 bytes genesis/generated/proxima/genesis | Bin 92691 -> 92700 bytes vm/transaction-builder/src/lib.rs | 3 +- 6 files changed, 38 insertions(+), 6 deletions(-) diff --git a/config/example/proxima/genesis_config.json b/config/example/proxima/genesis_config.json index 938b472b79..deded93b32 100644 --- a/config/example/proxima/genesis_config.json +++ b/config/example/proxima/genesis_config.json @@ -527,5 +527,5 @@ }, "time_service_type": "RealTimeService", "transaction_timeout": 86400, - "dag_effective_height": 0 + "dag_effective_height": 1 } diff --git a/config/src/genesis_config.rs b/config/src/genesis_config.rs index bdaebba503..562f08e61d 100644 --- a/config/src/genesis_config.rs +++ b/config/src/genesis_config.rs @@ -881,7 +881,8 @@ pub static G_HALLEY_CONFIG: Lazy = Lazy::new(|| { min_action_delay: 60 * 60 * 1000, // 1h }, transaction_timeout: ONE_DAY, - dag_effective_height: 0, + // todo: rollback it to zero and initialize BlockDag properly + dag_effective_height: 1u64, } }); @@ -940,7 +941,8 @@ pub static G_PROXIMA_CONFIG: Lazy = Lazy::new(|| { min_action_delay: 60 * 1000, // 1 minute }, transaction_timeout: ONE_DAY, - dag_effective_height: 0, + // todo: rollback it to zero and initialize BlockDag properly + dag_effective_height: 1u64, } }); diff --git a/executor/tests/executor_test.rs b/executor/tests/executor_test.rs index 1747d1f7a4..d45015e78f 100644 --- a/executor/tests/executor_test.rs +++ b/executor/tests/executor_test.rs @@ -3,6 +3,7 @@ use anyhow::anyhow; use anyhow::Result; +use starcoin_config::{BuiltinNetworkID, ChainNetwork}; use starcoin_executor::validate_transaction; use starcoin_logger::prelude::*; use starcoin_transaction_builder::{ @@ -28,8 +29,8 @@ use starcoin_vm_types::vm_status::KeptVMStatus; use starcoin_vm_types::{transaction::Package, vm_status::StatusCode}; use test_helper::executor::{ account_execute, account_execute_should_success, association_execute_should_success, - blockmeta_execute, build_raw_txn, current_block_number, TEST_MODULE, TEST_MODULE_1, - TEST_MODULE_2, + blockmeta_execute, build_raw_txn, current_block_number, prepare_customized_genesis, + TEST_MODULE, TEST_MODULE_1, TEST_MODULE_2, }; use test_helper::executor::{ @@ -111,6 +112,34 @@ fn test_flexidag_config_get() { assert_eq!(read_version, version); } +#[stest::test] +fn test_flexidag_config_get_for_halley() { + let chain_state = + prepare_customized_genesis(&ChainNetwork::new_builtin(BuiltinNetworkID::Halley)); + + let version = { + let mut vm = StarcoinVM::new(None); + vm.load_configs(&chain_state).unwrap(); + vm.get_flexidag_config().unwrap().effective_height + }; + + assert_eq!(version, 1); +} + +#[stest::test] +fn test_flexidag_config_get_for_proxima() { + let chain_state = + prepare_customized_genesis(&ChainNetwork::new_builtin(BuiltinNetworkID::Proxima)); + + let version = { + let mut vm = StarcoinVM::new(None); + vm.load_configs(&chain_state).unwrap(); + vm.get_flexidag_config().unwrap().effective_height + }; + + assert_eq!(version, 1); +} + #[stest::test] fn test_consensus_config_get() -> Result<()> { let (chain_state, _net) = prepare_genesis(); diff --git a/genesis/generated/halley/genesis b/genesis/generated/halley/genesis index b3476de34f6637993c65c646dfa2f4c482094465..22cac4c47f7e392e9c6e6555ff79b8ac7522b483 100644 GIT binary patch delta 212 zcmV;_04x8))CJ7c1&~7^H>xz-Z>oX=8xOzr?&%0J_8B+l-*R3;TQRh!DNS}jkz*qt z?&J%0iJseeN-d8>4_Y!B?XH{bya1(T*RHzz8B_Ao%l`C0W_2Ou9%K zq%uHB^3n%Iku;JLa}aQ#FRI|PF@f&2?g7nT12X_Cx4vKj`UnCD0gj O$JK?M+EkSa%MJjKh-J?J delta 209 zcmV;?051Q`)CI%T1&~7^2zcV#K!+A4fh`^u1?mrdJG0xtHtl3pxj-5SP(u0XjiRQq_Dv zO!6pI1lzu2@?-Tt(#MpXaI#l<1IuAS%jLH1&~7^%zqu}BMH4T4F2ZDb9|Q?`?}K)oJeIfU*2wM573KCkz*nt zZ!m$j6(X%@YQlUCbBKaC=djDc1=H@*?p{++r!d+klhKYJk-!KdWFR##^J^zfdmt%l znf{o%LGtZmtuKa3*pPiPe(V+89j}4zweA7UUjs7$E4RL20m=vh2mz6?7nhi60Xjh{ zTSlV&9dj_f7g^!K6t;LP&8CbvPQ2+f!HEuLh4^9blx)VLX59@3i7KJQ>Wz@q@w{Km P^}z!rFzXFJ;mZU7aZO|q delta 210 zcmV;@04@KV)CH5&1&~7^0b;q(bXc2lel&#Ops}o77$zz|BnhsZ Result { let init_script = match net.genesis_config().stdlib_version { StdlibVersion::Version(1) => build_init_script_v1(net), - _ => build_init_script_v2(net), + version if version < StdlibVersion::Version(12) => build_init_script_v2(net), + _ => build_init_script_v3(net), }; stdlib_package(stdlib_option, Some(init_script)) }