Skip to content

Commit

Permalink
Merge pull request #581 from magicalne/fix_reset_memblock
Browse files Browse the repository at this point in the history
fix(mem_pool): cannot get block_info when it is updating
  • Loading branch information
magicalne authored Feb 17, 2022
2 parents 0df3a39 + 690033b commit 44dbc34
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions crates/mem-pool/src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,15 +585,13 @@ impl MemPool {
// estimate next l2block timestamp
let estimated_timestamp = self.provider.estimate_next_blocktime().await?;
// reset mem block state
{
let snapshot = self.store.get_snapshot();
assert_eq!(snapshot.get_tip_block_hash()?, new_tip, "set new snapshot");
let mem_store = MemStore::new(snapshot);
self.mem_pool_state.store(Arc::new(mem_store));
}
// Fix execute_raw_l2transaction panic by updating mem_store first and storing it to mem_pool_state after.
let snapshot = self.store.get_snapshot();
assert_eq!(snapshot.get_tip_block_hash()?, new_tip, "set new snapshot");
let mem_store = MemStore::new(snapshot);
mem_store.update_mem_pool_block_info(self.mem_block.block_info())?;
let mem_block_content = self.mem_block.reset(&new_tip_block, estimated_timestamp);
let snap = self.mem_pool_state.load();
snap.update_mem_pool_block_info(self.mem_block.block_info())?;
self.mem_pool_state.store(Arc::new(mem_store));

// set tip
self.current_tip = (new_tip, new_tip_block.raw().number().unpack());
Expand Down

0 comments on commit 44dbc34

Please sign in to comment.