Skip to content

Commit

Permalink
Force deploy (#4025)
Browse files Browse the repository at this point in the history
* [force-deploy] add initial codes force deploy command into db exporter

* add the project of force upgrade

* [force deploy] Add suiteable binary files of starcoin framework

* [force-deploy] revert gas schedule

* [force-upgrade] reformat upgrade code

* [force-deploy] reformat some code for unittest

* [force-deploy] A new txn verify and modification scheme is used, based on modifications of the starcoin-runtime layer

* [force-deploy] modify code

* [force-deploy] upgrade framework mv file for barnard and proxima

* fixed for test

* for account get from multi chain id

* fixed error

* [force-upgrade] move the code into openedblock

* [force-deploy] add include_dir and fixed the genesis version of proxima and halley

* [force-upgrade] change to new process

* [force-upgrade] change to new process

* binary file

* [force-upgrade] change to new process

* [force-upgrade] add block timestamp

* [force-upgrade] remove unused code

* [force-upgrade] fixed upgrade test error

* [force-upgrade] fixed the timestamp

* [force-upgrade] fixed the timestamp

* [force-upgrade] fixed the script for include_dir

* [force-upgrade] fixed timestamp

* [force-upgrade] reverted gas scheduler

* [force-upgrade] reverted gas scheduler

* [force-upgrade] merged from commit "224ee92b878f8a8f4e1628bcd2464f7df934eab2"

* [force-upgrade] change inappropriate file name

* [force-upgrade] fixed executed for add result to accumulator

* [force-deploy] add some case

* [force-upgrade] change for test

* [force-upgrade] Change unittest for verify block template

* [force-upgrade] remove check function

* fix compiling errors and warnings

* fix unused code

* Revert "[force-upgrade] fixed executed for add result to accumulator"

This reverts commit 62fedfb.

* fix force upgrade txn test case

1. execute extra txn without gas limit
2. make extra txn is last executed

* fix burning tokens test

* add more check for main network when executing extra txn

* update stdlib version directly

* fix fmt

* stdlib framework v11 with move version 6 for test

* some updates

1. regenerate halley genesisuser that will be used by SpinupWP to connect to the server and set it up. The SSH user requires root privileges and must be able to run sudo commands non-interactively. If you see the following error, you need to enable passwordless sudo for the specified Linux user.
2. remove some rescrictions

* update force-deploy pkg path

* update deploy account for main network

* fix test cases

* update halley genesis

* minor updates

1. dont print extra txn body to log file
2. silence a warning

* update halley force upgrade height

* [force-deploy] set halley upgrade number to 600

* [force-upgrade] update genesis timestamp for halley test

* [force-upgrade]
1. Remove framework deposit logic
2. Update halley genesis timestamp for genesis block
3. Update block number of force upgrade to 400 to prevent too long

* [force-upgrade]
 Update block number of force upgrade to 300 to prevent too long

* [force-upgrade] update genesis

* change force deploy height of test network

1. change it to 15
2. update test cases

* update extra-txn proccessing

1. restore moduleUpgradeStrategy properly
2. update some suicide logs

* fix benchmark

1. update force upgrade height to 50 for test network
2. update test cases

* [force-upgrade] set the barnard upgrade number

* [force-upgrade] set the barnard upgrade number to 16082000

* update force deploy height for barnard

---------

Co-authored-by: simonjiao <[email protected]>
Co-authored-by: nk_ysg <[email protected]>
  • Loading branch information
3 people authored Apr 17, 2024
1 parent 3173f8c commit 654d6d9
Show file tree
Hide file tree
Showing 387 changed files with 893 additions and 33 deletions.
38 changes: 37 additions & 1 deletion Cargo.lock

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

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ members = [
"chain",
"chain/api",
"chain/open-block",
"chain/force-upgrade",
"chain/mock",
"chain/chain-notify",
"chain/service",
Expand Down Expand Up @@ -152,6 +153,7 @@ default-members = [
"chain",
"chain/api",
"chain/open-block",
"chain/force-upgrade",
"chain/mock",
"chain/chain-notify",
"chain/service",
Expand Down Expand Up @@ -442,7 +444,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 = "345a3900a0064dc57a9560235bc72c12f03448b1" }
starcoin-framework = { git = "https://github.com/starcoinorg/starcoin-framework", rev = "1df759371941ab59cb2295542f7eafa85c4ef6fe" }
starcoin-genesis = { path = "genesis" }
starcoin-logger = { path = "commons/logger" }
starcoin-metrics = { path = "commons/metrics" }
Expand All @@ -460,6 +462,7 @@ starcoin-network-rpc-api = { path = "network-rpc/api" }
starcoin-node = { path = "node" }
starcoin-node-api = { path = "node/api" }
starcoin-open-block = { path = "chain/open-block" }
starcoin-force-upgrade = { path = "chain/force-upgrade" }
starcoin-resource-viewer = { path = "vm/resource-viewer" }
starcoin-rpc-api = { path = "rpc/api" }
starcoin-rpc-client = { path = "rpc/client" }
Expand Down
3 changes: 3 additions & 0 deletions chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ starcoin-statedb = { workspace = true }
starcoin-time-service = { workspace = true }
starcoin-types = { package = "starcoin-types", workspace = true }
starcoin-vm-types = { workspace = true }
starcoin-vm-runtime = { workspace = true }
starcoin-force-upgrade = { workspace = true }
starcoin-storage = { workspace = true }
thiserror = { workspace = true }
once_cell = { workspace = true }
Expand All @@ -41,6 +43,7 @@ stdlib = { workspace = true }
stest = { workspace = true }
test-helper = { workspace = true }
tokio = { features = ["full"], workspace = true }
starcoin-force-upgrade = { workspace = true }

[features]
default = []
Expand Down
35 changes: 35 additions & 0 deletions chain/force-upgrade/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[package]
authors = { workspace = true }
edition = { workspace = true }
license = { workspace = true }
name = "starcoin-force-upgrade"
publish = { workspace = true }
version = "1.13.10"
homepage = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }


[dependencies]
anyhow = { workspace = true }
async-trait = { workspace = true }
bcs-ext = { package = "bcs-ext", workspace = true }
starcoin-crypto = { workspace = true }
futures = { workspace = true }
starcoin-logger = { workspace = true }
parking_lot = { workspace = true }
starcoin-accumulator = { workspace = true }
starcoin-chain-api = { workspace = true }
starcoin-state-api = { workspace = true }
starcoin-statedb = { workspace = true }
starcoin-storage = { workspace = true }
starcoin-types = { workspace = true }
starcoin-vm-types = { workspace = true }
starcoin-vm-runtime = { workspace = true }
starcoin-move-compiler = { workspace = true }
stdlib = { workspace = true }
include_dir = { workspace = true }

[dev-dependencies]
starcoin-genesis = { workspace = true }
stest = { workspace = true }
63 changes: 63 additions & 0 deletions chain/force-upgrade/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2

use anyhow::format_err;
use starcoin_types::account::DEFAULT_EXPIRATION_TIME;
use starcoin_types::identifier::Identifier;
use starcoin_types::language_storage::ModuleId;
use starcoin_types::{
account::{Account, DEFAULT_MAX_GAS_AMOUNT},
transaction::SignedUserTransaction,
};
use starcoin_vm_types::account_config::core_code_address;
use starcoin_vm_types::transaction::ScriptFunction;
use starcoin_vm_types::{
account_config::STC_TOKEN_CODE_STR,
genesis_config::ChainId,
transaction::{Package, RawUserTransaction, TransactionPayload},
};
use stdlib::COMPILED_MOVE_CODE_DIR;

pub struct ForceUpgrade;

impl ForceUpgrade {
// block_timestamp: *NOTE* by seconds,
pub fn force_deploy_txn(
account: Account,
sequence_number: u64,
block_timestamp_in_secs: u64,
chain_id: &ChainId,
) -> anyhow::Result<SignedUserTransaction> {
let package_file = "12/11-12/stdlib.blob".to_string();
let package = COMPILED_MOVE_CODE_DIR
.get_file(package_file.clone())
.map(|file| {
bcs_ext::from_bytes::<Package>(file.contents())
.expect("Decode package should success")
})
.ok_or_else(|| format_err!("Can not find upgrade package {}", package_file))?;

let init_script = ScriptFunction::new(
ModuleId::new(
core_code_address(),
Identifier::new("StdlibUpgradeScripts").unwrap(),
),
Identifier::new("upgrade_from_v11_to_v12").unwrap(),
vec![],
vec![],
);

assert_eq!(package.init_script().unwrap(), &init_script);

Ok(account.sign_txn(RawUserTransaction::new(
*account.address(),
sequence_number,
TransactionPayload::Package(package),
DEFAULT_MAX_GAS_AMOUNT,
1,
block_timestamp_in_secs + DEFAULT_EXPIRATION_TIME,
*chain_id,
STC_TOKEN_CODE_STR.to_string(),
)))
}
}
3 changes: 3 additions & 0 deletions chain/open-block/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ starcoin-state-api = { workspace = true }
starcoin-statedb = { workspace = true }
starcoin-storage = { workspace = true }
starcoin-types = { workspace = true }
starcoin-vm-types = { workspace = true }
starcoin-vm-runtime = { workspace = true }
starcoin-force-upgrade = { workspace = true }

[dev-dependencies]
starcoin-genesis = { workspace = true }
Expand Down
Loading

0 comments on commit 654d6d9

Please sign in to comment.