mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
fix(trace): change l1Fee type from uint64 to *big.Int (#360)
* fix: change l1Fee type from uint64 to *big.Int * use hexutil.Big
This commit is contained in:
parent
983d630244
commit
4e0daeb300
6 changed files with 14 additions and 10 deletions
|
|
@ -44,10 +44,10 @@ type StorageTrace struct {
|
||||||
// while replaying a transaction in debug mode as well as transaction
|
// while replaying a transaction in debug mode as well as transaction
|
||||||
// execution status, the amount of gas used and the return value
|
// execution status, the amount of gas used and the return value
|
||||||
type ExecutionResult struct {
|
type ExecutionResult struct {
|
||||||
L1Fee uint64 `json:"l1Fee,omitempty"`
|
L1Fee *hexutil.Big `json:"l1Fee,omitempty"`
|
||||||
Gas uint64 `json:"gas"`
|
Gas uint64 `json:"gas"`
|
||||||
Failed bool `json:"failed"`
|
Failed bool `json:"failed"`
|
||||||
ReturnValue string `json:"returnValue"`
|
ReturnValue string `json:"returnValue"`
|
||||||
// Sender's account state (before Tx)
|
// Sender's account state (before Tx)
|
||||||
From *AccountWrapper `json:"from,omitempty"`
|
From *AccountWrapper `json:"from,omitempty"`
|
||||||
// Receiver's account state (before Tx)
|
// Receiver's account state (before Tx)
|
||||||
|
|
|
||||||
|
|
@ -930,6 +930,7 @@ func (api *API) traceTx(ctx context.Context, message core.Message, txctx *Contex
|
||||||
Failed: result.Failed(),
|
Failed: result.Failed(),
|
||||||
ReturnValue: returnVal,
|
ReturnValue: returnVal,
|
||||||
StructLogs: vm.FormatLogs(tracer.StructLogs()),
|
StructLogs: vm.FormatLogs(tracer.StructLogs()),
|
||||||
|
L1Fee: (*hexutil.Big)(result.L1Fee),
|
||||||
}, nil
|
}, nil
|
||||||
|
|
||||||
case Tracer:
|
case Tracer:
|
||||||
|
|
|
||||||
|
|
@ -384,16 +384,12 @@ func (api *API) getTxResult(env *traceEnv, state *state.StateDB, index int, bloc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var l1Fee uint64
|
|
||||||
if result.L1Fee != nil {
|
|
||||||
l1Fee = result.L1Fee.Uint64()
|
|
||||||
}
|
|
||||||
env.executionResults[index] = &types.ExecutionResult{
|
env.executionResults[index] = &types.ExecutionResult{
|
||||||
From: sender,
|
From: sender,
|
||||||
To: receiver,
|
To: receiver,
|
||||||
AccountCreated: createdAcc,
|
AccountCreated: createdAcc,
|
||||||
AccountsAfter: after,
|
AccountsAfter: after,
|
||||||
L1Fee: l1Fee,
|
L1Fee: (*hexutil.Big)(result.L1Fee),
|
||||||
Gas: result.UsedGas,
|
Gas: result.UsedGas,
|
||||||
Failed: result.Failed(),
|
Failed: result.Failed(),
|
||||||
ReturnValue: fmt.Sprintf("%x", returnVal),
|
ReturnValue: fmt.Sprintf("%x", returnVal),
|
||||||
|
|
|
||||||
|
|
@ -164,10 +164,12 @@ func checkStructLogs(t *testing.T, expect []*txTraceResult, actual []*types.Exec
|
||||||
assert.Equal(t, len(expect), len(actual))
|
assert.Equal(t, len(expect), len(actual))
|
||||||
for i, val := range expect {
|
for i, val := range expect {
|
||||||
trace1, trace2 := val.Result.(*types.ExecutionResult), actual[i]
|
trace1, trace2 := val.Result.(*types.ExecutionResult), actual[i]
|
||||||
|
assert.Equal(t, trace1.L1Fee, trace2.L1Fee)
|
||||||
assert.Equal(t, trace1.Failed, trace2.Failed)
|
assert.Equal(t, trace1.Failed, trace2.Failed)
|
||||||
assert.Equal(t, trace1.Gas, trace2.Gas)
|
assert.Equal(t, trace1.Gas, trace2.Gas)
|
||||||
assert.Equal(t, trace1.ReturnValue, trace2.ReturnValue)
|
assert.Equal(t, trace1.ReturnValue, trace2.ReturnValue)
|
||||||
assert.Equal(t, len(trace1.StructLogs), len(trace2.StructLogs))
|
assert.Equal(t, len(trace1.StructLogs), len(trace2.StructLogs))
|
||||||
|
// TODO: compare other fields
|
||||||
|
|
||||||
for i, opcode := range trace1.StructLogs {
|
for i, opcode := range trace1.StructLogs {
|
||||||
data1, err := json.Marshal(opcode)
|
data1, err := json.Marshal(opcode)
|
||||||
|
|
|
||||||
|
|
@ -218,6 +218,7 @@ func TestTraceCall(t *testing.T) {
|
||||||
config: nil,
|
config: nil,
|
||||||
expectErr: nil,
|
expectErr: nil,
|
||||||
expect: &types.ExecutionResult{
|
expect: &types.ExecutionResult{
|
||||||
|
L1Fee: (*hexutil.Big)(big.NewInt(0)),
|
||||||
Gas: params.TxGas,
|
Gas: params.TxGas,
|
||||||
Failed: false,
|
Failed: false,
|
||||||
ReturnValue: "",
|
ReturnValue: "",
|
||||||
|
|
@ -235,6 +236,7 @@ func TestTraceCall(t *testing.T) {
|
||||||
config: nil,
|
config: nil,
|
||||||
expectErr: nil,
|
expectErr: nil,
|
||||||
expect: &types.ExecutionResult{
|
expect: &types.ExecutionResult{
|
||||||
|
L1Fee: (*hexutil.Big)(big.NewInt(0)),
|
||||||
Gas: params.TxGas,
|
Gas: params.TxGas,
|
||||||
Failed: false,
|
Failed: false,
|
||||||
ReturnValue: "",
|
ReturnValue: "",
|
||||||
|
|
@ -264,6 +266,7 @@ func TestTraceCall(t *testing.T) {
|
||||||
config: nil,
|
config: nil,
|
||||||
expectErr: nil,
|
expectErr: nil,
|
||||||
expect: &types.ExecutionResult{
|
expect: &types.ExecutionResult{
|
||||||
|
L1Fee: (*hexutil.Big)(big.NewInt(0)),
|
||||||
Gas: params.TxGas,
|
Gas: params.TxGas,
|
||||||
Failed: false,
|
Failed: false,
|
||||||
ReturnValue: "",
|
ReturnValue: "",
|
||||||
|
|
@ -281,6 +284,7 @@ func TestTraceCall(t *testing.T) {
|
||||||
config: nil,
|
config: nil,
|
||||||
expectErr: nil,
|
expectErr: nil,
|
||||||
expect: &types.ExecutionResult{
|
expect: &types.ExecutionResult{
|
||||||
|
L1Fee: (*hexutil.Big)(big.NewInt(0)),
|
||||||
Gas: params.TxGas,
|
Gas: params.TxGas,
|
||||||
Failed: false,
|
Failed: false,
|
||||||
ReturnValue: "",
|
ReturnValue: "",
|
||||||
|
|
@ -334,6 +338,7 @@ func TestTraceTransaction(t *testing.T) {
|
||||||
t.Errorf("Failed to trace transaction %v", err)
|
t.Errorf("Failed to trace transaction %v", err)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(result, &types.ExecutionResult{
|
if !reflect.DeepEqual(result, &types.ExecutionResult{
|
||||||
|
L1Fee: (*hexutil.Big)(big.NewInt(0)),
|
||||||
Gas: params.TxGas,
|
Gas: params.TxGas,
|
||||||
Failed: false,
|
Failed: false,
|
||||||
ReturnValue: "",
|
ReturnValue: "",
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import (
|
||||||
const (
|
const (
|
||||||
VersionMajor = 4 // Major version component of the current release
|
VersionMajor = 4 // Major version component of the current release
|
||||||
VersionMinor = 1 // Minor version component of the current release
|
VersionMinor = 1 // Minor version component of the current release
|
||||||
VersionPatch = 0 // Patch version component of the current release
|
VersionPatch = 1 // Patch version component of the current release
|
||||||
VersionMeta = "sepolia" // Version metadata to append to the version string
|
VersionMeta = "sepolia" // Version metadata to append to the version string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue