Skip to content

Commit f7d6322

Browse files
author
Guillermo Rodriguez
committed
Fix state injector logic bug
1 parent ce9c2f9 commit f7d6322

File tree

1 file changed

+24
-32
lines changed

1 file changed

+24
-32
lines changed

translator/src/tasks/final_processor.rs

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,19 @@ pub async fn final_processor(
168168

169169
let mut receipts = Some(vec![]);
170170

171-
let completed_block = if evm_block_num > config.evm_deploy_block.unwrap_or_default() {
171+
let mut completed_block = TelosEVMBlock {
172+
block_num: evm_block_num,
173+
block_hash,
174+
ship_hash: block.block_hash.as_string(),
175+
lib_num: block.lib_num,
176+
lib_hash: block.lib_hash.as_string(),
177+
transactions: vec![],
178+
header,
179+
execution_payload: exec_payload,
180+
extra_fields: Default::default(),
181+
};
182+
183+
if evm_block_num > config.evm_deploy_block.unwrap_or_default() {
172184
for row in block.decoded_rows {
173185
match row {
174186
DecodedRow::Account(removed, acc_diff) => {
@@ -222,39 +234,19 @@ pub async fn final_processor(
222234
.collect(),
223235
);
224236

225-
TelosEVMBlock {
226-
block_num: evm_block_num,
227-
block_hash,
228-
ship_hash: block.block_hash.as_string(),
229-
lib_num: block.lib_num,
230-
lib_hash: block.lib_hash.as_string(),
231-
transactions: block.transactions,
232-
header,
233-
execution_payload: exec_payload,
234-
extra_fields: TelosEngineAPIExtraFields {
235-
statediffs_account: Some(statediffs_account),
236-
statediffs_accountstate: Some(statediffs_accountstate),
237-
revision_changes: block.new_revision,
238-
gasprice_changes: block.new_gas_price,
239-
new_addresses_using_create: Some(new_addresses_using_create),
240-
new_addresses_using_openwallet: Some(new_addresses_using_openwallet),
241-
receipts,
242-
},
243-
}
244-
} else {
237+
completed_block.extra_fields = TelosEngineAPIExtraFields {
238+
statediffs_account: Some(statediffs_account),
239+
statediffs_accountstate: Some(statediffs_accountstate),
240+
revision_changes: block.new_revision,
241+
gasprice_changes: block.new_gas_price,
242+
new_addresses_using_create: Some(new_addresses_using_create),
243+
new_addresses_using_openwallet: Some(new_addresses_using_openwallet),
244+
receipts,
245+
};
246+
} else if evm_block_num == config.evm_deploy_block.unwrap_or_default() {
245247
let (state_dump_block, extra_fields) = generate_extra_fields_from_json(TESTNET_DEPLOY_STATE);
246248
assert_eq!(state_dump_block, evm_block_num, "State dump doesn\'t match configured deploy block");
247-
TelosEVMBlock {
248-
block_num: evm_block_num,
249-
block_hash,
250-
ship_hash: block.block_hash.as_string(),
251-
lib_num: block.lib_num,
252-
lib_hash: block.lib_hash.as_string(),
253-
transactions: block.transactions,
254-
header,
255-
execution_payload: exec_payload,
256-
extra_fields,
257-
}
249+
completed_block.extra_fields = extra_fields;
258250
};
259251

260252
block_map.next(&completed_block, &config.chain_id);

0 commit comments

Comments
 (0)