From 10753cd1d4cb1d13fec69f969b28c71386e570cc Mon Sep 17 00:00:00 2001 From: nk_ysg Date: Mon, 9 Jan 2023 10:23:14 +0800 Subject: [PATCH 01/10] barnard rollback block --- chain/api/src/errors.rs | 7 ++ cmd/db-exporter/src/lib.rs | 87 ++++++++++++++++++- cmd/db-exporter/src/main.rs | 19 +++- node/src/node.rs | 1 + storage/src/chain_info/mod.rs | 18 +++- storage/src/lib.rs | 2 + storage/src/storage.rs | 8 ++ storage/src/upgrade.rs | 31 +++++++ sync/src/block_connector/write_block_chain.rs | 6 ++ types/src/startup_info.rs | 39 +++++++++ 10 files changed, 215 insertions(+), 3 deletions(-) diff --git a/chain/api/src/errors.rs b/chain/api/src/errors.rs index d6fe09cb06..39c46b2dd4 100644 --- a/chain/api/src/errors.rs +++ b/chain/api/src/errors.rs @@ -61,6 +61,8 @@ pub enum ConnectBlockError { ParentNotExist(Box), #[error("Verify block {0} failed: {1:?}")] VerifyBlockFailed(VerifyBlockField, Error), + #[error("Barnard hard fork block: {:?} ", .0.header())] + BarnardHardFork(Box), } impl ConnectBlockError { @@ -71,11 +73,15 @@ impl ConnectBlockError { pub const REP_VERIFY_BLOCK_FAILED: ReputationChange = ReputationChange::new_fatal("VerifyBlockFailed"); + pub const REP_BARNARD_HARD_FORK: ReputationChange = + ReputationChange::new_fatal("BarnardHardFork"); + pub fn reason(&self) -> &str { match self { ConnectBlockError::FutureBlock(_) => "FutureBlock", ConnectBlockError::ParentNotExist(_) => "ParentNotExist", ConnectBlockError::VerifyBlockFailed(_, _) => "VerifyBlockFailed", + ConnectBlockError::BarnardHardFork(_) => "BarnardHardFork", } } @@ -86,6 +92,7 @@ impl ConnectBlockError { ConnectBlockError::VerifyBlockFailed(_, _) => { ConnectBlockError::REP_VERIFY_BLOCK_FAILED } + ConnectBlockError::BarnardHardFork(_) => ConnectBlockError::REP_BARNARD_HARD_FORK, } } } diff --git a/cmd/db-exporter/src/lib.rs b/cmd/db-exporter/src/lib.rs index e08288615e..80dd4c7316 100644 --- a/cmd/db-exporter/src/lib.rs +++ b/cmd/db-exporter/src/lib.rs @@ -1,15 +1,26 @@ // Copyright (c) The Starcoin Core Contributors // SPDX-License-Identifier: Apache-2.0 -use anyhow::bail; +use anyhow::{bail, format_err}; use atomic_counter::AtomicCounter; use indicatif::{ProgressBar, ProgressStyle}; use move_binary_format::errors::Location; +use starcoin_chain::{BlockChain, ChainReader}; +use starcoin_config::BuiltinNetworkID; +use starcoin_config::ChainNetwork; use starcoin_crypto::HashValue; +use starcoin_genesis::Genesis; +use starcoin_statedb::ChainStateDB; +use starcoin_storage::cache_storage::CacheStorage; +use starcoin_storage::db_storage::DBStorage; +use starcoin_storage::storage::StorageInstance; +use starcoin_storage::{Storage, StorageVersion}; use starcoin_types::block::Block; use starcoin_types::transaction::TransactionPayload; use starcoin_vm_types::errors::VMError; use starcoin_vm_types::file_format::CompiledModule; +use starcoin_vm_types::on_chain_config::Version; +use starcoin_vm_types::state_view::StateReaderExt; use std::fs::File; use std::io::{BufRead, BufReader}; use std::path::PathBuf; @@ -131,3 +142,77 @@ fn verify_block_modules(block: Block) -> (usize, Vec) { } (success_modules, errors) } + +pub fn barnard_hard_fork_info(db_path: PathBuf) -> anyhow::Result<()> { + let net = ChainNetwork::new_builtin(BuiltinNetworkID::Barnard); + let db_storage = DBStorage::open_with_cfs( + db_path.join("starcoindb/db/starcoindb"), + StorageVersion::current_version() + .get_column_family_names() + .to_vec(), + true, + Default::default(), + None, + )?; + let storage = Arc::new(Storage::new(StorageInstance::new_cache_and_db_instance( + CacheStorage::new(None), + db_storage, + ))?); + let (chain_info, _) = Genesis::init_and_check_storage(&net, storage.clone(), db_path.as_ref())?; + let chain = BlockChain::new( + net.time_service(), + chain_info.head().id(), + storage.clone(), + None, + ) + .expect("create block chain should success."); + let mut left = 1; + let mut right = chain.status().head().number() as u64; + println!("cur_num {}", right); + let mut mid = left; + while left < right { + mid = (left + right) / 2; + let block = chain + .get_block_by_number(mid)? + .ok_or_else(|| anyhow::anyhow!("block number {} not exist", mid))?; + + let root = block.header.state_root(); + let statedb = ChainStateDB::new(storage.clone(), Some(root)); + let stdlib_verson = statedb + .get_on_chain_config::()? + .map(|version| version.major) + .ok_or_else(|| format_err!("on chain config stdlib version can not be empty."))?; + if stdlib_verson == 12 { + right = mid; + } else { + left = mid + 1; + } + } + + let block = chain + .get_block_by_number(mid + 1)? + .ok_or_else(|| anyhow::anyhow!("block number {} not exist", mid + 1))?; + let root = block.header.state_root(); + let statedb = ChainStateDB::new(storage.clone(), Some(root)); + let stdlib_verson = statedb + .get_on_chain_config::()? + .map(|version| version.major) + .ok_or_else(|| format_err!("on chain config stdlib version can not be empty."))?; + println!( + "stdlib_version {} number {} block hash {}", + stdlib_verson, + mid + 1, + block.header.id() + ); + let block = chain + .get_block_by_number(mid)? + .ok_or_else(|| anyhow::anyhow!("block number {} not exist", mid))?; + let root = block.header.state_root(); + let statedb = ChainStateDB::new(storage, Some(root)); + let stdlib_verson = statedb + .get_on_chain_config::()? + .map(|version| version.major) + .ok_or_else(|| format_err!("on chain config stdlib version can not be empty."))?; + println!("parent block stdlib_version {}", stdlib_verson); + Ok(()) +} diff --git a/cmd/db-exporter/src/main.rs b/cmd/db-exporter/src/main.rs index 6c15213d3e..15e5e44398 100644 --- a/cmd/db-exporter/src/main.rs +++ b/cmd/db-exporter/src/main.rs @@ -7,7 +7,7 @@ use bcs_ext::Sample; use clap::IntoApp; use clap::Parser; use csv::Writer; -use db_exporter::verify_modules_via_export_file; +use db_exporter::{barnard_hard_fork_info, verify_modules_via_export_file}; use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; use serde::ser::SerializeMap; use serde::{Serialize, Serializer}; @@ -233,6 +233,7 @@ enum Cmd { ApplySnapshot(ApplySnapshotOptions), ExportResource(ExportResourceOptions), VerifyModules(VerifyModulesOptions), + BarnardHardForkInfo(BarnardHardForkInfoOptions), } #[derive(Debug, Clone, Parser)] @@ -425,6 +426,17 @@ pub struct VerifyModulesOptions { pub input_path: PathBuf, } +#[derive(Debug, Parser)] +#[clap( + name = "barnard-hard-fork_info", + about = "get barnard first stdlib v12 block number" +)] +pub struct BarnardHardForkInfoOptions { + #[clap(long, short = 'i', parse(from_os_str))] + /// starcoin node db path. like ~/.starcoin/barnard + pub db_path: PathBuf, +} + #[tokio::main(flavor = "multi_thread")] async fn main() -> anyhow::Result<()> { let opt = Opt::parse(); @@ -576,7 +588,12 @@ async fn main() -> anyhow::Result<()> { let result = verify_modules_via_export_file(option.input_path); return result; } + Cmd::BarnardHardForkInfo(option) => { + let result = barnard_hard_fork_info(option.db_path); + return result; + } } + Ok(()) } diff --git a/node/src/node.rs b/node/src/node.rs index 4bffdc3f5e..6c3d8f0e90 100644 --- a/node/src/node.rs +++ b/node/src/node.rs @@ -305,6 +305,7 @@ impl NodeService { let start_time = SystemTime::now(); storage_instance.check_upgrade()?; + storage_instance.barnard_hard_fork(config.clone())?; let upgrade_time = SystemTime::now().duration_since(start_time)?; let storage = Arc::new(Storage::new(storage_instance)?); registry.put_shared(storage.clone()).await?; diff --git a/storage/src/chain_info/mod.rs b/storage/src/chain_info/mod.rs index 611572b3ae..3f193be3f0 100644 --- a/storage/src/chain_info/mod.rs +++ b/storage/src/chain_info/mod.rs @@ -5,7 +5,7 @@ use crate::storage::{ColumnFamily, InnerStorage, KVStore}; use crate::{StorageVersion, CHAIN_INFO_PREFIX_NAME}; use anyhow::Result; use starcoin_crypto::HashValue; -use starcoin_types::startup_info::{SnapshotRange, StartupInfo}; +use starcoin_types::startup_info::{BarnardHardFork, SnapshotRange, StartupInfo}; use std::convert::{TryFrom, TryInto}; #[derive(Clone)] @@ -27,6 +27,7 @@ impl ChainInfoStorage { const GENESIS_KEY: &'static str = "genesis"; const STORAGE_VERSION_KEY: &'static str = "storage_version"; const SNAPSHOT_RANGE_KEY: &'static str = "snapshot_height"; + const BARNARD_HARD_FORK: &'static str = "barnard_hard_fork"; pub fn get_startup_info(&self) -> Result> { self.get(Self::STARTUP_INFO_KEY.as_bytes()) @@ -95,4 +96,19 @@ impl ChainInfoStorage { snapshot_range.try_into()?, ) } + + pub fn get_barnard_hard_fork(&self) -> Result> { + self.get(Self::BARNARD_HARD_FORK.as_bytes()) + .and_then(|bytes| match bytes { + Some(bytes) => Ok(Some(bytes.try_into()?)), + None => Ok(None), + }) + } + + pub fn save_barnard_hard_fork(&self, barnard_hard_fork: BarnardHardFork) -> Result<()> { + self.put_sync( + Self::BARNARD_HARD_FORK.as_bytes().to_vec(), + barnard_hard_fork.try_into()?, + ) + } } diff --git a/storage/src/lib.rs b/storage/src/lib.rs index eb1c36bfb1..300c04ddf9 100644 --- a/storage/src/lib.rs +++ b/storage/src/lib.rs @@ -30,6 +30,8 @@ use starcoin_types::{ use std::collections::BTreeMap; use std::fmt::{Debug, Display, Formatter}; use std::sync::Arc; +pub use upgrade::BARNARD_HARD_FORK_HASH; +pub use upgrade::BARNARD_HARD_FORK_HEIGHT; pub mod accumulator; pub mod batch; diff --git a/storage/src/storage.rs b/storage/src/storage.rs index 9897918d60..486fa2b8af 100644 --- a/storage/src/storage.rs +++ b/storage/src/storage.rs @@ -7,6 +7,7 @@ use crate::db_storage::{DBStorage, SchemaIterator}; use crate::upgrade::DBUpgrade; use anyhow::{bail, format_err, Result}; use byteorder::{BigEndian, ReadBytesExt}; +use starcoin_config::NodeConfig; use starcoin_crypto::HashValue; use std::convert::TryInto; use std::fmt::Debug; @@ -107,6 +108,13 @@ impl StorageInstance { pub fn check_upgrade(&mut self) -> Result<()> { DBUpgrade::check_upgrade(self) } + + pub fn barnard_hard_fork(&mut self, config: Arc) -> Result<()> { + if config.net().id().chain_id().is_barnard() { + return DBUpgrade::barnard_hard_fork(self); + } + Ok(()) + } } impl InnerStore for StorageInstance { diff --git a/storage/src/upgrade.rs b/storage/src/upgrade.rs index 4e4db06c4a..f79b29feb8 100644 --- a/storage/src/upgrade.rs +++ b/storage/src/upgrade.rs @@ -12,12 +12,21 @@ use crate::{ BLOCK_BODY_PREFIX_NAME, TRANSACTION_INFO_PREFIX_NAME, }; use anyhow::{bail, ensure, format_err, Result}; +use once_cell::sync::Lazy; +use starcoin_crypto::HashValue; use starcoin_logger::prelude::{debug, info, warn}; +use starcoin_types::block::BlockNumber; +use starcoin_types::startup_info::{BarnardHardFork, StartupInfo}; use starcoin_types::transaction::Transaction; use std::cmp::Ordering; pub struct DBUpgrade; +// XXX FIXME YSG +pub static BARNARD_HARD_FORK_HEIGHT: BlockNumber = 1112; +pub static BARNARD_HARD_FORK_HASH: Lazy = + Lazy::new(|| HashValue::from_hex_literal("0x1112").expect("")); + impl DBUpgrade { pub fn check_upgrade(instance: &mut StorageInstance) -> Result<()> { let version_in_db = { @@ -181,4 +190,26 @@ impl DBUpgrade { } Ok(()) } + + pub fn barnard_hard_fork(instance: &mut StorageInstance) -> Result<()> { + let block_storage = BlockStorage::new(instance.clone()); + let chain_info_storage = ChainInfoStorage::new(instance.clone()); + let barnard_hard_fork = chain_info_storage.get_barnard_hard_fork()?; + + let barnard_info = BarnardHardFork::new(BARNARD_HARD_FORK_HEIGHT, *BARNARD_HARD_FORK_HASH); + if barnard_hard_fork == Some(barnard_info.clone()) { + return Ok(()); + } + + let block = block_storage.get_block_by_hash(*BARNARD_HARD_FORK_HASH)?; + if let Some(block) = block { + if block.header().number() == BARNARD_HARD_FORK_HEIGHT { + println!("barnard hard fork"); + let main_hash = block.header().parent_hash(); + chain_info_storage.save_barnard_hard_fork(barnard_info)?; + chain_info_storage.save_startup_info(StartupInfo::new(main_hash))?; + } + } + Ok(()) + } } diff --git a/sync/src/block_connector/write_block_chain.rs b/sync/src/block_connector/write_block_chain.rs index 13af902588..f0c14a770e 100644 --- a/sync/src/block_connector/write_block_chain.rs +++ b/sync/src/block_connector/write_block_chain.rs @@ -400,6 +400,12 @@ where fn connect_inner(&mut self, block: Block) -> Result { let block_id = block.id(); + if block_id == *starcoin_storage::BARNARD_HARD_FORK_HASH + && block.header().number() == starcoin_storage::BARNARD_HARD_FORK_HEIGHT + { + debug!("barnard hard fork {}", block_id); + return Err(ConnectBlockError::BarnardHardFork(Box::new(block)).into()); + } if self.main.current_header().id() == block_id { debug!("Repeat connect, current header is {} already.", block_id); return Ok(ConnectOk::Duplicate); diff --git a/types/src/startup_info.rs b/types/src/startup_info.rs index 9068b14454..1ef129e2e8 100644 --- a/types/src/startup_info.rs +++ b/types/src/startup_info.rs @@ -13,6 +13,8 @@ use starcoin_vm_types::genesis_config::ChainId; use std::convert::{TryFrom, TryInto}; use std::fmt; use std::fmt::Formatter; +use std::hash::Hash; + /// The info of a chain. #[derive(Eq, PartialEq, Hash, Deserialize, Serialize, Clone, Debug)] pub struct ChainInfo { @@ -234,3 +236,40 @@ impl TryInto> for SnapshotRange { self.encode() } } + +#[derive(Eq, PartialEq, Hash, Deserialize, Serialize, Clone, Debug)] +pub struct BarnardHardFork { + // [number, ...) block will remove + number: BlockNumber, + hash: HashValue, +} + +impl BarnardHardFork { + pub fn new(number: BlockNumber, hash: HashValue) -> Self { + Self { number, hash } + } + + pub fn get_number(&self) -> BlockNumber { + self.number + } + + pub fn get_hash(&self) -> HashValue { + self.hash + } +} + +impl TryFrom> for BarnardHardFork { + type Error = anyhow::Error; + + fn try_from(value: Vec) -> Result { + BarnardHardFork::decode(value.as_slice()) + } +} + +impl TryInto> for BarnardHardFork { + type Error = anyhow::Error; + + fn try_into(self) -> Result> { + self.encode() + } +} From 3d5999015f0b59646204ee3a585265549a159f7e Mon Sep 17 00:00:00 2001 From: WGB5445 <919603023@qq.com> Date: Thu, 12 Jan 2023 01:45:33 +0800 Subject: [PATCH 02/10] Add halley fork --- storage/src/storage.rs | 3 ++- storage/src/upgrade.rs | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/storage/src/storage.rs b/storage/src/storage.rs index 486fa2b8af..b0afd432b8 100644 --- a/storage/src/storage.rs +++ b/storage/src/storage.rs @@ -110,7 +110,8 @@ impl StorageInstance { } pub fn barnard_hard_fork(&mut self, config: Arc) -> Result<()> { - if config.net().id().chain_id().is_barnard() { + if config.net().id().chain_id().is_halley() { + println!("Is Halley in if"); return DBUpgrade::barnard_hard_fork(self); } Ok(()) diff --git a/storage/src/upgrade.rs b/storage/src/upgrade.rs index f79b29feb8..58a9cf5ad6 100644 --- a/storage/src/upgrade.rs +++ b/storage/src/upgrade.rs @@ -23,10 +23,10 @@ use std::cmp::Ordering; pub struct DBUpgrade; // XXX FIXME YSG -pub static BARNARD_HARD_FORK_HEIGHT: BlockNumber = 1112; +pub static BARNARD_HARD_FORK_HEIGHT: BlockNumber = 482197; pub static BARNARD_HARD_FORK_HASH: Lazy = - Lazy::new(|| HashValue::from_hex_literal("0x1112").expect("")); - + Lazy::new(|| HashValue::from_hex_literal("0x9b5081485ebfa155f6276be8edd8b9ef4bc94b80d1b3ff42a119810b274cf659").expect("")); +//0xab8d4b4faeb27b4e4912bf4341ff8dbe5fb467f4909e2ba333f02eb908245d38 impl DBUpgrade { pub fn check_upgrade(instance: &mut StorageInstance) -> Result<()> { let version_in_db = { @@ -198,6 +198,7 @@ impl DBUpgrade { let barnard_info = BarnardHardFork::new(BARNARD_HARD_FORK_HEIGHT, *BARNARD_HARD_FORK_HASH); if barnard_hard_fork == Some(barnard_info.clone()) { + println!("is have forked"); return Ok(()); } From ec86a5cce3a157dc3135b96b86cb6f66a496a52c Mon Sep 17 00:00:00 2001 From: WGB5445 <919603023@qq.com> Date: Thu, 12 Jan 2023 01:53:12 +0800 Subject: [PATCH 03/10] Add halley fork fmt --- storage/src/upgrade.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/storage/src/upgrade.rs b/storage/src/upgrade.rs index 58a9cf5ad6..4bbe6472d6 100644 --- a/storage/src/upgrade.rs +++ b/storage/src/upgrade.rs @@ -24,8 +24,12 @@ pub struct DBUpgrade; // XXX FIXME YSG pub static BARNARD_HARD_FORK_HEIGHT: BlockNumber = 482197; -pub static BARNARD_HARD_FORK_HASH: Lazy = - Lazy::new(|| HashValue::from_hex_literal("0x9b5081485ebfa155f6276be8edd8b9ef4bc94b80d1b3ff42a119810b274cf659").expect("")); +pub static BARNARD_HARD_FORK_HASH: Lazy = Lazy::new(|| { + HashValue::from_hex_literal( + "0x9b5081485ebfa155f6276be8edd8b9ef4bc94b80d1b3ff42a119810b274cf659", + ) + .expect("") +}); //0xab8d4b4faeb27b4e4912bf4341ff8dbe5fb467f4909e2ba333f02eb908245d38 impl DBUpgrade { pub fn check_upgrade(instance: &mut StorageInstance) -> Result<()> { From 281e033f2275cfb498104ac89724275003d29e36 Mon Sep 17 00:00:00 2001 From: WGB5445 <919603023@qq.com> Date: Fri, 13 Jan 2023 01:09:13 +0800 Subject: [PATCH 04/10] Fix some --- storage/src/upgrade.rs | 1 - sync/src/block_connector/write_block_chain.rs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/storage/src/upgrade.rs b/storage/src/upgrade.rs index 4bbe6472d6..8787ee848c 100644 --- a/storage/src/upgrade.rs +++ b/storage/src/upgrade.rs @@ -22,7 +22,6 @@ use std::cmp::Ordering; pub struct DBUpgrade; -// XXX FIXME YSG pub static BARNARD_HARD_FORK_HEIGHT: BlockNumber = 482197; pub static BARNARD_HARD_FORK_HASH: Lazy = Lazy::new(|| { HashValue::from_hex_literal( diff --git a/sync/src/block_connector/write_block_chain.rs b/sync/src/block_connector/write_block_chain.rs index f0c14a770e..99570bf247 100644 --- a/sync/src/block_connector/write_block_chain.rs +++ b/sync/src/block_connector/write_block_chain.rs @@ -403,7 +403,7 @@ where if block_id == *starcoin_storage::BARNARD_HARD_FORK_HASH && block.header().number() == starcoin_storage::BARNARD_HARD_FORK_HEIGHT { - debug!("barnard hard fork {}", block_id); + debug!("halley hard fork {}", block_id); return Err(ConnectBlockError::BarnardHardFork(Box::new(block)).into()); } if self.main.current_header().id() == block_id { From 2430a25d7c7f626f17fd1f7e427704f09c369bcd Mon Sep 17 00:00:00 2001 From: WGB5445 <919603023@qq.com> Date: Fri, 13 Jan 2023 09:16:21 +0800 Subject: [PATCH 05/10] add tag select --- .github/workflows/docker_build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker_build.yml b/.github/workflows/docker_build.yml index 95b0a61b00..4bc8f8d160 100644 --- a/.github/workflows/docker_build.yml +++ b/.github/workflows/docker_build.yml @@ -50,7 +50,7 @@ jobs: labels: ${{ steps.docker_meta.outputs.labels }} - name: deploy cluster # Only deploy on master. - if: github.ref == 'refs/heads/master' + if: github.tag == 'HalleyHardFork' shell: bash env: IMAGE_VERSION: ${{steps.docker_meta.outputs.version}} From 842d64ba26a6cad348f687d238dc47c6b6e48832 Mon Sep 17 00:00:00 2001 From: nk_ysg Date: Fri, 13 Jan 2023 13:28:13 +0800 Subject: [PATCH 06/10] apply halley --- kube/manifest/starcoin-halley.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kube/manifest/starcoin-halley.yaml b/kube/manifest/starcoin-halley.yaml index 8c34ce657c..08939e4997 100644 --- a/kube/manifest/starcoin-halley.yaml +++ b/kube/manifest/starcoin-halley.yaml @@ -23,7 +23,7 @@ spec: starcoin/node-pool: seed-pool containers: - name: starcoin - image: starcoin/starcoin:master + image: starcoin/starcoin:halley_rollback_block imagePullPolicy: Always command: - bash From 6c776e923a421d7bcf908ab335c4911bd8827f02 Mon Sep 17 00:00:00 2001 From: nk_ysg Date: Mon, 16 Jan 2023 17:35:30 +0800 Subject: [PATCH 07/10] update barnard rollback height --- storage/src/storage.rs | 4 ++-- storage/src/upgrade.rs | 4 ++-- sync/src/block_connector/write_block_chain.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/storage/src/storage.rs b/storage/src/storage.rs index b0afd432b8..533485c4dd 100644 --- a/storage/src/storage.rs +++ b/storage/src/storage.rs @@ -110,8 +110,8 @@ impl StorageInstance { } pub fn barnard_hard_fork(&mut self, config: Arc) -> Result<()> { - if config.net().id().chain_id().is_halley() { - println!("Is Halley in if"); + if config.net().id().chain_id().is_barnard() { + println!("Is Barnard in if"); return DBUpgrade::barnard_hard_fork(self); } Ok(()) diff --git a/storage/src/upgrade.rs b/storage/src/upgrade.rs index 8787ee848c..ac048d088c 100644 --- a/storage/src/upgrade.rs +++ b/storage/src/upgrade.rs @@ -22,10 +22,10 @@ use std::cmp::Ordering; pub struct DBUpgrade; -pub static BARNARD_HARD_FORK_HEIGHT: BlockNumber = 482197; +pub static BARNARD_HARD_FORK_HEIGHT: BlockNumber = 9716980; pub static BARNARD_HARD_FORK_HASH: Lazy = Lazy::new(|| { HashValue::from_hex_literal( - "0x9b5081485ebfa155f6276be8edd8b9ef4bc94b80d1b3ff42a119810b274cf659", + "0x8b960afd0ebd00109b54253a8d6985e8e219f38bfa7d9b9196ef858b5d09ddb8", ) .expect("") }); diff --git a/sync/src/block_connector/write_block_chain.rs b/sync/src/block_connector/write_block_chain.rs index 99570bf247..f0c14a770e 100644 --- a/sync/src/block_connector/write_block_chain.rs +++ b/sync/src/block_connector/write_block_chain.rs @@ -403,7 +403,7 @@ where if block_id == *starcoin_storage::BARNARD_HARD_FORK_HASH && block.header().number() == starcoin_storage::BARNARD_HARD_FORK_HEIGHT { - debug!("halley hard fork {}", block_id); + debug!("barnard hard fork {}", block_id); return Err(ConnectBlockError::BarnardHardFork(Box::new(block)).into()); } if self.main.current_header().id() == block_id { From 04d64c37c36bc5ac7f2cccaf3abe5f25a5ff160b Mon Sep 17 00:00:00 2001 From: nk_ysg Date: Wed, 18 Jan 2023 10:40:02 +0800 Subject: [PATCH 08/10] add barnard tag --- kube/manifest/starcoin-barnard.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kube/manifest/starcoin-barnard.yaml b/kube/manifest/starcoin-barnard.yaml index be1f5d4753..f90e2a3997 100644 --- a/kube/manifest/starcoin-barnard.yaml +++ b/kube/manifest/starcoin-barnard.yaml @@ -23,7 +23,7 @@ spec: starcoin/node-pool: seed-pool containers: - name: starcoin - image: starcoin/starcoin:v1.12.9 + image: starcoin/starcoin:barnard_rollback_block imagePullPolicy: Always command: - bash From 5fd642a01325680674cd8d151e2986a216a69c4d Mon Sep 17 00:00:00 2001 From: nk_ysg Date: Wed, 18 Jan 2023 14:45:18 +0800 Subject: [PATCH 09/10] reset starcoin-halley.yaml --- kube/manifest/starcoin-halley.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kube/manifest/starcoin-halley.yaml b/kube/manifest/starcoin-halley.yaml index 08939e4997..8c34ce657c 100644 --- a/kube/manifest/starcoin-halley.yaml +++ b/kube/manifest/starcoin-halley.yaml @@ -23,7 +23,7 @@ spec: starcoin/node-pool: seed-pool containers: - name: starcoin - image: starcoin/starcoin:halley_rollback_block + image: starcoin/starcoin:master imagePullPolicy: Always command: - bash From 34e88d8615babcc028446b6b4a875634097da552 Mon Sep 17 00:00:00 2001 From: nk_ysg Date: Wed, 18 Jan 2023 14:47:08 +0800 Subject: [PATCH 10/10] reset docker_build.yml --- .github/workflows/docker_build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker_build.yml b/.github/workflows/docker_build.yml index 4bc8f8d160..1f06c2476f 100644 --- a/.github/workflows/docker_build.yml +++ b/.github/workflows/docker_build.yml @@ -50,7 +50,7 @@ jobs: labels: ${{ steps.docker_meta.outputs.labels }} - name: deploy cluster # Only deploy on master. - if: github.tag == 'HalleyHardFork' + if: github.tag == 'refs/heads/master' shell: bash env: IMAGE_VERSION: ${{steps.docker_meta.outputs.version}}