@@ -56,24 +56,27 @@ impl TxExecStrategy<EthereumTxEssence> for EthTxExecStrategy {
56
56
// Compute the spec id
57
57
let spec_id = block_builder. chain_spec . spec_id ( header. number ) ;
58
58
if !SpecId :: enabled ( spec_id, MIN_SPEC_ID ) {
59
- bail ! (
60
- "Invalid protocol version: expected >= {:?}, got {:?}" ,
61
- MIN_SPEC_ID ,
62
- spec_id,
63
- )
59
+ bail ! ( "Invalid protocol version: expected >= {MIN_SPEC_ID:?}, got {spec_id:?}" ) ;
64
60
}
65
61
66
62
#[ cfg( not( target_os = "zkvm" ) ) ]
67
63
{
68
64
use chrono:: { TimeZone , Utc } ;
69
65
use log:: info;
70
66
let dt = Utc
71
- . timestamp_opt ( block_builder. input . timestamp . try_into ( ) . unwrap ( ) , 0 )
67
+ . timestamp_opt (
68
+ block_builder
69
+ . input
70
+ . timestamp
71
+ . try_into ( )
72
+ . expect ( "Timestamp could not fit into i64" ) ,
73
+ 0 ,
74
+ )
72
75
. unwrap ( ) ;
73
76
74
77
info ! ( "Block no. {}" , header. number) ;
75
- info ! ( " EVM spec ID: {:?}" , spec_id ) ;
76
- info ! ( " Timestamp: {}" , dt ) ;
78
+ info ! ( " EVM spec ID: {spec_id :?}" ) ;
79
+ info ! ( " Timestamp: {dt}" ) ;
77
80
info ! ( " Transactions: {}" , block_builder. input. transactions. len( ) ) ;
78
81
info ! ( " Withdrawals: {}" , block_builder. input. withdrawals. len( ) ) ;
79
82
info ! ( " Fee Recipient: {:?}" , block_builder. input. beneficiary) ;
@@ -92,15 +95,15 @@ impl TxExecStrategy<EthereumTxEssence> for EthTxExecStrategy {
92
95
} )
93
96
. modify_block_env ( |blk_env| {
94
97
// set the EVM block environment
95
- blk_env. number = header. number . try_into ( ) . unwrap ( ) ;
98
+ blk_env. number = U256 :: from ( header. number ) ;
96
99
blk_env. coinbase = block_builder. input . beneficiary ;
97
100
blk_env. timestamp = header. timestamp ;
98
101
blk_env. difficulty = U256 :: ZERO ;
99
102
blk_env. prevrandao = Some ( header. mix_hash ) ;
100
103
blk_env. basefee = header. base_fee_per_gas ;
101
104
blk_env. gas_limit = block_builder. input . gas_limit ;
102
105
} )
103
- . with_db ( block_builder. db . take ( ) . unwrap ( ) )
106
+ . with_db ( block_builder. db . take ( ) . expect ( "No database" ) )
104
107
. build ( ) ;
105
108
106
109
// bloom filter over all transaction logs
@@ -118,34 +121,34 @@ impl TxExecStrategy<EthereumTxEssence> for EthTxExecStrategy {
118
121
// verify the transaction signature
119
122
let tx_from = tx
120
123
. recover_from ( )
121
- . with_context ( || format ! ( "Error recovering address for transaction {}" , tx_no ) ) ?;
124
+ . with_context ( || format ! ( "Error recovering address for transaction {tx_no}" ) ) ?;
122
125
123
126
#[ cfg( not( target_os = "zkvm" ) ) ]
124
127
{
125
128
let tx_hash = tx. hash ( ) ;
126
- debug ! ( "Tx no. {} (hash: {})" , tx_no , tx_hash ) ;
129
+ debug ! ( "Tx no. {tx_no } (hash: {tx_hash })" ) ;
127
130
debug ! ( " Type: {}" , tx. essence. tx_type( ) ) ;
128
- debug ! ( " Fr: {:?}" , tx_from ) ;
131
+ debug ! ( " Fr: {tx_from :?}" ) ;
129
132
debug ! ( " To: {:?}" , tx. essence. to( ) . unwrap_or_default( ) ) ;
130
133
}
131
134
132
135
// verify transaction gas
133
136
let block_available_gas = block_builder. input . gas_limit - cumulative_gas_used;
134
137
if block_available_gas < tx. essence . gas_limit ( ) {
135
- bail ! ( "Error at transaction {}: gas exceeds block limit" , tx_no ) ;
138
+ bail ! ( "Error at transaction {tx_no }: gas exceeds block limit" ) ;
136
139
}
137
140
138
141
// process the transaction
139
142
fill_eth_tx_env ( & mut evm. env ( ) . tx , & tx. essence , tx_from) ;
140
143
let ResultAndState { result, state } = evm
141
144
. transact ( )
142
- . map_err ( |evm_err| anyhow ! ( "Error at transaction {}: {:?}" , tx_no , evm_err ) ) ?;
145
+ . map_err ( |evm_err| anyhow ! ( "Error at transaction {tx_no }: {evm_err :?}" ) ) ?;
143
146
144
147
let gas_used = result. gas_used ( ) . try_into ( ) . unwrap ( ) ;
145
148
cumulative_gas_used = cumulative_gas_used. checked_add ( gas_used) . unwrap ( ) ;
146
149
147
150
#[ cfg( not( target_os = "zkvm" ) ) ]
148
- debug ! ( " Ok: {:?}" , result ) ;
151
+ debug ! ( " Ok: {result :?}" ) ;
149
152
150
153
// create the receipt from the EVM result
151
154
let receipt = Receipt :: new (
@@ -175,8 +178,7 @@ impl TxExecStrategy<EthereumTxEssence> for EthTxExecStrategy {
175
178
if account. is_touched ( ) {
176
179
// log account
177
180
debug ! (
178
- " State {:?} (is_selfdestructed={}, is_loaded_as_not_existing={}, is_created={}, is_empty={})" ,
179
- address,
181
+ " State {address:?} (is_selfdestructed={}, is_loaded_as_not_existing={}, is_created={}, is_empty={})" ,
180
182
account. is_selfdestructed( ) ,
181
183
account. is_loaded_as_not_existing( ) ,
182
184
account. is_created( ) ,
@@ -191,7 +193,7 @@ impl TxExecStrategy<EthereumTxEssence> for EthTxExecStrategy {
191
193
// log state changes
192
194
for ( addr, slot) in & account. storage {
193
195
if slot. is_changed ( ) {
194
- debug ! ( " Storage address: {:?}" , addr ) ;
196
+ debug ! ( " Storage address: {addr :?}" ) ;
195
197
debug ! ( " Before: {:?}" , slot. original_value( ) ) ;
196
198
debug ! ( " After: {:?}" , slot. present_value( ) ) ;
197
199
}
@@ -217,7 +219,7 @@ impl TxExecStrategy<EthereumTxEssence> for EthTxExecStrategy {
217
219
{
218
220
debug ! ( "Withdrawal no. {}" , withdrawal. index) ;
219
221
debug ! ( " Recipient: {:?}" , withdrawal. address) ;
220
- debug ! ( " Value: {}" , amount_wei ) ;
222
+ debug ! ( " Value: {amount_wei}" ) ;
221
223
}
222
224
// Credit withdrawal amount
223
225
increase_account_balance ( & mut evm. context . evm . db , withdrawal. address , amount_wei) ?;
@@ -233,11 +235,7 @@ impl TxExecStrategy<EthereumTxEssence> for EthTxExecStrategy {
233
235
header. receipts_root = receipt_trie. hash ( ) ;
234
236
header. logs_bloom = logs_bloom;
235
237
header. gas_used = cumulative_gas_used;
236
- header. withdrawals_root = if spec_id < SpecId :: SHANGHAI {
237
- None
238
- } else {
239
- Some ( withdrawals_trie. hash ( ) )
240
- } ;
238
+ header. withdrawals_root = ( spec_id < SpecId :: SHANGHAI ) . then_some ( withdrawals_trie. hash ( ) ) ;
241
239
242
240
// Leak memory, save cycles
243
241
guest_mem_forget ( [ tx_trie, receipt_trie, withdrawals_trie] ) ;
@@ -311,13 +309,7 @@ where
311
309
// Read account from database
312
310
let mut account: Account = db
313
311
. basic ( address)
314
- . map_err ( |db_err| {
315
- anyhow ! (
316
- "Error increasing account balance for {}: {:?}" ,
317
- address,
318
- db_err
319
- )
320
- } ) ?
312
+ . map_err ( |db_err| anyhow ! ( "Error increasing account balance for {address}: {db_err:?}" ) ) ?
321
313
. unwrap_or_default ( )
322
314
. into ( ) ;
323
315
// Credit withdrawal amount
0 commit comments