Skip to content

Commit

Permalink
fix: importer working again (#246)
Browse files Browse the repository at this point in the history
  • Loading branch information
dinhani-cw authored Feb 21, 2024
1 parent 18cf3ac commit ef077a3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ importer-download *args="":

# Importer: Import downloaded external RPC blocks to Stratus storage
importer-import:
cargo run --bin importer-import -- --postgres {{postgres_url}} --storage inmemory
cargo run --bin importer-import --release -- --postgres {{postgres_url}} --storage inmemory

# ------------------------------------------------------------------------------
# Test tasks
Expand Down
2 changes: 1 addition & 1 deletion src/eth/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ impl EthExecutor {
return Err(e);
};

self.storage.save_account_changes(block.number(), execution.clone()).await?;
// temporarily save state to next transactions from the same block
self.storage.save_account_changes(block.number(), execution.clone()).await?;
executions.push((tx, receipt, execution));
}
Err(e) => {
Expand Down
16 changes: 5 additions & 11 deletions src/eth/storage/inmemory/inmemory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,21 +383,15 @@ fn save_account_changes(state: &mut InMemoryStorageState, block_number: BlockNum
.entry(changes.address.clone())
.or_insert_with(|| InMemoryAccount::new(changes.address));

// nonce
if let Some(nonce) = changes.nonce.take_modified() {
// account basic info
if let Some(nonce) = changes.nonce.take() {
account.set_nonce(block_number, nonce);
}

// balance
if let Some(balance) = changes.balance.take_modified() {
if let Some(balance) = changes.balance.take() {
account.set_balance(block_number, balance);
}

// bytecode
if is_success {
if let Some(Some(bytecode)) = changes.bytecode.take_modified() {
account.set_bytecode(block_number, bytecode);
}
if let Some(Some(bytecode)) = changes.bytecode.take() {
account.set_bytecode(block_number, bytecode);
}

// slots
Expand Down

0 comments on commit ef077a3

Please sign in to comment.