mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-16 17:03:46 +00:00
Merge branch 'ethereum:master' into gethintegration
This commit is contained in:
commit
b8283a0ae6
11 changed files with 76 additions and 61 deletions
|
|
@ -17,6 +17,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"cmp"
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
@ -292,13 +293,7 @@ func sortChanges(changes []types.Change) {
|
||||||
if a.Action == b.Action {
|
if a.Action == b.Action {
|
||||||
return strings.Compare(*a.ResourceRecordSet.Name, *b.ResourceRecordSet.Name)
|
return strings.Compare(*a.ResourceRecordSet.Name, *b.ResourceRecordSet.Name)
|
||||||
}
|
}
|
||||||
if score[string(a.Action)] < score[string(b.Action)] {
|
return cmp.Compare(score[string(a.Action)], score[string(b.Action)])
|
||||||
return -1
|
|
||||||
}
|
|
||||||
if score[string(a.Action)] > score[string(b.Action)] {
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"cmp"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
@ -104,13 +105,7 @@ func (ns nodeSet) topN(n int) nodeSet {
|
||||||
byscore = append(byscore, v)
|
byscore = append(byscore, v)
|
||||||
}
|
}
|
||||||
slices.SortFunc(byscore, func(a, b nodeJSON) int {
|
slices.SortFunc(byscore, func(a, b nodeJSON) int {
|
||||||
if a.Score > b.Score {
|
return cmp.Compare(b.Score, a.Score)
|
||||||
return -1
|
|
||||||
}
|
|
||||||
if a.Score < b.Score {
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
})
|
})
|
||||||
result := make(nodeSet, n)
|
result := make(nodeSet, n)
|
||||||
for _, v := range byscore[:n] {
|
for _, v := range byscore[:n] {
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ package snapshot
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"cmp"
|
||||||
"fmt"
|
"fmt"
|
||||||
"slices"
|
"slices"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
@ -45,13 +46,7 @@ func (it *weightedIterator) Cmp(other *weightedIterator) int {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
// Same account/storage-slot in multiple layers, split by priority
|
// Same account/storage-slot in multiple layers, split by priority
|
||||||
if it.priority < other.priority {
|
return cmp.Compare(it.priority, other.priority)
|
||||||
return -1
|
|
||||||
}
|
|
||||||
if it.priority > other.priority {
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// fastIterator is a more optimized multi-layer iterator which maintains a
|
// fastIterator is a more optimized multi-layer iterator which maintains a
|
||||||
|
|
|
||||||
|
|
@ -105,8 +105,8 @@ func (e *gfP12) Mul(a, b *gfP12) *gfP12 {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *gfP12) MulScalar(a *gfP12, b *gfP6) *gfP12 {
|
func (e *gfP12) MulScalar(a *gfP12, b *gfP6) *gfP12 {
|
||||||
e.x.Mul(&e.x, b)
|
e.x.Mul(&a.x, b)
|
||||||
e.y.Mul(&e.y, b)
|
e.y.Mul(&a.y, b)
|
||||||
return e
|
return e
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -125,8 +125,8 @@ func (e *gfP12) Mul(a, b *gfP12, pool *bnPool) *gfP12 {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *gfP12) MulScalar(a *gfP12, b *gfP6, pool *bnPool) *gfP12 {
|
func (e *gfP12) MulScalar(a *gfP12, b *gfP6, pool *bnPool) *gfP12 {
|
||||||
e.x.Mul(e.x, b, pool)
|
e.x.Mul(a.x, b, pool)
|
||||||
e.y.Mul(e.y, b, pool)
|
e.y.Mul(a.y, b, pool)
|
||||||
return e
|
return e
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -217,6 +217,7 @@ type StructLogger struct {
|
||||||
|
|
||||||
interrupt atomic.Bool // Atomic flag to signal execution interruption
|
interrupt atomic.Bool // Atomic flag to signal execution interruption
|
||||||
reason error // Textual reason for the interruption
|
reason error // Textual reason for the interruption
|
||||||
|
skip bool // skip processing hooks.
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewStreamingStructLogger returns a new streaming logger.
|
// NewStreamingStructLogger returns a new streaming logger.
|
||||||
|
|
@ -240,10 +241,12 @@ func NewStructLogger(cfg *Config) *StructLogger {
|
||||||
|
|
||||||
func (l *StructLogger) Hooks() *tracing.Hooks {
|
func (l *StructLogger) Hooks() *tracing.Hooks {
|
||||||
return &tracing.Hooks{
|
return &tracing.Hooks{
|
||||||
OnTxStart: l.OnTxStart,
|
OnTxStart: l.OnTxStart,
|
||||||
OnTxEnd: l.OnTxEnd,
|
OnTxEnd: l.OnTxEnd,
|
||||||
OnExit: l.OnExit,
|
OnSystemCallStartV2: l.OnSystemCallStart,
|
||||||
OnOpcode: l.OnOpcode,
|
OnSystemCallEnd: l.OnSystemCallEnd,
|
||||||
|
OnExit: l.OnExit,
|
||||||
|
OnOpcode: l.OnOpcode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -255,6 +258,10 @@ func (l *StructLogger) OnOpcode(pc uint64, opcode byte, gas, cost uint64, scope
|
||||||
if l.interrupt.Load() {
|
if l.interrupt.Load() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// Processing a system call.
|
||||||
|
if l.skip {
|
||||||
|
return
|
||||||
|
}
|
||||||
// check if already accumulated the size of the response.
|
// check if already accumulated the size of the response.
|
||||||
if l.cfg.Limit != 0 && l.resultSize > l.cfg.Limit {
|
if l.cfg.Limit != 0 && l.resultSize > l.cfg.Limit {
|
||||||
return
|
return
|
||||||
|
|
@ -320,6 +327,9 @@ func (l *StructLogger) OnExit(depth int, output []byte, gasUsed uint64, err erro
|
||||||
if depth != 0 {
|
if depth != 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if l.skip {
|
||||||
|
return
|
||||||
|
}
|
||||||
l.output = output
|
l.output = output
|
||||||
l.err = err
|
l.err = err
|
||||||
// TODO @holiman, should we output the per-scope output?
|
// TODO @holiman, should we output the per-scope output?
|
||||||
|
|
@ -360,6 +370,13 @@ func (l *StructLogger) Stop(err error) {
|
||||||
func (l *StructLogger) OnTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address) {
|
func (l *StructLogger) OnTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address) {
|
||||||
l.env = env
|
l.env = env
|
||||||
}
|
}
|
||||||
|
func (l *StructLogger) OnSystemCallStart(env *tracing.VMContext) {
|
||||||
|
l.skip = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *StructLogger) OnSystemCallEnd() {
|
||||||
|
l.skip = false
|
||||||
|
}
|
||||||
|
|
||||||
func (l *StructLogger) OnTxEnd(receipt *types.Receipt, err error) {
|
func (l *StructLogger) OnTxEnd(receipt *types.Receipt, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -389,9 +406,10 @@ func WriteTrace(writer io.Writer, logs []StructLog) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type mdLogger struct {
|
type mdLogger struct {
|
||||||
out io.Writer
|
out io.Writer
|
||||||
cfg *Config
|
cfg *Config
|
||||||
env *tracing.VMContext
|
env *tracing.VMContext
|
||||||
|
skip bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewMarkdownLogger creates a logger which outputs information in a format adapted
|
// NewMarkdownLogger creates a logger which outputs information in a format adapted
|
||||||
|
|
@ -406,11 +424,13 @@ func NewMarkdownLogger(cfg *Config, writer io.Writer) *mdLogger {
|
||||||
|
|
||||||
func (t *mdLogger) Hooks() *tracing.Hooks {
|
func (t *mdLogger) Hooks() *tracing.Hooks {
|
||||||
return &tracing.Hooks{
|
return &tracing.Hooks{
|
||||||
OnTxStart: t.OnTxStart,
|
OnTxStart: t.OnTxStart,
|
||||||
OnEnter: t.OnEnter,
|
OnSystemCallStartV2: t.OnSystemCallStart,
|
||||||
OnExit: t.OnExit,
|
OnSystemCallEnd: t.OnSystemCallEnd,
|
||||||
OnOpcode: t.OnOpcode,
|
OnEnter: t.OnEnter,
|
||||||
OnFault: t.OnFault,
|
OnExit: t.OnExit,
|
||||||
|
OnOpcode: t.OnOpcode,
|
||||||
|
OnFault: t.OnFault,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -418,7 +438,18 @@ func (t *mdLogger) OnTxStart(env *tracing.VMContext, tx *types.Transaction, from
|
||||||
t.env = env
|
t.env = env
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *mdLogger) OnSystemCallStart(env *tracing.VMContext) {
|
||||||
|
t.skip = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *mdLogger) OnSystemCallEnd() {
|
||||||
|
t.skip = false
|
||||||
|
}
|
||||||
|
|
||||||
func (t *mdLogger) OnEnter(depth int, typ byte, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
|
func (t *mdLogger) OnEnter(depth int, typ byte, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
|
||||||
|
if t.skip {
|
||||||
|
return
|
||||||
|
}
|
||||||
if depth != 0 {
|
if depth != 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -446,6 +477,9 @@ func (t *mdLogger) OnEnter(depth int, typ byte, from common.Address, to common.A
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *mdLogger) OnExit(depth int, output []byte, gasUsed uint64, err error, reverted bool) {
|
func (t *mdLogger) OnExit(depth int, output []byte, gasUsed uint64, err error, reverted bool) {
|
||||||
|
if t.skip {
|
||||||
|
return
|
||||||
|
}
|
||||||
if depth == 0 {
|
if depth == 0 {
|
||||||
fmt.Fprintf(t.out, "\nPost-execution info:\n"+
|
fmt.Fprintf(t.out, "\nPost-execution info:\n"+
|
||||||
" - output: `%#x`\n"+
|
" - output: `%#x`\n"+
|
||||||
|
|
@ -457,6 +491,9 @@ func (t *mdLogger) OnExit(depth int, output []byte, gasUsed uint64, err error, r
|
||||||
|
|
||||||
// OnOpcode also tracks SLOAD/SSTORE ops to track storage change.
|
// OnOpcode also tracks SLOAD/SSTORE ops to track storage change.
|
||||||
func (t *mdLogger) OnOpcode(pc uint64, op byte, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error) {
|
func (t *mdLogger) OnOpcode(pc uint64, op byte, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error) {
|
||||||
|
if t.skip {
|
||||||
|
return
|
||||||
|
}
|
||||||
stack := scope.StackData()
|
stack := scope.StackData()
|
||||||
fmt.Fprintf(t.out, "| %4d | %10v | %3d |%10v |", pc, vm.OpCode(op).String(),
|
fmt.Fprintf(t.out, "| %4d | %10v | %3d |%10v |", pc, vm.OpCode(op).String(),
|
||||||
cost, t.env.StateDB.GetRefund())
|
cost, t.env.StateDB.GetRefund())
|
||||||
|
|
@ -477,6 +514,9 @@ func (t *mdLogger) OnOpcode(pc uint64, op byte, gas, cost uint64, scope tracing.
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *mdLogger) OnFault(pc uint64, op byte, gas, cost uint64, scope tracing.OpContext, depth int, err error) {
|
func (t *mdLogger) OnFault(pc uint64, op byte, gas, cost uint64, scope tracing.OpContext, depth int, err error) {
|
||||||
|
if t.skip {
|
||||||
|
return
|
||||||
|
}
|
||||||
fmt.Fprintf(t.out, "\nError: at pc=%d, op=%v: %v\n", pc, op, err)
|
fmt.Fprintf(t.out, "\nError: at pc=%d, op=%v: %v\n", pc, op, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ const (
|
||||||
maxSimulateBlocks = 256
|
maxSimulateBlocks = 256
|
||||||
|
|
||||||
// timestampIncrement is the default increment between block timestamps.
|
// timestampIncrement is the default increment between block timestamps.
|
||||||
timestampIncrement = 1
|
timestampIncrement = 12
|
||||||
)
|
)
|
||||||
|
|
||||||
// simBlock is a batch of calls to be simulated sequentially.
|
// simBlock is a batch of calls to be simulated sequentially.
|
||||||
|
|
|
||||||
|
|
@ -41,19 +41,19 @@ func TestSimulateSanitizeBlockOrder(t *testing.T) {
|
||||||
baseNumber: 10,
|
baseNumber: 10,
|
||||||
baseTimestamp: 50,
|
baseTimestamp: 50,
|
||||||
blocks: []simBlock{{}, {}, {}},
|
blocks: []simBlock{{}, {}, {}},
|
||||||
expected: []result{{number: 11, timestamp: 51}, {number: 12, timestamp: 52}, {number: 13, timestamp: 53}},
|
expected: []result{{number: 11, timestamp: 62}, {number: 12, timestamp: 74}, {number: 13, timestamp: 86}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
baseNumber: 10,
|
baseNumber: 10,
|
||||||
baseTimestamp: 50,
|
baseTimestamp: 50,
|
||||||
blocks: []simBlock{{BlockOverrides: &override.BlockOverrides{Number: newInt(13), Time: newUint64(70)}}, {}},
|
blocks: []simBlock{{BlockOverrides: &override.BlockOverrides{Number: newInt(13), Time: newUint64(80)}}, {}},
|
||||||
expected: []result{{number: 11, timestamp: 51}, {number: 12, timestamp: 52}, {number: 13, timestamp: 70}, {number: 14, timestamp: 71}},
|
expected: []result{{number: 11, timestamp: 62}, {number: 12, timestamp: 74}, {number: 13, timestamp: 80}, {number: 14, timestamp: 92}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
baseNumber: 10,
|
baseNumber: 10,
|
||||||
baseTimestamp: 50,
|
baseTimestamp: 50,
|
||||||
blocks: []simBlock{{BlockOverrides: &override.BlockOverrides{Number: newInt(11)}}, {BlockOverrides: &override.BlockOverrides{Number: newInt(14)}}, {}},
|
blocks: []simBlock{{BlockOverrides: &override.BlockOverrides{Number: newInt(11)}}, {BlockOverrides: &override.BlockOverrides{Number: newInt(14)}}, {}},
|
||||||
expected: []result{{number: 11, timestamp: 51}, {number: 12, timestamp: 52}, {number: 13, timestamp: 53}, {number: 14, timestamp: 54}, {number: 15, timestamp: 55}},
|
expected: []result{{number: 11, timestamp: 62}, {number: 12, timestamp: 74}, {number: 13, timestamp: 86}, {number: 14, timestamp: 98}, {number: 15, timestamp: 110}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
baseNumber: 10,
|
baseNumber: 10,
|
||||||
|
|
@ -64,8 +64,8 @@ func TestSimulateSanitizeBlockOrder(t *testing.T) {
|
||||||
{
|
{
|
||||||
baseNumber: 10,
|
baseNumber: 10,
|
||||||
baseTimestamp: 50,
|
baseTimestamp: 50,
|
||||||
blocks: []simBlock{{BlockOverrides: &override.BlockOverrides{Number: newInt(13), Time: newUint64(52)}}},
|
blocks: []simBlock{{BlockOverrides: &override.BlockOverrides{Number: newInt(13), Time: newUint64(74)}}},
|
||||||
err: "block timestamps must be in order: 52 <= 52",
|
err: "block timestamps must be in order: 74 <= 74",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
baseNumber: 10,
|
baseNumber: 10,
|
||||||
|
|
@ -76,8 +76,8 @@ func TestSimulateSanitizeBlockOrder(t *testing.T) {
|
||||||
{
|
{
|
||||||
baseNumber: 10,
|
baseNumber: 10,
|
||||||
baseTimestamp: 50,
|
baseTimestamp: 50,
|
||||||
blocks: []simBlock{{BlockOverrides: &override.BlockOverrides{Number: newInt(11), Time: newUint64(60)}}, {BlockOverrides: &override.BlockOverrides{Number: newInt(13), Time: newUint64(61)}}},
|
blocks: []simBlock{{BlockOverrides: &override.BlockOverrides{Number: newInt(11), Time: newUint64(60)}}, {BlockOverrides: &override.BlockOverrides{Number: newInt(13), Time: newUint64(72)}}},
|
||||||
err: "block timestamps must be in order: 61 <= 61",
|
err: "block timestamps must be in order: 72 <= 72",
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
sim := &simulator{base: &types.Header{Number: big.NewInt(int64(tc.baseNumber)), Time: tc.baseTimestamp}}
|
sim := &simulator{base: &types.Header{Number: big.NewInt(int64(tc.baseNumber)), Time: tc.baseTimestamp}}
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ func NewApp(usage string) *cli.App {
|
||||||
app.EnableBashCompletion = true
|
app.EnableBashCompletion = true
|
||||||
app.Version = version.WithCommit(git.Commit, git.Date)
|
app.Version = version.WithCommit(git.Commit, git.Date)
|
||||||
app.Usage = usage
|
app.Usage = usage
|
||||||
app.Copyright = "Copyright 2013-2024 The go-ethereum Authors"
|
app.Copyright = "Copyright 2013-2025 The go-ethereum Authors"
|
||||||
app.Before = func(ctx *cli.Context) error {
|
app.Before = func(ctx *cli.Context) error {
|
||||||
MigrateGlobalFlags(ctx)
|
MigrateGlobalFlags(ctx)
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
package p2p
|
package p2p
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"cmp"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
|
@ -81,13 +82,7 @@ func (cap Cap) String() string {
|
||||||
// Cmp defines the canonical sorting order of capabilities.
|
// Cmp defines the canonical sorting order of capabilities.
|
||||||
func (cap Cap) Cmp(other Cap) int {
|
func (cap Cap) Cmp(other Cap) int {
|
||||||
if cap.Name == other.Name {
|
if cap.Name == other.Name {
|
||||||
if cap.Version < other.Version {
|
return cmp.Compare(cap.Version, other.Version)
|
||||||
return -1
|
|
||||||
}
|
|
||||||
if cap.Version > other.Version {
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
return strings.Compare(cap.Name, other.Name)
|
return strings.Compare(cap.Name, other.Name)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ package pathdb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"cmp"
|
||||||
"fmt"
|
"fmt"
|
||||||
"slices"
|
"slices"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
@ -45,13 +46,7 @@ func (it *weightedIterator) Cmp(other *weightedIterator) int {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
// Same account/storage-slot in multiple layers, split by priority
|
// Same account/storage-slot in multiple layers, split by priority
|
||||||
if it.priority < other.priority {
|
return cmp.Compare(it.priority, other.priority)
|
||||||
return -1
|
|
||||||
}
|
|
||||||
if it.priority > other.priority {
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// fastIterator is a more optimized multi-layer iterator which maintains a
|
// fastIterator is a more optimized multi-layer iterator which maintains a
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue