Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

master #25

Merged
merged 57 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
46d8bc4
Enables fast tracing for CALL family
CMajeri Jul 28, 2021
0b450bc
Removes useless code
CMajeri Jul 28, 2021
093ac43
Merge branch 'master' of ssh://github.com/ethereum/go-ethereum into e…
bgiegel Feb 7, 2022
843aa43
Merge branch 'ethereum-master'
bgiegel Feb 7, 2022
ff52ea4
apply log wrapper chervin’s patch
bgiegel Feb 7, 2022
453da32
Merge branch 'ethereum:master' into master
bgiegel Feb 8, 2022
4c6d403
Detect silent failures (no REVERT or error message)
CMajeri May 27, 2022
d87e8eb
Merge remote-tracking branch 'origin/master' into feature/call_failures
CMajeri Jun 21, 2022
a299399
Simplify loop
CMajeri Jun 21, 2022
d1589f4
Merge pull request #4 from taurusgroup/feature/call_failures
CMajeri Jun 21, 2022
581018d
Merge branch 'ethereum:master' into master
bgiegel Jul 20, 2022
d6a2c62
Merge branch 'ethereum:master' into master
hmoens Sep 1, 2022
d0dc349
graphql: return correct logs for tx (#25612)
s1na Aug 31, 2022
3b41be6
graphql: fixes missing tx logs (#25745)
s1na Sep 13, 2022
972007a
Release Geth v1.10.24
karalabe Sep 14, 2022
8f61fc8
params: set TerminalTotalDifficultyPassed to true (#25769)
MariusVanDerWijden Sep 15, 2022
69568c5
params: release Geth v1.10.25
karalabe Sep 15, 2022
85e469f
eth/protocols/snap: fix problems due to idle-but-busy peers (#25651)
holiman Aug 31, 2022
937ea49
eth/protocols/snap: throttle trie heal requests when peers DoS us (#2…
karalabe Sep 9, 2022
a32e69a
trie: check childrens' existence concurrently for snap heal (#25694)
karalabe Sep 6, 2022
99bbb33
eth: fix a rare datarace on CHT challenge reply / shutdown (#25831)
karalabe Sep 20, 2022
27600a5
eth/filters: change filter block to be by-ref (#26054)
holiman Oct 27, 2022
211dbb7
rpc: handle wrong HTTP batch response length (#26064)
jmank88 Nov 2, 2022
e5eb32a
params: release geth v1.10.26 stable
fjl Nov 3, 2022
92cf8e8
Merge tag 'v1.10.26' of https://github.com/ethereum/go-ethereum
Feb 9, 2023
42b793f
Merge pull request #5 from taurusgroup/merge_1.10.26
simonecid Feb 27, 2023
ebcd50e
Merge branch 'master' into release_v1.11.2
simonecid Mar 1, 2023
3b142ef
Merge pull request #8 from taurusgroup/release_v1.11.2
simonecid Mar 1, 2023
b8f419f
Merge pull request #9 from taurusgroup/release_v1.11.5
hmoens Mar 30, 2023
312db2c
Merge pull request #10 from taurusgroup/release_v1.12
dupontcy Jun 27, 2023
a0491a0
deps: update supranational/blst to 0.3.11 (#27890)
dependabot[bot] Aug 10, 2023
55863ce
core/txpool/blobpool: fix metrics name for prometheus export (#27901)
imulmat4 Aug 11, 2023
770db14
ethdb/leveldb: support more than 7 levels in metrics (#27904)
jsvisa Aug 11, 2023
811a674
all: update golang/x/ext and fix slice sorting fallout (#27909)
karalabe Aug 11, 2023
f298ec4
go.mod, build: upgrade c-kzg-4844 (#27907)
fjl Aug 11, 2023
a867039
internal/build: apply -ubuntu to env (#27910)
fjl Aug 12, 2023
bed8460
params: release go-ethereum v1.12.2
fjl Aug 12, 2023
c1a41f7
Merge pull request #14 from taurusgroup/release_v1.12.2
dupontcy Aug 28, 2023
ad217b1
Merge branch 'master' into release_v1.13.2
claudiughioc Sep 28, 2023
0ebfb75
Merge pull request #17 from taurusgroup/release_v1.13.2
claudiughioc Sep 28, 2023
18919df
Merge pull request #20 from taurusgroup/release_v1.13.4
dupontcy Nov 7, 2023
916d6a4
params: release Geth v1.15.5
karalabe Nov 14, 2023
5ba3d57
Merge branch 'release/1.13' into release-1.13.6
fjl Dec 18, 2023
da6cdaf
all: release go-ethereum v1.13.6
fjl Dec 18, 2023
c3d9ca6
all: release go-ethereum v1.13.7
fjl Dec 19, 2023
b20b4a7
all: release go-ethereum v1.13.8
holiman Dec 22, 2023
dd938d1
Merge branch 'master' into release/1.13
fjl Jan 10, 2024
bc0be1b
Merge branch 'master' into release/1.13
karalabe Jan 11, 2024
e4105b9
Merge pull request #21 from taurusgroup/release_v1.13.10
dupontcy Jan 16, 2024
8f7eb9c
all: release go-ethereum v1.13.11 (#28868)
holiman Jan 24, 2024
4aa3062
Merge pull request #22 from taurusgroup/release_v1.13.11
dupontcy Jan 25, 2024
02eb36a
all: release go-ethereum v1.13.12 (#28961)
holiman Feb 9, 2024
7f131dc
Merge branch 'master' into release/1.13
fjl Feb 21, 2024
48174e7
Merge pull request #23 from taurusgroup/release_v1.13.13
dupontcy Feb 26, 2024
2bd6bd0
Merge branch 'master' into release/1.13
karalabe Feb 27, 2024
21637f2
Merge branch 'master' into release_v1.13.14
dupontcy Feb 27, 2024
e4b72e8
Merge pull request #24 from taurusgroup/release_v1.13.14
dupontcy Feb 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 65 additions & 2 deletions eth/tracers/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,22 @@ func (s *StructLog) ErrorString() string {
return ""
}

type wrappedLog struct {
parent *wrappedLog
error error
log StructLog
children []*wrappedLog
}

// StructLogger is an EVM state logger and implements EVMLogger.
//
// StructLogger can capture state based on the given Log configuration and also keeps
// a track record of modified storage which is used in reporting snapshots of the
// contract their storage.
type StructLogger struct {
current *wrappedLog
depth int

cfg Config
env *vm.EVM

Expand Down Expand Up @@ -143,6 +153,8 @@ func (l *StructLogger) Reset() {
// CaptureStart implements the EVMLogger interface to initialize the tracing operation.
func (l *StructLogger) CaptureStart(env *vm.EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) {
l.env = env
l.depth = 0
l.current = &wrappedLog{}
}

// CaptureState logs a new structured log message and pushes it out to the environment
Expand All @@ -161,6 +173,35 @@ func (l *StructLogger) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, s
memory := scope.Memory
stack := scope.Stack
contract := scope.Contract
for ; l.depth > depth-1; l.depth = l.depth - 1 {
i := l.depth - (depth - 1)
if l.current.error == nil {
switch stack.Data()[len(stack.Data())-i].Bytes32()[31] {
case 0x00:
l.current.error = fmt.Errorf("call failed")
}
}
l.current = l.current.parent
}
if err != nil {
l.current.error = err
}
switch op {
case vm.CALL, vm.DELEGATECALL, vm.STATICCALL, vm.CALLCODE:
l.depth = l.depth + 1
wl := &wrappedLog{
parent: l.current,
error: l.current.error,
}
l.current.children = append(l.current.children, wl)
l.current = wl
case vm.REVERT:
l.current.error = vm.ErrExecutionReverted
return
default:
return
}

// Copy a snapshot of the current memory state to a new buffer
var mem []byte
if l.cfg.EnableMemory {
Expand Down Expand Up @@ -210,7 +251,7 @@ func (l *StructLogger) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, s
}
// create a new snapshot of the EVM.
log := StructLog{pc, op, gas, cost, mem, memory.Len(), stck, rdata, storage, depth, l.env.StateDB.GetRefund(), err}
l.logs = append(l.logs, log)
l.current.log = log
}

// CaptureFault implements the EVMLogger interface to trace an execution fault
Expand All @@ -220,6 +261,17 @@ func (l *StructLogger) CaptureFault(pc uint64, op vm.OpCode, gas, cost uint64, s

// CaptureEnd is called after the call finishes to finalize the tracing.
func (l *StructLogger) CaptureEnd(output []byte, gasUsed uint64, err error) {
for ; l.depth > 1; l.depth-- {
l.current = l.current.parent
}
l.current.log = StructLog{
Op: vm.CALL,
GasCost: gasUsed,
ReturnData: output,
Depth: 0,
Err: err,
}

l.output = output
l.err = err
if l.cfg.Debug {
Expand Down Expand Up @@ -270,8 +322,19 @@ func (l *StructLogger) CaptureTxEnd(restGas uint64) {
l.usedGas = l.gasLimit - restGas
}

// Depth first append for all children (stack max depth is 1024)
func (l *wrappedLog) getLogs() []StructLog {
var logs []StructLog
l.log.Err = l.error
logs = append(logs, l.log)
for _, child := range l.children {
logs = append(logs, child.getLogs()...)
}
return logs
}

// StructLogs returns the captured log entries.
func (l *StructLogger) StructLogs() []StructLog { return l.logs }
func (l *StructLogger) StructLogs() []StructLog { return l.current.getLogs() }

// Error returns the VM error captured by the trace.
func (l *StructLogger) Error() error { return l.err }
Expand Down
65 changes: 65 additions & 0 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,71 @@ func (s *BlockChainAPI) EstimateGas(ctx context.Context, args TransactionArgs, b
return DoEstimateGas(ctx, s.b, args, bNrOrHash, overrides, s.b.RPCGasCap())
}

// ExecutionResult groups all structured logs emitted by the EVM
// while replaying a transaction in debug mode as well as transaction
// execution status, the amount of gas used and the return value
type ExecutionResult struct {
Gas uint64 `json:"gas"`
Failed bool `json:"failed"`
ReturnValue string `json:"returnValue"`
StructLogs []StructLogRes `json:"structLogs"`
}

// StructLogRes stores a structured log emitted by the EVM while replaying a
// transaction in debug mode
type StructLogRes struct {
Pc uint64 `json:"pc"`
Op string `json:"op"`
Gas uint64 `json:"gas"`
GasCost uint64 `json:"gasCost"`
Depth int `json:"depth"`
Error string `json:"error,omitempty"`
Stack *[]string `json:"stack,omitempty"`
Memory *[]string `json:"memory,omitempty"`
Storage *map[string]string `json:"storage,omitempty"`
}

// FormatLogs formats EVM returned structured logs for json output
func FormatLogs(logs []logger.StructLog) []StructLogRes {
formatted := make([]StructLogRes, len(logs))
for index, trace := range logs {
var errString string
if trace.Err != nil {
errString = trace.Err.Error()
}
formatted[index] = StructLogRes{
Pc: trace.Pc,
Op: trace.Op.String(),
Gas: trace.Gas,
GasCost: trace.GasCost,
Depth: trace.Depth,
Error: errString,
}
if trace.Stack != nil {
stack := make([]string, len(trace.Stack))
for i, stackValue := range trace.Stack {
stack[i] = stackValue.Hex()
}
formatted[index].Stack = &stack
}
if trace.Memory != nil {
memory := make([]string, 0, (len(trace.Memory)+31)/32)
for i := 0; i+32 <= len(trace.Memory); i += 32 {
memory = append(memory, fmt.Sprintf("%x", trace.Memory[i:i+32]))
}
formatted[index].Memory = &memory
}
if trace.Storage != nil {
storage := make(map[string]string)
for i, storageValue := range trace.Storage {
storage[fmt.Sprintf("%x", i)] = fmt.Sprintf("%x", storageValue)
}
formatted[index].Storage = &storage
}
}
return formatted
}

// RPCMarshalHeader converts the given header to the RPC output .
func RPCMarshalHeader(head *types.Header) map[string]interface{} {
result := map[string]interface{}{
Expand Down