Skip to content

Commit

Permalink
fix a bug may cost deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
KaoImin committed Aug 2, 2023
1 parent ac29baf commit c158a57
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion core/run/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ impl Axon {
// Init Block db and get the current block
let storage = self.init_storage();
let current_block = storage.get_latest_block(Context::new()).await?;
let current_state_root = current_block.header.state_root;

log::info!("At block number {}", current_block.header.number + 1);

// Init network
Expand All @@ -267,8 +269,9 @@ impl Axon {
let txs_wal = Arc::new(SignedTxsWAL::new(txs_wal_path));

// Init system contract
let (metadata_root, _header_cell_root) =
if current_block.header.number != 0 {
self.init_system_contract(&trie_db, &current_block, &storage);
}

// Init mempool and recover signed transactions with the current block number
let current_stxs = txs_wal.load_by_number(current_block.header.number + 1);
Expand All @@ -279,6 +282,13 @@ impl Axon {
.await;

// Get the validator list from current metadata for consensus initialization
let metadata_root = AxonExecutorAdapter::from_root(
current_state_root,
Arc::clone(&trie_db),
Arc::clone(&storage),
Proposal::new_without_state_root(&self.genesis.block.header).into(),
)?
.get_metadata_root();
let metadata = MetadataHandle::new(metadata_root)
.get_metadata_by_block_number(current_block.header.number)?;
let validators: Vec<Validator> = metadata
Expand Down

0 comments on commit c158a57

Please sign in to comment.