Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

7 changes: 5 additions & 2 deletions chain/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,13 +411,16 @@ impl BlockChain {
author_array.copy_from_slice(&author_bytes[..16]);
let author_v2 = starcoin_vm2_types::account_address::AccountAddress::new(author_array);

// Build execution state from the selected parent, not from current main head.
// In equal-difficulty DAG branches, selected parent may differ from self.statedb head.
let parent_multi_state = self.storage.0.get_vm_multi_state(parent_header.id())?;
let chain_state = ChainStateDB::new(
self.storage.0.clone().into_super_arc(),
Some(self.statedb.0.state_root()),
Some(parent_multi_state.state_root1()),
);
let chain_state2 = ChainStateDB2::new(
self.storage.1.clone().into_super_arc(),
Some(self.statedb.1.state_root()),
Some(parent_multi_state.state_root2()),
);

let mut opened_block = OpenedBlock::new(
Expand Down
6 changes: 3 additions & 3 deletions commons/parallel-executor/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2278,13 +2278,13 @@ mod tests {
_view: &MVHashMapView<u64, u64>,
txn: &Self::T,
) -> ExecutionStatus<Self::Output, ()> {
let change = match txn.op {
let change = match &txn.op {
CreateThenAddOp::Create { value } => {
DelayedChange::Create(DelayedFieldValue::Aggregator(value))
DelayedChange::Create(DelayedFieldValue::Aggregator(*value))
}
CreateThenAddOp::Add { delta, max_value } => {
DelayedChange::Apply(DelayedApplyChange::AggregatorDelta {
delta: DeltaWithMax::new(SignedU128::Positive(delta), max_value),
delta: DeltaWithMax::new(SignedU128::Positive(*delta), *max_value),
})
}
};
Expand Down
22 changes: 12 additions & 10 deletions rpc/client/tests/chain_get_block_txn_infos_in_seq_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ fn test_chain_get_block_txn_infos_in_seq() -> Result<()> {
std::thread::sleep(Duration::from_secs(5));

let client = RpcClient::connect_ipc(ipc_file)?;
let block_hash = wait_for_queryable_main_head_hash(
let block_hash = block.id();
wait_for_block_queryable(
&client,
block_hash,
block.header().number(),
Duration::from_secs(60),
)?;
Expand Down Expand Up @@ -176,35 +178,35 @@ fn test_chain_get_block_txn_infos_in_seq() -> Result<()> {
Ok(())
}

fn wait_for_queryable_main_head_hash(
fn wait_for_block_queryable(
client: &RpcClient,
block_hash: HashValue,
min_number: u64,
timeout: Duration,
) -> Result<HashValue> {
) -> Result<()> {
let deadline = Instant::now() + timeout;
loop {
if Instant::now() >= deadline {
return Err(format_err!(
"timeout waiting queryable main head, min number {}",
"timeout waiting queryable block {:?}, min number {}",
block_hash,
min_number
));
}
if let Ok(chain_info) = client.chain_info() {
let head_number = chain_info.head.number.0;
let head_hash = chain_info.head.block_hash;
if head_number >= min_number {
let seq_res = client.chain_get_block_txn_infos_in_seq(head_hash);
let vm1_res = client.chain_get_block_txn_infos(head_hash);
let vm2_res = client.chain_get_block_txn_infos2(head_hash);
let seq_res = client.chain_get_block_txn_infos_in_seq(block_hash);
let vm1_res = client.chain_get_block_txn_infos(block_hash);
let vm2_res = client.chain_get_block_txn_infos2(block_hash);
if seq_res.is_ok() && vm1_res.is_ok() && vm2_res.is_ok() {
return Ok(head_hash);
return Ok(());
}
}
}
std::thread::sleep(Duration::from_millis(200));
}
}

fn wait_for_consistent_txn_infos(
client: &RpcClient,
block_hash: HashValue,
Expand Down
Loading
Loading