Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
stdlib v12 gas schedule refactor (#3960)
* add stdlib upgrade init_script test

* add stdlib v12 files

* add stdlib v12 files

* refactor stdlib 12 vm execution

* update compiled files

* fix GasSchedule diff

* update test_package_init_function

* update test_package_init_function

* comment concurrency level

* add dev cmd concurrency_level

* reset halley genesis and comment master pr deploy halley

* add halley genesis

* update BARNARD_HARD_FORK_HEIGHT and BARNARD_HARD_FORK_HASH

* update stdlib v12 repo

* revert docker_build.yml
  • Loading branch information
nkysg committed Sep 6, 2023
1 parent 62fc18b commit 7698f19
Show file tree
Hide file tree
Showing 214 changed files with 214 additions and 192 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -442,7 +442,7 @@ starcoin-crypto = { git = "https://github.com/starcoinorg/starcoin-crypto", rev
starcoin-decrypt = { path = "commons/decrypt" }
starcoin-dev = { path = "vm/dev" }
starcoin-executor = { path = "executor" }
starcoin-framework = { git = "https://github.com/starcoinorg/starcoin-framework", rev = "0d3921265ed6a519bd09b1111949db2593a6f9c1" }
starcoin-framework = { git = "https://github.com/starcoinorg/starcoin-framework", rev = "345a3900a0064dc57a9560235bc72c12f03448b1" }
starcoin-genesis = { path = "genesis" }
starcoin-logger = { path = "commons/logger" }
starcoin-metrics = { path = "commons/metrics" }
Expand Down
1 change: 1 addition & 0 deletions cmd/starcoin/src/dev/mod.rs
Expand Up @@ -3,6 +3,7 @@

pub use call_contract_cmd::*;
pub use compile_cmd::*;
pub use concurrency_level_cmd::*;
pub use deploy_cmd::*;
pub use get_coin_cmd::*;
pub use package_cmd::*;
Expand Down
3 changes: 2 additions & 1 deletion cmd/starcoin/src/lib.rs
Expand Up @@ -141,7 +141,8 @@ pub fn add_command(
)
.subcommand(dev::panic_cmd::PanicCommand)
.subcommand(dev::sleep_cmd::SleepCommand)
.subcommand(dev::gen_block_cmd::GenBlockCommand),
.subcommand(dev::gen_block_cmd::GenBlockCommand)
.subcommand(dev::ConcurrencyLevelCommand),
)
.command(CustomCommand::with_name("contract").subcommand(contract::GetContractDataCommand))
}
2 changes: 1 addition & 1 deletion config/src/genesis_config.rs
Expand Up @@ -833,7 +833,7 @@ pub static G_HALLEY_CONFIG: Lazy<GenesisConfig> = Lazy::new(|| {
GenesisConfig {
genesis_block_parameter: GenesisBlockParameterConfig::Static(GenesisBlockParameter {
parent_hash: HashValue::sha3_256_of(b"starcoin_halley"),
timestamp: 1676002743000,
timestamp: 1693798675000,
difficulty: 100.into(),
}),
version: Version { major: 1 },
Expand Down
Binary file modified genesis/generated/halley/genesis
Binary file not shown.
7 changes: 2 additions & 5 deletions genesis/src/lib.rs
Expand Up @@ -586,7 +586,7 @@ mod tests {
return Ok(());
}
match net.stdlib_version() {
// test whether it is successful that the function initialize_v3 initializes genesis block for the gas scheduls
// test whether it is successful that the function initialize_v2 initializes genesis block for the gas schedules
// if it is, the gas schedule in genesis block will be the same as the one from the latest cost table
StdlibVersion::Version(12) | StdlibVersion::Latest => {
info!(
Expand Down Expand Up @@ -635,10 +635,7 @@ mod tests {
.ok_or_else(|| {
anyhow::anyhow!("Expect 0x1::GasSchedule::gas_schedule() return value")
})?;
let mut framework_gas_shedule = bcs_ext::from_bytes::<GasSchedule>(&data)?;
framework_gas_shedule
.entries
.retain(|(key, _value)| !key.is_empty());
let framework_gas_shedule = bcs_ext::from_bytes::<GasSchedule>(&data)?;

assert!(
!framework_gas_shedule.is_different(genesis_gas_schedule.as_ref().unwrap()),
Expand Down
4 changes: 1 addition & 3 deletions node/src/node.rs
Expand Up @@ -12,7 +12,6 @@ use futures::channel::oneshot;
use futures::executor::block_on;
use futures_timer::Delay;
use network_api::{PeerProvider, PeerSelector, PeerStrategy};
use num_cpus;
use starcoin_account_service::{AccountEventService, AccountService, AccountStorage};
use starcoin_block_relayer::BlockRelayer;
use starcoin_chain_notify::ChainNotifyHandlerService;
Expand Down Expand Up @@ -55,7 +54,6 @@ use starcoin_sync::verified_rpc_client::VerifiedRpcClient;
use starcoin_txpool::TxPoolActorService;
use starcoin_types::system_events::{SystemShutdown, SystemStarted};
use starcoin_vm_runtime::metrics::VMMetrics;
use starcoin_vm_runtime::starcoin_vm::StarcoinVM;
use std::sync::Arc;
use std::time::{Duration, SystemTime};

Expand Down Expand Up @@ -235,7 +233,7 @@ impl NodeService {
}

// XXX FIXME YSG add execute_config
StarcoinVM::set_concurrency_level_once(num_cpus::get());
// StarcoinVM::set_concurrency_level_once(num_cpus::get());
let (start_sender, start_receiver) = oneshot::channel();
let join_handle = timeout_join_handler::spawn(move || {
let system = System::with_tokio_rt(|| {
Expand Down
4 changes: 2 additions & 2 deletions storage/src/upgrade.rs
Expand Up @@ -22,10 +22,10 @@ use std::cmp::Ordering;

pub struct DBUpgrade;

pub static BARNARD_HARD_FORK_HEIGHT: BlockNumber = 9716880;
pub static BARNARD_HARD_FORK_HEIGHT: BlockNumber = 16057420;
pub static BARNARD_HARD_FORK_HASH: Lazy<HashValue> = Lazy::new(|| {
HashValue::from_hex_literal(
"0x98f32397569e26540985f0d487c5e7cc229a8c9be9afe10f973b3d95204d06d7",
"0x602bb269e3a221510f82b0b812304e767457f73ac3203663bd401ef3d29bcc97",
)
.expect("")
});
Expand Down
Binary file modified vm/stdlib/compiled/12/11-12/stdlib.blob
Binary file not shown.
Binary file modified vm/stdlib/compiled/12/11-12/stdlib/037_Account.mv
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/11-12/stdlib/057_EasyGasScript.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/11-12/stdlib/057_Oracle.mv
Binary file not shown.
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/11-12/stdlib/058_PriceOracle.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/11-12/stdlib/061_NFT.mv
Binary file not shown.
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/11-12/stdlib/063_MerkleProof.mv
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/11-12/stdlib/068_Genesis.mv
Binary file not shown.
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/11-12/stdlib/071_Genesis.mv
Binary file not shown.
Binary file not shown.
Binary file added vm/stdlib/compiled/12/11-12/stdlib/072_Genesis.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/11-12/stdlib/073_NFTGallery.mv
Binary file not shown.
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/11-12/stdlib/078_Secp256k1.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/11-12/stdlib/081_SimpleMap.mv
Binary file not shown.
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/11-12/stdlib/084_String.mv
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/11-12/stdlib/090_TypeInfo.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/11-12/stdlib/091_U256.mv
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified vm/stdlib/compiled/12/stdlib/037_Account.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/stdlib/055_GasSchedule.mv
Binary file not shown.
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/stdlib/057_EasyGasScript.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/stdlib/057_Oracle.mv
Binary file not shown.
Binary file added vm/stdlib/compiled/12/stdlib/058_EasyGasScript.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/stdlib/058_Epoch.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/stdlib/058_PriceOracle.mv
Binary file not shown.
File renamed without changes.
Binary file removed vm/stdlib/compiled/12/stdlib/059_EventUtil.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/stdlib/060_FixedPoint32.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/stdlib/061_NFT.mv
Binary file not shown.
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/stdlib/062_STCUSDOracle.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/stdlib/063_MerkleProof.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/stdlib/063_Offer.mv
Binary file not shown.
Binary file not shown.
File renamed without changes.
Binary file removed vm/stdlib/compiled/12/stdlib/065_LanguageVersion.mv
Binary file not shown.
File renamed without changes.
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/stdlib/068_Genesis.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/stdlib/068_IdentifierNFT.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/stdlib/069_GenesisNFT.mv
Binary file not shown.
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/stdlib/071_Genesis.mv
Binary file not shown.
Binary file not shown.
Binary file added vm/stdlib/compiled/12/stdlib/072_Genesis.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/stdlib/072_GenesisNFTScripts.mv
Binary file not shown.
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/stdlib/073_NFTGallery.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/stdlib/074_MintDaoProposal.mv
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/stdlib/077_NFTGalleryScripts.mv
Binary file not shown.
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/stdlib/078_Secp256k1.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/stdlib/080_PriceOracleScripts.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/stdlib/081_SimpleMap.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/stdlib/082_Signature.mv
Binary file not shown.
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/stdlib/083_StarcoinVerifier.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/stdlib/084_String.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/stdlib/085_StructuredHash.mv
Binary file not shown.
Binary file not shown.
File renamed without changes.
Binary file removed vm/stdlib/compiled/12/stdlib/088_Table.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/stdlib/088_TransferScripts.mv
Binary file not shown.
File renamed without changes.
Binary file removed vm/stdlib/compiled/12/stdlib/089_TransactionTimeout.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/stdlib/089_TreasuryScripts.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/stdlib/090_TypeInfo.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/stdlib/091_U256.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/stdlib/092_YieldFarming.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/12/stdlib/093_YieldFarmingV2.mv
Binary file not shown.
Binary file modified vm/stdlib/compiled/latest/stdlib/037_Account.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/latest/stdlib/057_EasyGasScript.mv
Binary file not shown.
Binary file not shown.
Binary file removed vm/stdlib/compiled/latest/stdlib/058_Epoch.mv
Binary file not shown.
File renamed without changes.
Binary file removed vm/stdlib/compiled/latest/stdlib/059_EventUtil.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/latest/stdlib/060_FixedPoint32.mv
Binary file not shown.
Binary file not shown.
Binary file removed vm/stdlib/compiled/latest/stdlib/062_STCUSDOracle.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/latest/stdlib/063_Offer.mv
Binary file not shown.
File renamed without changes.
Binary file removed vm/stdlib/compiled/latest/stdlib/065_LanguageVersion.mv
Binary file not shown.
File renamed without changes.
Binary file not shown.
Binary file removed vm/stdlib/compiled/latest/stdlib/069_GenesisNFT.mv
Binary file not shown.
Binary file not shown.
Binary file removed vm/stdlib/compiled/latest/stdlib/071_Genesis.mv
Binary file not shown.
Binary file not shown.
Binary file added vm/stdlib/compiled/latest/stdlib/072_Genesis.mv
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed vm/stdlib/compiled/latest/stdlib/074_MintDaoProposal.mv
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed vm/stdlib/compiled/latest/stdlib/082_Signature.mv
Binary file not shown.
Binary file not shown.
Binary file removed vm/stdlib/compiled/latest/stdlib/085_StructuredHash.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/latest/stdlib/088_Table.mv
Binary file not shown.
File renamed without changes.
Binary file not shown.
57 changes: 57 additions & 0 deletions vm/stdlib/tests/package_init_script.rs
@@ -0,0 +1,57 @@
use anyhow::{format_err, Result};
use starcoin_vm_types::transaction::Package;
use stdlib::COMPILED_MOVE_CODE_DIR;

#[test]
fn test_package_init_function() -> Result<()> {
let _path_list = [
"./compiled/2/1-2/stdlib.blob",
"./compiled/3/2-3/stdlib.blob",
"./compiled/4/3-4/stdlib.blob",
"./compiled/5/4-5/stdlib.blob",
"./compiled/6/5-6/stdlib.blob",
"./compiled/7/6-7/stdlib.blob",
"./compiled/8/7-8/stdlib.blob",
"./compiled/9/8-9/stdlib.blob",
"./compiled/10/9-10/stdlib.blob",
"./compiled/11/10-11/stdlib.blob",
"./compiled/12/11-12/stdlib.blob",
];

let init_strs = [
"0x00000000000000000000000000000001::PackageTxnManager::convert_TwoPhaseUpgrade_to_TwoPhaseUpgradeV2",
"0x00000000000000000000000000000001::StdlibUpgradeScripts::upgrade_from_v2_to_v3",
"",
"",
"0x00000000000000000000000000000001::StdlibUpgradeScripts::upgrade_from_v5_to_v6",
"0x00000000000000000000000000000001::StdlibUpgradeScripts::upgrade_from_v6_to_v7",
"0x00000000000000000000000000000001::StdlibUpgradeScripts::upgrade_from_v7_to_v8",
"",
"",
"",
"0x00000000000000000000000000000001::StdlibUpgradeScripts::upgrade_from_v11_to_v12",
];
for (i, version) in (2..=12).collect::<Vec<usize>>().into_iter().enumerate() {
let package_file = format!("{}/{}-{}/stdlib.blob", version, version - 1, version);
let package = COMPILED_MOVE_CODE_DIR
.get_file(package_file)
.map(|file| {
bcs_ext::from_bytes::<Package>(file.contents())
.expect("Decode package should success")
})
.ok_or_else(|| {
format_err!(
"Can not find upgrade package between version {} and {}",
version - 1,
version
)
})?;
let init_fun = if let Some(init_script) = package.init_script() {
format!("{}::{}", init_script.module(), init_script.function())
} else {
"".to_owned()
};
assert_eq!(init_fun, init_strs[i]);
}
Ok(())
}

0 comments on commit 7698f19

Please sign in to comment.