Skip to content

Commit

Permalink
w3vm: dropped deprecated Receipt.GasLimit (#184)
Browse files Browse the repository at this point in the history
Co-authored-by: lmittmann <[email protected]>
  • Loading branch information
lmittmann and lmittmann authored Aug 22, 2024
1 parent f2f9118 commit 52746ee
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 deletions.
1 change: 0 additions & 1 deletion w3vm/receipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ type Receipt struct {

GasUsed uint64 // Gas used for executing the message
GasRefund uint64 // Gas refunded after executing the message
GasLimit uint64 // Deprecated: Minimum required gas limit (gas used without refund)
Logs []*types.Log // Logs emitted by the message
Output []byte // Output bytes of the applied message
ContractAddress *common.Address // Contract address created by a contract creation transaction
Expand Down
1 change: 0 additions & 1 deletion w3vm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ func (v *VM) apply(msg *w3types.Message, isCall bool, hooks *tracing.Hooks) (*Re
f: msg.Func,
GasUsed: result.UsedGas,
GasRefund: result.RefundedGas,
GasLimit: result.UsedGas + v.db.GetRefund(),
Output: result.ReturnData,
Logs: v.db.GetLogs(txHash, 0, w3.Hash0),
}
Expand Down
28 changes: 10 additions & 18 deletions w3vm/vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ func TestVMApply(t *testing.T) {
Value: w3.I("1 ether"),
},
WantReceipt: &w3vm.Receipt{
GasUsed: 21_000,
GasLimit: 21_000,
GasUsed: 21_000,
},
},
{ // WETH transfer
Expand All @@ -170,7 +169,6 @@ func TestVMApply(t *testing.T) {
WantReceipt: &w3vm.Receipt{
GasUsed: 38_853,
GasRefund: 9_713,
GasLimit: 58_753,
Logs: []*types.Log{
{
Address: addrWETH,
Expand Down Expand Up @@ -202,9 +200,8 @@ func TestVMApply(t *testing.T) {
Gas: 100_000,
},
WantReceipt: &w3vm.Receipt{
GasUsed: 24_019,
GasLimit: 24_019,
Err: errors.New("execution reverted"),
GasUsed: 24_019,
Err: errors.New("execution reverted"),
},
WantErr: errors.New("execution reverted"),
},
Expand All @@ -218,10 +215,9 @@ func TestVMApply(t *testing.T) {
To: &addr1,
},
WantReceipt: &w3vm.Receipt{
GasUsed: 21_008,
GasLimit: 21_008,
Output: w3.B("0x00"),
Err: errors.New("execution reverted"),
GasUsed: 21_008,
Output: w3.B("0x00"),
Err: errors.New("execution reverted"),
},
WantErr: errors.New("execution reverted"),
},
Expand All @@ -232,7 +228,6 @@ func TestVMApply(t *testing.T) {
},
WantReceipt: &w3vm.Receipt{
GasUsed: 53_006,
GasLimit: 53_006,
ContractAddress: ptr(crypto.CreateAddress(addr1, 0)),
},
},
Expand All @@ -246,7 +241,6 @@ func TestVMApply(t *testing.T) {
},
WantReceipt: &w3vm.Receipt{
GasUsed: 53_006,
GasLimit: 53_006,
ContractAddress: ptr(crypto.CreateAddress(addr1, 1)),
},
},
Expand All @@ -265,8 +259,7 @@ func TestVMApply(t *testing.T) {
Value: w3.I("1 ether"),
},
WantReceipt: &w3vm.Receipt{
GasUsed: 21_000,
GasLimit: 21_000,
GasUsed: 21_000,
},
},
}
Expand Down Expand Up @@ -540,9 +533,8 @@ func TestVMCall(t *testing.T) {
Input: mustEncodeArgs(funcBalanceOf, addr0),
},
WantReceipt: &w3vm.Receipt{
GasUsed: 23_726,
GasLimit: 23_726,
Output: w3.B("0x0000000000000000000000000000000000000000000000000de0b6b3a7640000"),
GasUsed: 23_726,
Output: w3.B("0x0000000000000000000000000000000000000000000000000de0b6b3a7640000"),
},
},
}
Expand Down Expand Up @@ -716,7 +708,7 @@ func TestVMApply_Integration(t *testing.T) {
cmpopts.EquateEmpty(),
cmpopts.EquateErrors(),
cmpopts.IgnoreUnexported(w3vm.Receipt{}),
cmpopts.IgnoreFields(w3vm.Receipt{}, "GasRefund", "GasLimit", "Output"),
cmpopts.IgnoreFields(w3vm.Receipt{}, "GasRefund", "Output"),
cmpopts.IgnoreFields(types.Log{}, "BlockHash", "BlockNumber", "TxHash", "TxIndex", "Index"),
cmpopts.EquateComparable(common.Address{}, common.Hash{}),
); diff != "" {
Expand Down

0 comments on commit 52746ee

Please sign in to comment.