Skip to content

Commit

Permalink
chainState write version 12
Browse files Browse the repository at this point in the history
  • Loading branch information
nkysg committed Apr 13, 2024
1 parent 4a51280 commit 5a55127
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions chain/open-block/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ starcoin-state-api = { workspace = true }
starcoin-statedb = { workspace = true }
starcoin-storage = { workspace = true }
starcoin-types = { workspace = true }
starcoin-vm-types = { workspace = true }

[dev-dependencies]
starcoin-genesis = { workspace = true }
Expand Down
8 changes: 8 additions & 0 deletions chain/open-block/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ use starcoin_state_api::{ChainStateReader, ChainStateWriter};
use starcoin_statedb::ChainStateDB;
use starcoin_storage::Store;
use starcoin_types::{
access_path::AccessPath,
account_address::AccountAddress,
account_config::genesis_address,
block::BlockNumber,
block::{BlockBody, BlockHeader, BlockInfo, BlockTemplate},
block_metadata::BlockMetadata,
Expand All @@ -24,6 +26,7 @@ use starcoin_types::{
write_set::WriteSet,
U256,
};
use starcoin_vm_types::{move_resource::MoveResource, on_chain_config::Version};
use std::{convert::TryInto, sync::Arc};

pub struct OpenedBlock {
Expand Down Expand Up @@ -285,6 +288,11 @@ impl OpenedBlock {
self.state
.apply_write_set(self.extra_set)
.map_err(BlockExecutorError::BlockChainStateErr)?;
let version_path =
AccessPath::resource_access_path(genesis_address(), Version::struct_tag());
let version = Version { major: 12 };
self.state
.set(&version_path, bcs_ext::to_bytes(&version)?)?;
self.state
.commit()
.map_err(BlockExecutorError::BlockChainStateErr)?;
Expand Down
1 change: 1 addition & 0 deletions executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ starcoin-vm-types = { workspace = true }
starcoin-vm-runtime = { workspace = true }
starcoin-statedb = { workspace = true }
serde = { default-features = false, workspace = true }
bcs-ext = { package = "bcs-ext", workspace = true }

[dev-dependencies]
bcs-ext = { package = "bcs-ext", workspace = true }
Expand Down
10 changes: 10 additions & 0 deletions executor/src/block_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ use starcoin_types::error::ExecutorResult;
use starcoin_types::transaction::TransactionStatus;
use starcoin_types::transaction::{Transaction, TransactionInfo};
use starcoin_vm_runtime::metrics::VMMetrics;
use starcoin_vm_types::access_path::AccessPath;
use starcoin_vm_types::account_config::genesis_address;
use starcoin_vm_types::contract_event::ContractEvent;
use starcoin_vm_types::move_resource::MoveResource;
use starcoin_vm_types::on_chain_config::Version;
use starcoin_vm_types::state_store::table::{TableHandle, TableInfo};
use starcoin_vm_types::write_set::WriteSet;
use std::collections::BTreeMap;
Expand Down Expand Up @@ -90,6 +94,12 @@ pub fn block_execute<S: ChainStateReader + ChainStateWriter>(
chain_state
.apply_write_set(extra_set)
.map_err(BlockExecutorError::BlockChainStateErr)?;
let version_path =
AccessPath::resource_access_path(genesis_address(), Version::struct_tag());
let version = Version { major: 12 };
chain_state
.set(&version_path, bcs_ext::to_bytes(&version).unwrap())
.map_err(BlockExecutorError::BlockChainStateErr)?;
chain_state
.commit()
.map_err(BlockExecutorError::BlockChainStateErr)?;
Expand Down

0 comments on commit 5a55127

Please sign in to comment.