Skip to content

Commit

Permalink
fix(mempool): pool cycles not reset on next mem block for readonly no…
Browse files Browse the repository at this point in the history
…de (#781)

* fix(mempool): pool cycles not reset on next mem block for readonly node

* fix(mempool): verify txs from fullnode

Right now, fullnode publish tx only after finalization. But we should
not depend on this behaviour.

For readonly node, we should verify cylces instead of blindly trust
fullnode.

* refactor(mempool): recreate cycles pool from config

In case we migrate to dynamic config in the future
  • Loading branch information
zeroqn authored Aug 12, 2022
1 parent 4cec852 commit 992c887
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions crates/mem-pool/src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,13 @@ impl MemPool {
let db = self.store.begin_transaction();
self.remove_unexecutables(&mut mem_state, &db).await?;

// reset cycles pool available cycles.
// recreate from config, in case we migrate to dynamic config in the future.
self.cycles_pool = CyclesPool::new(
self.mem_block_config.max_cycles_limit,
self.mem_block_config.syscall_cycles.clone(),
);

// prepare next mem block
self.try_package_more_withdrawals(&mem_state, &mut withdrawals);
self.prepare_next_mem_block(&db, &mut mem_state, withdrawals, deposits, mem_block_txs)
Expand Down

0 comments on commit 992c887

Please sign in to comment.