debug_traceCall and debug_traceBlock #261

Open
i-norden wants to merge 16 commits from ian/tracing into v5
Showing only changes of commit 89082466fc - Show all commits

View File

@ -27,7 +27,9 @@ import (
"strconv" "strconv"
"time" "time"
"github.com/cerc-io/plugeth-statediff" "github.com/ethereum/go-ethereum/core/vm"
statediff "github.com/cerc-io/plugeth-statediff"
"github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/hexutil"
@ -1008,6 +1010,45 @@ func (diff *StateOverride) Apply(state *ipld_direct_state.StateDB) error {
return nil return nil
} }
// BlockOverrides is a set of header fields to override.
type BlockOverrides struct {
Number *hexutil.Big
Difficulty *hexutil.Big
Time *hexutil.Uint64
GasLimit *hexutil.Uint64
Coinbase *common.Address
Random *common.Hash
BaseFee *hexutil.Big
}
// Apply overrides the given header fields into the given block context.
func (diff *BlockOverrides) Apply(blockCtx *vm.BlockContext) {
if diff == nil {
return
}
if diff.Number != nil {
blockCtx.BlockNumber = diff.Number.ToInt()
}
if diff.Difficulty != nil {
blockCtx.Difficulty = diff.Difficulty.ToInt()
}
if diff.Time != nil {
blockCtx.Time = uint64(*diff.Time)
}
if diff.GasLimit != nil {
blockCtx.GasLimit = uint64(*diff.GasLimit)
}
if diff.Coinbase != nil {
blockCtx.Coinbase = *diff.Coinbase
}
if diff.Random != nil {
blockCtx.Random = diff.Random
}
if diff.BaseFee != nil {
blockCtx.BaseFee = diff.BaseFee.ToInt()
}
}
// Call executes the given transaction on the state for the given block number. // Call executes the given transaction on the state for the given block number.
// //
// Additionally, the caller can specify a batch of contract for fields overriding. // Additionally, the caller can specify a batch of contract for fields overriding.