Skip to content

Commit

Permalink
fix: pending storage & sequencer_provider (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbcaron authored Jul 6, 2024
1 parent faab885 commit 6d5f208
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Next release

- fix: pending storage & sequencer_provider
- refactor: support pending blocks & db crate
- refactor: new crate exec
- fix(issue): Removed unrelated link from issue template
Expand Down
3 changes: 3 additions & 0 deletions crates/client/db/src/block_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ impl DeoxysBackend {
tx.put_cf(&col, ROW_PENDING_INFO, bincode::serialize(&block.info)?);
tx.put_cf(&col, ROW_PENDING_INNER, bincode::serialize(&block.inner)?);
tx.put_cf(&col, ROW_PENDING_STATE_UPDATE, bincode::serialize(&state_update)?);
let mut writeopts = WriteOptions::new();
writeopts.disable_wal(true);
self.db.write_opt(tx, &writeopts)?;
Ok(())
}

Expand Down
14 changes: 12 additions & 2 deletions crates/client/exec/src/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl<'a> ExecutionContext<'a> {
let mut executed_prev = 0;
for (index, tx) in transactions_before.into_iter().enumerate() {
let hash = tx.tx_hash();
log::debug!("reexecuting {hash:#}");
log::debug!("executing {hash:#}");
tx.execute(&mut cached_state, &self.block_context, charge_fee, validate).map_err(|err| TxReexecError {
block_n: self.db_id,
hash,
Expand All @@ -39,7 +39,7 @@ impl<'a> ExecutionContext<'a> {
.enumerate()
.map(|(index, tx)| {
let hash = tx.tx_hash();
log::debug!("reexecuting {hash:#} (trace)");
log::debug!("executing {hash:#} (trace)");
let tx_type = tx.tx_type();
let fee_type = tx.fee_type();

Expand All @@ -54,6 +54,16 @@ impl<'a> ExecutionContext<'a> {
let mut state = CachedState::<_>::create_transactional(&mut cached_state);
let execution_info = tx
.execute(&mut state, &self.block_context, charge_fee, validate)
.and_then(|mut tx_info| {
if tx_info.actual_fee.0 == 0 {
tx_info.actual_fee = blockifier::fee::fee_utils::calculate_tx_fee(
&tx_info.actual_resources,
&self.block_context,
&fee_type,
)?;
}
Ok(tx_info)
})
.map_err(|err| TxReexecError { block_n: self.db_id, hash, index: executed_prev + index, err })?;
let state_diff = state.to_state_diff();
state.commit();
Expand Down
2 changes: 1 addition & 1 deletion crates/client/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ impl Starknet {
backend,
starting_block,
sequencer_provider: Arc::new(SequencerGatewayProvider::new(
chain_config.feeder_gateway.clone(),
chain_config.gateway.clone(),
chain_config.feeder_gateway.clone(),
chain_config.chain_id,
)),
chain_config,
Expand Down

0 comments on commit 6d5f208

Please sign in to comment.