diff --git a/nimbus/evm/interpreter/gas_costs.nim b/nimbus/evm/interpreter/gas_costs.nim index b8f3dcec7..350fb8bac 100644 --- a/nimbus/evm/interpreter/gas_costs.nim +++ b/nimbus/evm/interpreter/gas_costs.nim @@ -508,9 +508,10 @@ template gasCosts(fork: EVMFork, prefix, ResultGasCostsName: untyped) = raise newException(TypeError, "GasInt Overflow (" & $gasParams.kind & ") " & $gasParams.c_contractGas) result.gasRefund = gasParams.c_contractGas.truncate(GasInt) - if result.gasCost.u256 + result.gasRefund.u256 > high(GasInt).u256: - raise newException(TypeError, "GasInt overflow, gasCost=" & - $result.gasCost & ", gasRefund=" & $result.gasRefund) + if result.gasRefund > 0: # skip check if gasRefund is negative + if result.gasCost.u256 + result.gasRefund.u256 > high(GasInt).u256: + raise newException(TypeError, "GasInt overflow, gasCost=" & + $result.gasCost & ", gasRefund=" & $result.gasRefund) result.gasCost += result.gasRefund diff --git a/tools/t8n/testdata/00-512/exp.json b/tools/t8n/testdata/00-512/exp.json index 026f7abe6..bf27d3d6a 100644 --- a/tools/t8n/testdata/00-512/exp.json +++ b/tools/t8n/testdata/00-512/exp.json @@ -1,42 +1,40 @@ { "alloc": { - "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba": { - "balance": "0x142b84" - }, "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f": { - "storage": { - "0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000000000000000000000000000000000000000020", - "0x0000000000000000000000000000000000000000000000000000000000000001": "0x0000000000000000000000000000000000000000000000000000000000112233" - }, "balance": "0x0", - "nonce": "0x2" + "storage": { + "0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000000000000000000000000000000000000000001" + } + }, + "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba": { + "balance": "0x6400000000" }, "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": { - "balance": "0x63ffebd47c", + "balance": "0x0", "nonce": "0x1" } }, "result": { - "stateRoot": "0xe0cfa6916b126d6a08639aa0b928a053b7bba1390535e166c1f5d41068a4fc45", + "stateRoot": "0x5c909919be50eb74177909035f65aaeebd416d956f0b6bc2fbd4e6c15daa889f", "txRoot": "0xa9ba46978e16fd6192f2d3f12f1bc7d7a7f92684452c0783378fc17539729c6b", - "receiptsRoot": "0xe385c544fafdddffbf18a71d9c746174b861551d96d534f9d64885158bea37ad", + "receiptsRoot": "0x97fe59b8004de685658f61c2939be1892eb8593c1ce622c392dd985946712e06", "logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "receipts": [ { - "root": "0x", - "status": "0x1", - "cumulativeGasUsed": "0x2045a", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "logs": null, - "transactionHash": "0xdbb728ec3bb0b37eb49274b839b556865bf27a654f91ef7787ef05e97d1fb15c", - "contractAddress": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "gasUsed": "0x2045a", - "blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "transactionIndex": "0x0" + "root": "0x", + "status": "0x0", + "cumulativeGasUsed": "0xa00000000", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "logs": null, + "transactionHash": "0xdbb728ec3bb0b37eb49274b839b556865bf27a654f91ef7787ef05e97d1fb15c", + "contractAddress": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f", + "gasUsed": "0xa00000000", + "blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "transactionIndex": "0x0" } ], "currentDifficulty": "0x20000", - "gasUsed": "0x2045a" + "gasUsed": "0xa00000000" } -} \ No newline at end of file +} diff --git a/tools/t8n/testdata/00-513/exp.json b/tools/t8n/testdata/00-513/exp.json index 230fe546e..e4c8e67cc 100644 --- a/tools/t8n/testdata/00-513/exp.json +++ b/tools/t8n/testdata/00-513/exp.json @@ -1,42 +1,40 @@ { "alloc": { - "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba": { - "balance": "0x13d300" - }, "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f": { - "storage": { - "0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000000000000000000000000000000000000000020", - "0x0000000000000000000000000000000000000000000000000000000000000001": "0x0000000000000000000000000000000000000000000000000000000000112233" - }, "balance": "0x0", - "nonce": "0x2" + "storage": { + "0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000000000000000000000000000000000000000001" + } + }, + "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba": { + "balance": "0x63e700000a" }, "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": { - "balance": "0x63ffec2d00", + "balance": "0x18fffff6", "nonce": "0x1" } }, "result": { - "stateRoot": "0xd9dac0bdb42187224bd22799fb6d74ee60b019cab5f07e7d6e986d8a05685517", + "stateRoot": "0xa90981ea96b4654da0da00c9e30e340e8dc644333d05bcbeeef3035aa4a727f5", "txRoot": "0x6b6b3de330c8f068c4e72c00440dfba319a4aff53a124121f89e0a1875488cb4", - "receiptsRoot": "0xf1e764ea6c4f95e27ff8e8e36afa8ef4485d98393f2831f522085fc4e86eae7c", + "receiptsRoot": "0x87fd847f6f94482827f1f719603c9a6f081bfc73256b0a70b515a084987b797b", "logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "receipts": [ { - "root": "0x", - "status": "0x1", - "cumulativeGasUsed": "0x1fb80", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "logs": null, - "transactionHash": "0x57ffa2f9cb76c8a72f602a26f2d11774788f38b9424094136d75baaef5f1404e", - "contractAddress": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "gasUsed": "0x1fb80", - "blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "transactionIndex": "0x0" + "root": "0x", + "status": "0x0", + "cumulativeGasUsed": "0x9fd800001", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "logs": null, + "transactionHash": "0x57ffa2f9cb76c8a72f602a26f2d11774788f38b9424094136d75baaef5f1404e", + "contractAddress": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f", + "gasUsed": "0x9fd800001", + "blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "transactionIndex": "0x0" } ], "currentDifficulty": "0x20000", - "gasUsed": "0x1fb80" + "gasUsed": "0x9fd800001" } -} +} \ No newline at end of file diff --git a/tools/t8n/testdata/00-514/exp.json b/tools/t8n/testdata/00-514/exp.json index 8a9e9a511..86f719f61 100644 --- a/tools/t8n/testdata/00-514/exp.json +++ b/tools/t8n/testdata/00-514/exp.json @@ -1,49 +1,50 @@ { "alloc": { - "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba": { - "balance": "0x1e4e02" - }, "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f": { "balance": "0x0", - "nonce": "0x2" - }, - "0x7b9f5332c245e5c60923427eeb34e5adfba6470e": { "storage": { - "0x0000000000000000000000000000000000000000000000000000000000000001": "0x0000000000000000000000000000000000000000000000000000000000000001" - }, - "balance": "0x0", - "nonce": "0x1" + "0x0000000000000000000000000000000000000000000000000000000000000001": "0x0000000000000000000000000000000000000000000000000000000000000001" + } }, - "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": { - "balance": "0xe8d486c1fe", - "nonce": "0x1" + "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba": { + "balance": "0x1e8480" }, "0xdea0000000000000000000000000000000000000": { "code": "0x6001600155600060015560016002556000600255600160035560006003556001600455600060045560016005556000600555600160065560006006556001600755600060075560016008556000600855600160095560006009556001600a556000600a556001600b556000600b556001600c556000600c556001600d556000600d556001600e556000600e556001600f556000600f5560016010556000601055600160015500", "balance": "0x0" + }, + "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": { + "balance": "0xe8d4868b80", + "nonce": "0x1" + }, + "0x7b9f5332c245e5c60923427eeb34e5adfba6470e": { + "balance": "0x0", + "storage": { + "0x0000000000000000000000000000000000000000000000000000000000000001": "0x0000000000000000000000000000000000000000000000000000000000000001" + } } }, "result": { - "stateRoot": "0x16d0fd49f5ee712bdad56326e859088ee949b87666b8a1aa6d146ae62f00d879", + "stateRoot": "0x5cd4060c604cd171d89098685e46d32c29a0cd2e9ce4b9b9575fd7d3b567211b", "txRoot": "0x875c38cccd9ebeab40d7ff716a3010ede2b215f530a341271d7312d8f444c3b2", - "receiptsRoot": "0x43be55e1ef1e34ceaa4be0c9515bb0a672b25ab41fa9a781d41379777113119b", + "receiptsRoot": "0xea5b87d12423d7570eb418dcdbb9f547f8fcc0577bd026d2189fd8fb550b85cf", "logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "receipts": [ { - "root": "0x", - "status": "0x1", - "cumulativeGasUsed": "0x307cd", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "logs": null, - "transactionHash": "0x96cc2aefef7009d456429678da71afdbd182f7e9d4a133b1c74c547083ef11b0", - "contractAddress": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "gasUsed": "0x307cd", - "blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "transactionIndex": "0x0" + "root": "0x", + "status": "0x0", + "cumulativeGasUsed": "0x30d40", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "logs": null, + "transactionHash": "0x96cc2aefef7009d456429678da71afdbd182f7e9d4a133b1c74c547083ef11b0", + "contractAddress": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f", + "gasUsed": "0x30d40", + "blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "transactionIndex": "0x0" } ], "currentDifficulty": "0x20000", - "gasUsed": "0x307cd" + "gasUsed": "0x30d40" } -} \ No newline at end of file +}