Merge branch 'master' into release/1.13
This commit is contained in:
commit
2bd6bd01d2
@ -916,7 +916,7 @@ There are a couple of implementation for a UI. We'll try to keep this list up to
|
|||||||
|
|
||||||
| Name | Repo | UI type| No external resources| Blocky support| Verifies permissions | Hash information | No secondary storage | Statically linked| Can modify parameters|
|
| Name | Repo | UI type| No external resources| Blocky support| Verifies permissions | Hash information | No secondary storage | Statically linked| Can modify parameters|
|
||||||
| ---- | ---- | -------| ---- | ---- | ---- |---- | ---- | ---- | ---- |
|
| ---- | ---- | -------| ---- | ---- | ---- |---- | ---- | ---- | ---- |
|
||||||
| QtSigner| https://github.com/holiman/qtsigner/| Python3/QT-based| :+1:| :+1:| :+1:| :+1:| :+1:| :x: | :+1: (partially)|
|
| QtSigner| https://github.com/holiman/qtsigner/ | Python3/QT-based| :+1:| :+1:| :+1:| :+1:| :+1:| :x: | :+1: (partially)|
|
||||||
| GtkSigner| https://github.com/holiman/gtksigner| Python3/GTK-based| :+1:| :x:| :x:| :+1:| :+1:| :x: | :x: |
|
| GtkSigner| https://github.com/holiman/gtksigner | Python3/GTK-based| :+1:| :x:| :x:| :+1:| :+1:| :x: | :x: |
|
||||||
| Frame | https://github.com/floating/frame/commits/go-signer| Electron-based| :x:| :x:| :x:| :x:| ?| :x: | :x: |
|
| Frame | https://github.com/floating/frame/commits/go-signer | Electron-based| :x:| :x:| :x:| :x:| ?| :x: | :x: |
|
||||||
| Clef UI| https://github.com/ethereum/clef-ui| Golang/QT-based| :+1:| :+1:| :x:| :+1:| :+1:| :x: | :+1: (approve tx only)|
|
| Clef UI| https://github.com/ethereum/clef-ui | Golang/QT-based| :+1:| :+1:| :x:| :+1:| :+1:| :x: | :+1: (approve tx only)|
|
||||||
|
@ -402,7 +402,7 @@ func (p *BlobPool) Init(gasTip uint64, head *types.Header, reserve txpool.Addres
|
|||||||
}
|
}
|
||||||
var (
|
var (
|
||||||
basefee = uint256.MustFromBig(eip1559.CalcBaseFee(p.chain.Config(), p.head))
|
basefee = uint256.MustFromBig(eip1559.CalcBaseFee(p.chain.Config(), p.head))
|
||||||
blobfee = uint256.MustFromBig(big.NewInt(params.BlobTxMinBlobGasprice))
|
blobfee = uint256.NewInt(params.BlobTxMinBlobGasprice)
|
||||||
)
|
)
|
||||||
if p.head.ExcessBlobGas != nil {
|
if p.head.ExcessBlobGas != nil {
|
||||||
blobfee = uint256.MustFromBig(eip4844.CalcBlobFee(*p.head.ExcessBlobGas))
|
blobfee = uint256.MustFromBig(eip4844.CalcBlobFee(*p.head.ExcessBlobGas))
|
||||||
|
@ -1228,6 +1228,24 @@ func TestAdd(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
// Blob transactions that don't meet the min blob gas price should be rejected
|
||||||
|
{
|
||||||
|
seeds: map[string]seed{
|
||||||
|
"alice": {balance: 10000000},
|
||||||
|
},
|
||||||
|
adds: []addtx{
|
||||||
|
{ // New account, no previous txs, nonce 0, but blob fee cap too low
|
||||||
|
from: "alice",
|
||||||
|
tx: makeUnsignedTx(0, 1, 1, 0),
|
||||||
|
err: txpool.ErrUnderpriced,
|
||||||
|
},
|
||||||
|
{ // Same as above but blob fee cap equals minimum, should be accepted
|
||||||
|
from: "alice",
|
||||||
|
tx: makeUnsignedTx(0, 1, 1, params.BlobTxMinBlobGasprice),
|
||||||
|
err: nil,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for i, tt := range tests {
|
for i, tt := range tests {
|
||||||
// Create a temporary folder for the persistent backend
|
// Create a temporary folder for the persistent backend
|
||||||
|
@ -30,8 +30,8 @@ type Config struct {
|
|||||||
// DefaultConfig contains the default configurations for the transaction pool.
|
// DefaultConfig contains the default configurations for the transaction pool.
|
||||||
var DefaultConfig = Config{
|
var DefaultConfig = Config{
|
||||||
Datadir: "blobpool",
|
Datadir: "blobpool",
|
||||||
Datacap: 10 * 1024 * 1024 * 1024,
|
Datacap: 10 * 1024 * 1024 * 1024 / 4, // TODO(karalabe): /4 handicap for rollout, gradually bump back up to 10GB
|
||||||
PriceBump: 100, // either have patience or be aggressive, no mushy ground
|
PriceBump: 100, // either have patience or be aggressive, no mushy ground
|
||||||
}
|
}
|
||||||
|
|
||||||
// sanitize checks the provided user configurations and changes anything that's
|
// sanitize checks the provided user configurations and changes anything that's
|
||||||
|
@ -54,4 +54,10 @@ var (
|
|||||||
// ErrFutureReplacePending is returned if a future transaction replaces a pending
|
// ErrFutureReplacePending is returned if a future transaction replaces a pending
|
||||||
// one. Future transactions should only be able to replace other future transactions.
|
// one. Future transactions should only be able to replace other future transactions.
|
||||||
ErrFutureReplacePending = errors.New("future transaction tries to replace pending")
|
ErrFutureReplacePending = errors.New("future transaction tries to replace pending")
|
||||||
|
|
||||||
|
// ErrAlreadyReserved is returned if the sender address has a pending transaction
|
||||||
|
// in a different subpool. For example, this error is returned in response to any
|
||||||
|
// input transaction of non-blob type when a blob transaction from this sender
|
||||||
|
// remains pending (and vice-versa).
|
||||||
|
ErrAlreadyReserved = errors.New("address already reserved")
|
||||||
)
|
)
|
||||||
|
@ -164,7 +164,12 @@ func (journal *journal) rotate(all map[common.Address]types.Transactions) error
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
journal.writer = sink
|
journal.writer = sink
|
||||||
log.Info("Regenerated local transaction journal", "transactions", journaled, "accounts", len(all))
|
|
||||||
|
logger := log.Info
|
||||||
|
if len(all) == 0 {
|
||||||
|
logger = log.Debug
|
||||||
|
}
|
||||||
|
logger("Regenerated local transaction journal", "transactions", journaled, "accounts", len(all))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ func (p *TxPool) reserver(id int, subpool SubPool) AddressReserver {
|
|||||||
log.Error("pool attempted to reserve already-owned address", "address", addr)
|
log.Error("pool attempted to reserve already-owned address", "address", addr)
|
||||||
return nil // Ignore fault to give the pool a chance to recover while the bug gets fixed
|
return nil // Ignore fault to give the pool a chance to recover while the bug gets fixed
|
||||||
}
|
}
|
||||||
return errors.New("address already reserved")
|
return ErrAlreadyReserved
|
||||||
}
|
}
|
||||||
p.reservations[addr] = subpool
|
p.reservations[addr] = subpool
|
||||||
if metrics.Enabled {
|
if metrics.Enabled {
|
||||||
|
@ -30,6 +30,12 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// blobTxMinBlobGasPrice is the big.Int version of the configured protocol
|
||||||
|
// parameter to avoid constucting a new big integer for every transaction.
|
||||||
|
blobTxMinBlobGasPrice = big.NewInt(params.BlobTxMinBlobGasprice)
|
||||||
|
)
|
||||||
|
|
||||||
// ValidationOptions define certain differences between transaction validation
|
// ValidationOptions define certain differences between transaction validation
|
||||||
// across the different pools without having to duplicate those checks.
|
// across the different pools without having to duplicate those checks.
|
||||||
type ValidationOptions struct {
|
type ValidationOptions struct {
|
||||||
@ -101,15 +107,17 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if tx.Gas() < intrGas {
|
if tx.Gas() < intrGas {
|
||||||
return fmt.Errorf("%w: needed %v, allowed %v", core.ErrIntrinsicGas, intrGas, tx.Gas())
|
return fmt.Errorf("%w: gas %v, minimum needed %v", core.ErrIntrinsicGas, tx.Gas(), intrGas)
|
||||||
}
|
}
|
||||||
// Ensure the gasprice is high enough to cover the requirement of the calling
|
// Ensure the gasprice is high enough to cover the requirement of the calling pool
|
||||||
// pool and/or block producer
|
|
||||||
if tx.GasTipCapIntCmp(opts.MinTip) < 0 {
|
if tx.GasTipCapIntCmp(opts.MinTip) < 0 {
|
||||||
return fmt.Errorf("%w: tip needed %v, tip permitted %v", ErrUnderpriced, opts.MinTip, tx.GasTipCap())
|
return fmt.Errorf("%w: gas tip cap %v, minimum needed %v", ErrUnderpriced, tx.GasTipCap(), opts.MinTip)
|
||||||
}
|
}
|
||||||
// Ensure blob transactions have valid commitments
|
|
||||||
if tx.Type() == types.BlobTxType {
|
if tx.Type() == types.BlobTxType {
|
||||||
|
// Ensure the blob fee cap satisfies the minimum blob gas price
|
||||||
|
if tx.BlobGasFeeCapIntCmp(blobTxMinBlobGasPrice) < 0 {
|
||||||
|
return fmt.Errorf("%w: blob fee cap %v, minimum needed %v", ErrUnderpriced, tx.BlobGasFeeCap(), blobTxMinBlobGasPrice)
|
||||||
|
}
|
||||||
sidecar := tx.BlobTxSidecar()
|
sidecar := tx.BlobTxSidecar()
|
||||||
if sidecar == nil {
|
if sidecar == nil {
|
||||||
return fmt.Errorf("missing sidecar in blob transaction")
|
return fmt.Errorf("missing sidecar in blob transaction")
|
||||||
@ -123,6 +131,7 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types
|
|||||||
if len(hashes) > params.MaxBlobGasPerBlock/params.BlobTxBlobGasPerBlob {
|
if len(hashes) > params.MaxBlobGasPerBlock/params.BlobTxBlobGasPerBlob {
|
||||||
return fmt.Errorf("too many blobs in transaction: have %d, permitted %d", len(hashes), params.MaxBlobGasPerBlock/params.BlobTxBlobGasPerBlob)
|
return fmt.Errorf("too many blobs in transaction: have %d, permitted %d", len(hashes), params.MaxBlobGasPerBlock/params.BlobTxBlobGasPerBlob)
|
||||||
}
|
}
|
||||||
|
// Ensure commitments, proofs and hashes are valid
|
||||||
if err := validateBlobSidecar(hashes, sidecar); err != nil {
|
if err := validateBlobSidecar(hashes, sidecar); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -488,7 +488,7 @@ func (api *ConsensusAPI) NewPayloadV1(params engine.ExecutableData) (engine.Payl
|
|||||||
// NewPayloadV2 creates an Eth1 block, inserts it in the chain, and returns the status of the chain.
|
// NewPayloadV2 creates an Eth1 block, inserts it in the chain, and returns the status of the chain.
|
||||||
func (api *ConsensusAPI) NewPayloadV2(params engine.ExecutableData) (engine.PayloadStatusV1, error) {
|
func (api *ConsensusAPI) NewPayloadV2(params engine.ExecutableData) (engine.PayloadStatusV1, error) {
|
||||||
if api.eth.BlockChain().Config().IsCancun(api.eth.BlockChain().Config().LondonBlock, params.Timestamp) {
|
if api.eth.BlockChain().Config().IsCancun(api.eth.BlockChain().Config().LondonBlock, params.Timestamp) {
|
||||||
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("can't use new payload v2 post-shanghai"))
|
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("can't use newPayloadV2 post-cancun"))
|
||||||
}
|
}
|
||||||
if api.eth.BlockChain().Config().LatestFork(params.Timestamp) == forks.Shanghai {
|
if api.eth.BlockChain().Config().LatestFork(params.Timestamp) == forks.Shanghai {
|
||||||
if params.Withdrawals == nil {
|
if params.Withdrawals == nil {
|
||||||
@ -503,7 +503,7 @@ func (api *ConsensusAPI) NewPayloadV2(params engine.ExecutableData) (engine.Payl
|
|||||||
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("non-nil excessBlobGas pre-cancun"))
|
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("non-nil excessBlobGas pre-cancun"))
|
||||||
}
|
}
|
||||||
if params.BlobGasUsed != nil {
|
if params.BlobGasUsed != nil {
|
||||||
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("non-nil params.BlobGasUsed pre-cancun"))
|
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("non-nil blobGasUsed pre-cancun"))
|
||||||
}
|
}
|
||||||
return api.newPayload(params, nil, nil)
|
return api.newPayload(params, nil, nil)
|
||||||
}
|
}
|
||||||
@ -517,14 +517,14 @@ func (api *ConsensusAPI) NewPayloadV3(params engine.ExecutableData, versionedHas
|
|||||||
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil excessBlobGas post-cancun"))
|
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil excessBlobGas post-cancun"))
|
||||||
}
|
}
|
||||||
if params.BlobGasUsed == nil {
|
if params.BlobGasUsed == nil {
|
||||||
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil params.BlobGasUsed post-cancun"))
|
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil blobGasUsed post-cancun"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if versionedHashes == nil {
|
if versionedHashes == nil {
|
||||||
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil versionedHashes post-cancun"))
|
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil versionedHashes post-cancun"))
|
||||||
}
|
}
|
||||||
if beaconRoot == nil {
|
if beaconRoot == nil {
|
||||||
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil parentBeaconBlockRoot post-cancun"))
|
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil beaconRoot post-cancun"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if api.eth.BlockChain().Config().LatestFork(params.Timestamp) != forks.Cancun {
|
if api.eth.BlockChain().Config().LatestFork(params.Timestamp) != forks.Cancun {
|
||||||
@ -879,8 +879,7 @@ func getBody(block *types.Block) *engine.ExecutionPayloadBodyV1 {
|
|||||||
)
|
)
|
||||||
|
|
||||||
for j, tx := range body.Transactions {
|
for j, tx := range body.Transactions {
|
||||||
data, _ := tx.MarshalBinary()
|
txs[j], _ = tx.MarshalBinary()
|
||||||
txs[j] = hexutil.Bytes(data)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Post-shanghai withdrawals MUST be set to empty slice instead of nil
|
// Post-shanghai withdrawals MUST be set to empty slice instead of nil
|
||||||
|
@ -262,11 +262,8 @@ func TestInvalidPayloadTimestamp(t *testing.T) {
|
|||||||
{0, true},
|
{0, true},
|
||||||
{parent.Time, true},
|
{parent.Time, true},
|
||||||
{parent.Time - 1, true},
|
{parent.Time - 1, true},
|
||||||
|
{parent.Time + 1, false},
|
||||||
// TODO (MariusVanDerWijden) following tests are currently broken,
|
{uint64(time.Now().Unix()) + uint64(time.Minute), false},
|
||||||
// fixed in upcoming merge-kiln-v2 pr
|
|
||||||
//{parent.Time() + 1, false},
|
|
||||||
//{uint64(time.Now().Unix()) + uint64(time.Minute), false},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, test := range tests {
|
for i, test := range tests {
|
||||||
|
@ -919,7 +919,7 @@ func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, bloc
|
|||||||
config.BlockOverrides.Apply(&vmctx)
|
config.BlockOverrides.Apply(&vmctx)
|
||||||
}
|
}
|
||||||
// Execute the trace
|
// Execute the trace
|
||||||
msg, err := args.ToMessage(api.backend.RPCGasCap(), block.BaseFee())
|
msg, err := args.ToMessage(api.backend.RPCGasCap(), vmctx.BaseFee)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ func (t *callTracer) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, sco
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Avoid processing nested calls when only caring about top call
|
// Avoid processing nested calls when only caring about top call
|
||||||
if t.config.OnlyTopCall && depth > 0 {
|
if t.config.OnlyTopCall && depth > 1 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Skip if tracing was interrupted
|
// Skip if tracing was interrupted
|
||||||
|
@ -453,7 +453,7 @@ func (s *PersonalAccountAPI) signTransaction(ctx context.Context, args *Transact
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// Set some sanity defaults and terminate on failure
|
// Set some sanity defaults and terminate on failure
|
||||||
if err := args.setDefaults(ctx, s.b); err != nil {
|
if err := args.setDefaults(ctx, s.b, false); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// Assemble the transaction and sign with the wallet
|
// Assemble the transaction and sign with the wallet
|
||||||
@ -1093,14 +1093,14 @@ func doCall(ctx context.Context, b Backend, args TransactionArgs, state *state.S
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
// Get a new instance of the EVM.
|
// Get a new instance of the EVM.
|
||||||
msg, err := args.ToMessage(globalGasCap, header.BaseFee)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
blockCtx := core.NewEVMBlockContext(header, NewChainContext(ctx, b), nil)
|
blockCtx := core.NewEVMBlockContext(header, NewChainContext(ctx, b), nil)
|
||||||
if blockOverrides != nil {
|
if blockOverrides != nil {
|
||||||
blockOverrides.Apply(&blockCtx)
|
blockOverrides.Apply(&blockCtx)
|
||||||
}
|
}
|
||||||
|
msg, err := args.ToMessage(globalGasCap, blockCtx.BaseFee)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
evm := b.GetEVM(ctx, msg, state, header, &vm.Config{NoBaseFee: true}, &blockCtx)
|
evm := b.GetEVM(ctx, msg, state, header, &vm.Config{NoBaseFee: true}, &blockCtx)
|
||||||
|
|
||||||
// Wait for the context to be done and cancel the evm. Even if the
|
// Wait for the context to be done and cancel the evm. Even if the
|
||||||
@ -1485,14 +1485,9 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH
|
|||||||
if db == nil || err != nil {
|
if db == nil || err != nil {
|
||||||
return nil, 0, nil, err
|
return nil, 0, nil, err
|
||||||
}
|
}
|
||||||
// If the gas amount is not set, default to RPC gas cap.
|
|
||||||
if args.Gas == nil {
|
|
||||||
tmp := hexutil.Uint64(b.RPCGasCap())
|
|
||||||
args.Gas = &tmp
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure any missing fields are filled, extract the recipient and input data
|
// Ensure any missing fields are filled, extract the recipient and input data
|
||||||
if err := args.setDefaults(ctx, b); err != nil {
|
if err := args.setDefaults(ctx, b, true); err != nil {
|
||||||
return nil, 0, nil, err
|
return nil, 0, nil, err
|
||||||
}
|
}
|
||||||
var to common.Address
|
var to common.Address
|
||||||
@ -1795,7 +1790,7 @@ func (s *TransactionAPI) SendTransaction(ctx context.Context, args TransactionAr
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set some sanity defaults and terminate on failure
|
// Set some sanity defaults and terminate on failure
|
||||||
if err := args.setDefaults(ctx, s.b); err != nil {
|
if err := args.setDefaults(ctx, s.b, false); err != nil {
|
||||||
return common.Hash{}, err
|
return common.Hash{}, err
|
||||||
}
|
}
|
||||||
// Assemble the transaction and sign with the wallet
|
// Assemble the transaction and sign with the wallet
|
||||||
@ -1815,7 +1810,7 @@ func (s *TransactionAPI) FillTransaction(ctx context.Context, args TransactionAr
|
|||||||
args.blobSidecarAllowed = true
|
args.blobSidecarAllowed = true
|
||||||
|
|
||||||
// Set some sanity defaults and terminate on failure
|
// Set some sanity defaults and terminate on failure
|
||||||
if err := args.setDefaults(ctx, s.b); err != nil {
|
if err := args.setDefaults(ctx, s.b, false); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// Assemble the transaction and obtain rlp
|
// Assemble the transaction and obtain rlp
|
||||||
@ -1884,7 +1879,7 @@ func (s *TransactionAPI) SignTransaction(ctx context.Context, args TransactionAr
|
|||||||
if args.Nonce == nil {
|
if args.Nonce == nil {
|
||||||
return nil, errors.New("nonce not specified")
|
return nil, errors.New("nonce not specified")
|
||||||
}
|
}
|
||||||
if err := args.setDefaults(ctx, s.b); err != nil {
|
if err := args.setDefaults(ctx, s.b, false); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// Before actually sign the transaction, ensure the transaction fee is reasonable.
|
// Before actually sign the transaction, ensure the transaction fee is reasonable.
|
||||||
@ -1933,7 +1928,7 @@ func (s *TransactionAPI) Resend(ctx context.Context, sendArgs TransactionArgs, g
|
|||||||
if sendArgs.Nonce == nil {
|
if sendArgs.Nonce == nil {
|
||||||
return common.Hash{}, errors.New("missing transaction nonce in transaction spec")
|
return common.Hash{}, errors.New("missing transaction nonce in transaction spec")
|
||||||
}
|
}
|
||||||
if err := sendArgs.setDefaults(ctx, s.b); err != nil {
|
if err := sendArgs.setDefaults(ctx, s.b, false); err != nil {
|
||||||
return common.Hash{}, err
|
return common.Hash{}, err
|
||||||
}
|
}
|
||||||
matchTx := sendArgs.toTransaction()
|
matchTx := sendArgs.toTransaction()
|
||||||
|
@ -96,7 +96,7 @@ func (args *TransactionArgs) data() []byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// setDefaults fills in default values for unspecified tx fields.
|
// setDefaults fills in default values for unspecified tx fields.
|
||||||
func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend) error {
|
func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend, skipGasEstimation bool) error {
|
||||||
if err := args.setBlobTxSidecar(ctx, b); err != nil {
|
if err := args.setBlobTxSidecar(ctx, b); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -136,30 +136,37 @@ func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Estimate the gas usage if necessary.
|
|
||||||
if args.Gas == nil {
|
if args.Gas == nil {
|
||||||
// These fields are immutable during the estimation, safe to
|
if skipGasEstimation { // Skip gas usage estimation if a precise gas limit is not critical, e.g., in non-transaction calls.
|
||||||
// pass the pointer directly.
|
gas := hexutil.Uint64(b.RPCGasCap())
|
||||||
data := args.data()
|
if gas == 0 {
|
||||||
callArgs := TransactionArgs{
|
gas = hexutil.Uint64(math.MaxUint64 / 2)
|
||||||
From: args.From,
|
}
|
||||||
To: args.To,
|
args.Gas = &gas
|
||||||
GasPrice: args.GasPrice,
|
} else { // Estimate the gas usage otherwise.
|
||||||
MaxFeePerGas: args.MaxFeePerGas,
|
// These fields are immutable during the estimation, safe to
|
||||||
MaxPriorityFeePerGas: args.MaxPriorityFeePerGas,
|
// pass the pointer directly.
|
||||||
Value: args.Value,
|
data := args.data()
|
||||||
Data: (*hexutil.Bytes)(&data),
|
callArgs := TransactionArgs{
|
||||||
AccessList: args.AccessList,
|
From: args.From,
|
||||||
BlobFeeCap: args.BlobFeeCap,
|
To: args.To,
|
||||||
BlobHashes: args.BlobHashes,
|
GasPrice: args.GasPrice,
|
||||||
|
MaxFeePerGas: args.MaxFeePerGas,
|
||||||
|
MaxPriorityFeePerGas: args.MaxPriorityFeePerGas,
|
||||||
|
Value: args.Value,
|
||||||
|
Data: (*hexutil.Bytes)(&data),
|
||||||
|
AccessList: args.AccessList,
|
||||||
|
BlobFeeCap: args.BlobFeeCap,
|
||||||
|
BlobHashes: args.BlobHashes,
|
||||||
|
}
|
||||||
|
latestBlockNr := rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber)
|
||||||
|
estimated, err := DoEstimateGas(ctx, b, callArgs, latestBlockNr, nil, b.RPCGasCap())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args.Gas = &estimated
|
||||||
|
log.Trace("Estimate gas usage automatically", "gas", args.Gas)
|
||||||
}
|
}
|
||||||
latestBlockNr := rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber)
|
|
||||||
estimated, err := DoEstimateGas(ctx, b, callArgs, latestBlockNr, nil, b.RPCGasCap())
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
args.Gas = &estimated
|
|
||||||
log.Trace("Estimate gas usage automatically", "gas", args.Gas)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If chain id is provided, ensure it matches the local chain id. Otherwise, set the local
|
// If chain id is provided, ensure it matches the local chain id. Otherwise, set the local
|
||||||
|
@ -2,6 +2,7 @@ package log
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math/big"
|
"math/big"
|
||||||
@ -77,7 +78,7 @@ func benchmarkLogger(b *testing.B, l Logger) {
|
|||||||
tt = time.Now()
|
tt = time.Now()
|
||||||
bigint = big.NewInt(100)
|
bigint = big.NewInt(100)
|
||||||
nilbig *big.Int
|
nilbig *big.Int
|
||||||
err = fmt.Errorf("Oh nooes it's crap")
|
err = errors.New("Oh nooes it's crap")
|
||||||
)
|
)
|
||||||
b.ReportAllocs()
|
b.ReportAllocs()
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
@ -106,7 +107,7 @@ func TestLoggerOutput(t *testing.T) {
|
|||||||
tt = time.Time{}
|
tt = time.Time{}
|
||||||
bigint = big.NewInt(100)
|
bigint = big.NewInt(100)
|
||||||
nilbig *big.Int
|
nilbig *big.Int
|
||||||
err = fmt.Errorf("Oh nooes it's crap")
|
err = errors.New("Oh nooes it's crap")
|
||||||
smallUint = uint256.NewInt(500_000)
|
smallUint = uint256.NewInt(500_000)
|
||||||
bigUint = &uint256.Int{0xff, 0xff, 0xff, 0xff}
|
bigUint = &uint256.Int{0xff, 0xff, 0xff, 0xff}
|
||||||
)
|
)
|
||||||
|
@ -914,13 +914,13 @@ func (srv *Server) checkInboundConn(remoteIP net.IP) error {
|
|||||||
}
|
}
|
||||||
// Reject connections that do not match NetRestrict.
|
// Reject connections that do not match NetRestrict.
|
||||||
if srv.NetRestrict != nil && !srv.NetRestrict.Contains(remoteIP) {
|
if srv.NetRestrict != nil && !srv.NetRestrict.Contains(remoteIP) {
|
||||||
return fmt.Errorf("not in netrestrict list")
|
return errors.New("not in netrestrict list")
|
||||||
}
|
}
|
||||||
// Reject Internet peers that try too often.
|
// Reject Internet peers that try too often.
|
||||||
now := srv.clock.Now()
|
now := srv.clock.Now()
|
||||||
srv.inboundHistory.expire(now, nil)
|
srv.inboundHistory.expire(now, nil)
|
||||||
if !netutil.IsLAN(remoteIP) && srv.inboundHistory.contains(remoteIP.String()) {
|
if !netutil.IsLAN(remoteIP) && srv.inboundHistory.contains(remoteIP.String()) {
|
||||||
return fmt.Errorf("too many attempts")
|
return errors.New("too many attempts")
|
||||||
}
|
}
|
||||||
srv.inboundHistory.add(remoteIP.String(), now.Add(inboundThrottleTime))
|
srv.inboundHistory.add(remoteIP.String(), now.Add(inboundThrottleTime))
|
||||||
return nil
|
return nil
|
||||||
|
@ -19,6 +19,7 @@ package p2p
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
@ -157,7 +158,7 @@ func readProtocolHandshake(rw MsgReader) (*protoHandshake, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if msg.Size > baseProtocolMaxMsgSize {
|
if msg.Size > baseProtocolMaxMsgSize {
|
||||||
return nil, fmt.Errorf("message too big")
|
return nil, errors.New("message too big")
|
||||||
}
|
}
|
||||||
if msg.Code == discMsg {
|
if msg.Code == discMsg {
|
||||||
// Disconnect before protocol handshake is valid according to the
|
// Disconnect before protocol handshake is valid according to the
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
const (
|
const (
|
||||||
VersionMajor = 1 // Major version component of the current release
|
VersionMajor = 1 // Major version component of the current release
|
||||||
VersionMinor = 13 // Minor version component of the current release
|
VersionMinor = 13 // Minor version component of the current release
|
||||||
VersionPatch = 13 // Patch version component of the current release
|
VersionPatch = 14 // Patch version component of the current release
|
||||||
VersionMeta = "stable" // Version metadata to append to the version string
|
VersionMeta = "stable" // Version metadata to append to the version string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ package rpc
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"strings"
|
"strings"
|
||||||
@ -104,7 +105,7 @@ func (bn *BlockNumber) UnmarshalJSON(data []byte) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if blckNum > math.MaxInt64 {
|
if blckNum > math.MaxInt64 {
|
||||||
return fmt.Errorf("block number larger than int64")
|
return errors.New("block number larger than int64")
|
||||||
}
|
}
|
||||||
*bn = BlockNumber(blckNum)
|
*bn = BlockNumber(blckNum)
|
||||||
return nil
|
return nil
|
||||||
@ -154,7 +155,7 @@ func (bnh *BlockNumberOrHash) UnmarshalJSON(data []byte) error {
|
|||||||
err := json.Unmarshal(data, &e)
|
err := json.Unmarshal(data, &e)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if e.BlockNumber != nil && e.BlockHash != nil {
|
if e.BlockNumber != nil && e.BlockHash != nil {
|
||||||
return fmt.Errorf("cannot specify both BlockHash and BlockNumber, choose one or the other")
|
return errors.New("cannot specify both BlockHash and BlockNumber, choose one or the other")
|
||||||
}
|
}
|
||||||
bnh.BlockNumber = e.BlockNumber
|
bnh.BlockNumber = e.BlockNumber
|
||||||
bnh.BlockHash = e.BlockHash
|
bnh.BlockHash = e.BlockHash
|
||||||
@ -202,7 +203,7 @@ func (bnh *BlockNumberOrHash) UnmarshalJSON(data []byte) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if blckNum > math.MaxInt64 {
|
if blckNum > math.MaxInt64 {
|
||||||
return fmt.Errorf("blocknumber too high")
|
return errors.New("blocknumber too high")
|
||||||
}
|
}
|
||||||
bn := BlockNumber(blckNum)
|
bn := BlockNumber(blckNum)
|
||||||
bnh.BlockNumber = &bn
|
bnh.BlockNumber = &bn
|
||||||
|
Loading…
Reference in New Issue
Block a user