@@ -103,11 +103,24 @@ int main(int argc, const char* argv[])
103
103
tx.chain_id = chain_id;
104
104
105
105
auto res = state::transition (state, block, tx, rev, vm);
106
+
107
+ const auto tx_computed_hash = keccak256 (rlp::encode (tx));
108
+
109
+ if (j_txs[i].contains (" hash" ) && j_txs[i][" hash" ].is_string ())
110
+ {
111
+ const auto tx_loaded_hash_opt =
112
+ evmc::from_hex<bytes32>(j_txs[i][" hash" ].get <std::string>());
113
+
114
+ if (tx_loaded_hash_opt.has_value () &&
115
+ tx_loaded_hash_opt.value () != tx_computed_hash)
116
+ throw std::logic_error (" hash mismatch" );
117
+ }
118
+
106
119
if (holds_alternative<std::error_code>(res))
107
120
{
108
121
const auto ec = std::get<std::error_code>(res);
109
122
json::json j_rejected_tx;
110
- j_rejected_tx[" hash" ] = j_txs[i][ " hash " ] ;
123
+ j_rejected_tx[" hash" ] = hex0x (tx_computed_hash) ;
111
124
j_rejected_tx[" index" ] = i;
112
125
j_rejected_tx[" error" ] = ec.message ();
113
126
j_result[" rejected" ].push_back (j_rejected_tx);
@@ -120,7 +133,8 @@ int main(int argc, const char* argv[])
120
133
121
134
txs_logs.insert (txs_logs.end (), tx_logs.begin (), tx_logs.end ());
122
135
auto & j_receipt = j_result[" receipts" ][j_result[" receipts" ].size ()];
123
- j_receipt[" transactionHash" ] = j_txs[i][" hash" ];
136
+
137
+ j_receipt[" transactionHash" ] = hex0x (tx_computed_hash);
124
138
j_receipt[" gasUsed" ] = hex0x (static_cast <uint64_t >(receipt.gas_used ));
125
139
j_receipt[" cumulativeGasUsed" ] = j_receipt[" gasUsed" ];
126
140
@@ -165,9 +179,10 @@ int main(int argc, const char* argv[])
165
179
166
180
std::ofstream{output_dir / output_alloc_file} << std::setw (2 ) << j_alloc;
167
181
}
168
- catch (... )
182
+ catch (const std:: exception & e )
169
183
{
170
- std::cerr << " Unhandled exception" << std::endl;
184
+ std::cerr << e.what () << std::endl;
185
+ return 1 ;
171
186
}
172
187
173
188
return 0 ;
0 commit comments