Skip to content

Commit 310a58d

Browse files
authored
Merge pull request #13695 from ethereum/evmc-refund
test: Support tracking gas refunds
2 parents 50747d6 + 54b4598 commit 310a58d

File tree

53 files changed

+117
-110
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+117
-110
lines changed

test/ExecutionFramework.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,21 @@ void ExecutionFramework::sendMessage(bytes const& _data, bool _isCreation, u256
192192
if (_isCreation)
193193
m_contractAddress = EVMHost::convertFromEVMC(result.create_address);
194194

195-
m_gasUsed = InitialGas - result.gas_left;
195+
unsigned const refundRatio = (m_evmVersion >= langutil::EVMVersion::london() ? 5 : 2);
196+
auto const totalGasUsed = InitialGas - result.gas_left;
197+
auto const gasRefund = min(u256(result.gas_refund), totalGasUsed / refundRatio);
198+
199+
m_gasUsed = totalGasUsed - gasRefund;
196200
m_transactionSuccessful = (result.status_code == EVMC_SUCCESS);
197201

198202
if (m_showMessages)
199203
{
200-
cout << " out: " << util::toHex(m_output) << endl;
201-
cout << " result: " << static_cast<size_t>(result.status_code) << endl;
202-
cout << " gas used: " << m_gasUsed.str() << endl;
204+
cout << " out: " << util::toHex(m_output) << endl;
205+
cout << " result: " << static_cast<size_t>(result.status_code) << endl;
206+
cout << " gas used: " << m_gasUsed.str() << endl;
207+
cout << " gas used (without refund): " << totalGasUsed.str() << endl;
208+
cout << " gas refund (total): " << result.gas_refund << endl;
209+
cout << " gas refund (bound): " << gasRefund.str() << endl;
203210
}
204211
}
205212

0 commit comments

Comments
 (0)