diff --git a/go.mod b/go.mod index 78fb8758d724..a46e68049850 100644 --- a/go.mod +++ b/go.mod @@ -56,11 +56,11 @@ require ( go.uber.org/goleak v1.3.0 go.uber.org/mock v0.4.0 go.uber.org/zap v1.26.0 - golang.org/x/crypto v0.26.0 + golang.org/x/crypto v0.31.0 golang.org/x/exp v0.0.0-20231127185646-65229373498e golang.org/x/net v0.28.0 - golang.org/x/sync v0.8.0 - golang.org/x/term v0.23.0 + golang.org/x/sync v0.10.0 + golang.org/x/term v0.27.0 golang.org/x/time v0.3.0 gonum.org/v1/gonum v0.11.0 google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed @@ -176,8 +176,8 @@ require ( go.opentelemetry.io/proto/otlp v1.0.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/oauth2 v0.21.0 // indirect - golang.org/x/sys v0.24.0 // indirect - golang.org/x/text v0.17.0 // indirect + golang.org/x/sys v0.28.0 // indirect + golang.org/x/text v0.21.0 // indirect golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240604185151-ef581f913117 // indirect gopkg.in/inf.v0 v0.9.1 // indirect diff --git a/go.sum b/go.sum index d43867a56bde..fb6007017f8d 100644 --- a/go.sum +++ b/go.sum @@ -695,8 +695,8 @@ golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= -golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= +golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= +golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -804,8 +804,8 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= -golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= +golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -873,12 +873,12 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= -golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= -golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= +golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= +golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -889,8 +889,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= -golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/snow/snowtest/context.go b/snow/snowtest/context.go index 2b857184235c..36af84e5c79c 100644 --- a/snow/snowtest/context.go +++ b/snow/snowtest/context.go @@ -98,6 +98,6 @@ func Context(tb testing.TB, chainID ids.ID) *snow.Context { Metrics: metrics.NewPrefixGatherer(), ValidatorState: validatorState, - ChainDataDir: "", + ChainDataDir: tb.TempDir(), } } diff --git a/vms/components/gas/state.go b/vms/components/gas/state.go index e3c1c3eb3603..03c4b74cd814 100644 --- a/vms/components/gas/state.go +++ b/vms/components/gas/state.go @@ -5,6 +5,7 @@ package gas import ( "errors" + "fmt" "math" safemath "github.com/ava-labs/avalanchego/utils/math" @@ -44,7 +45,7 @@ func (s State) AdvanceTime( func (s State) ConsumeGas(gas Gas) (State, error) { newCapacity, err := safemath.Sub(uint64(s.Capacity), uint64(gas)) if err != nil { - return State{}, ErrInsufficientCapacity + return State{}, fmt.Errorf("%w: capacity (%d) < gas (%d)", ErrInsufficientCapacity, s.Capacity, gas) } newExcess, err := safemath.Add(uint64(s.Excess), uint64(gas)) diff --git a/vms/platformvm/block/builder/builder.go b/vms/platformvm/block/builder/builder.go index 410d3285a9e7..bf017d217929 100644 --- a/vms/platformvm/block/builder/builder.go +++ b/vms/platformvm/block/builder/builder.go @@ -355,6 +355,9 @@ func buildBlock( ) } if err != nil { + builder.txExecutorBackend.Ctx.Log.Warn("failed to pack block transactions", + zap.Error(err), + ) return nil, fmt.Errorf("failed to pack block txs: %w", err) } @@ -485,9 +488,26 @@ func packEtnaBlockTxs( blockComplexity gas.Dimensions feeCalculator = state.PickFeeCalculator(backend.Config, stateDiff) ) + + backend.Ctx.Log.Debug("starting to pack block txs", + zap.Stringer("parentID", parentID), + zap.Time("blockTimestamp", timestamp), + zap.Uint64("capacity", uint64(capacity)), + zap.Int("mempoolLen", mempool.Len()), + ) for { + currentBlockGas, err := blockComplexity.ToGas(backend.Config.DynamicFeeConfig.Weights) + if err != nil { + return nil, err + } + tx, exists := mempool.Peek() if !exists { + backend.Ctx.Log.Debug("mempool is empty", + zap.Uint64("capacity", uint64(capacity)), + zap.Uint64("blockGas", uint64(currentBlockGas)), + zap.Int("blockLen", len(blockTxs)), + ) break } @@ -504,6 +524,12 @@ func packEtnaBlockTxs( return nil, err } if newBlockGas > capacity { + backend.Ctx.Log.Debug("block is full", + zap.Uint64("nextBlockGas", uint64(newBlockGas)), + zap.Uint64("capacity", uint64(capacity)), + zap.Uint64("blockGas", uint64(currentBlockGas)), + zap.Int("blockLen", len(blockTxs)), + ) break } @@ -549,6 +575,7 @@ func executeTx( // Invariant: [tx] has already been syntactically verified. + txID := tx.ID() err := txexecutor.VerifyWarpMessages( ctx, backend.Ctx.NetworkID, @@ -557,7 +584,11 @@ func executeTx( tx.Unsigned, ) if err != nil { - txID := tx.ID() + backend.Ctx.Log.Debug("transaction failed warp verification", + zap.Stringer("txID", txID), + zap.Error(err), + ) + mempool.MarkDropped(txID, err) return false, nil } @@ -574,23 +605,41 @@ func executeTx( txDiff, ) if err != nil { - txID := tx.ID() + backend.Ctx.Log.Debug("transaction failed execution", + zap.Stringer("txID", txID), + zap.Error(err), + ) + mempool.MarkDropped(txID, err) return false, nil } if inputs.Overlaps(txInputs) { - txID := tx.ID() + // This log is a warn because the mempool should not have allowed this + // transaction to be included. + backend.Ctx.Log.Warn("transaction conflicts with prior transaction", + zap.Stringer("txID", txID), + zap.Error(err), + ) + mempool.MarkDropped(txID, blockexecutor.ErrConflictingBlockTxs) return false, nil } if err := manager.VerifyUniqueInputs(parentID, txInputs); err != nil { - txID := tx.ID() + backend.Ctx.Log.Debug("transaction conflicts with ancestor's import transaction", + zap.Stringer("txID", txID), + zap.Error(err), + ) + mempool.MarkDropped(txID, err) return false, nil } inputs.Union(txInputs) + backend.Ctx.Log.Debug("successfully executed transaction", + zap.Stringer("txID", txID), + zap.Error(err), + ) txDiff.AddTx(tx, status.Committed) return true, txDiff.Apply(stateDiff) } diff --git a/vms/platformvm/block/executor/verifier.go b/vms/platformvm/block/executor/verifier.go index 365cc5a98838..f76b5c078117 100644 --- a/vms/platformvm/block/executor/verifier.go +++ b/vms/platformvm/block/executor/verifier.go @@ -525,14 +525,14 @@ func (v *verifier) processStandardTxs(txs []*txs.Tx, feeCalculator txfee.Calcula blockComplexity, err = blockComplexity.Add(&txComplexity) if err != nil { - return nil, nil, nil, 0, err + return nil, nil, nil, 0, fmt.Errorf("block complexity overflow: %w", err) } } var err error gasConsumed, err = blockComplexity.ToGas(v.txExecutorBackend.Config.DynamicFeeConfig.Weights) if err != nil { - return nil, nil, nil, 0, err + return nil, nil, nil, 0, fmt.Errorf("block gas overflow: %w", err) } // If this block exceeds the available capacity, ConsumeGas will return diff --git a/vms/platformvm/network/gossip.go b/vms/platformvm/network/gossip.go index 43e730b90e31..70992c04eecf 100644 --- a/vms/platformvm/network/gossip.go +++ b/vms/platformvm/network/gossip.go @@ -10,6 +10,7 @@ import ( "time" "github.com/prometheus/client_golang/prometheus" + "go.uber.org/zap" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/network/p2p" @@ -108,6 +109,11 @@ func (g *gossipMempool) Add(tx *txs.Tx) error { } if err := g.txVerifier.VerifyTx(tx); err != nil { + g.log.Debug("transaction failed verification", + zap.Stringer("txID", txID), + zap.Error(err), + ) + g.Mempool.MarkDropped(txID, err) return fmt.Errorf("failed verification: %w", err) } diff --git a/x/merkledb/db.go b/x/merkledb/db.go index 3096cbabd262..2fd1d1735068 100644 --- a/x/merkledb/db.go +++ b/x/merkledb/db.go @@ -151,7 +151,7 @@ type Prefetcher interface { type MerkleDB interface { database.Database Clearer - Trie + View MerkleRootGetter ProofGetter ChangeProofer