@@ -67,7 +67,7 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types
67
67
// This is for spam protection, not consensus,
68
68
// as the external engine-API user authenticates deposits.
69
69
if tx .Type () == types .DepositTxType {
70
- meter (TypeNotSupportDeposit ).Mark (1 )
70
+ Meter (TypeNotSupportDeposit ).Mark (1 )
71
71
return core .ErrTxTypeNotSupported
72
72
}
73
73
// Ensure transactions not implemented by the calling pool are rejected
@@ -81,25 +81,25 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types
81
81
}
82
82
// Ensure only transactions that have been enabled are accepted
83
83
if ! opts .Config .IsBerlin (head .Number ) && tx .Type () != types .LegacyTxType {
84
- meter (TypeNotSupport2718 ).Mark (1 )
84
+ Meter (TypeNotSupport2718 ).Mark (1 )
85
85
return fmt .Errorf ("%w: type %d rejected, pool not yet in Berlin" , core .ErrTxTypeNotSupported , tx .Type ())
86
86
}
87
87
if ! opts .Config .IsLondon (head .Number ) && tx .Type () == types .DynamicFeeTxType {
88
- meter (TypeNotSupport1559 ).Mark (1 )
88
+ Meter (TypeNotSupport1559 ).Mark (1 )
89
89
return fmt .Errorf ("%w: type %d rejected, pool not yet in London" , core .ErrTxTypeNotSupported , tx .Type ())
90
90
}
91
91
if ! opts .Config .IsCancun (head .Number , head .Time ) && tx .Type () == types .BlobTxType {
92
92
return fmt .Errorf ("%w: type %d rejected, pool not yet in Cancun" , core .ErrTxTypeNotSupported , tx .Type ())
93
93
}
94
94
// Check whether the init code size has been exceeded
95
95
if opts .Config .IsShanghai (head .Number , head .Time ) && tx .To () == nil && len (tx .Data ()) > params .MaxInitCodeSize {
96
- meter (MaxInitCodeSizeExceeded ).Mark (1 )
96
+ Meter (MaxInitCodeSizeExceeded ).Mark (1 )
97
97
return fmt .Errorf ("%w: code size %v, limit %v" , core .ErrMaxInitCodeSizeExceeded , len (tx .Data ()), params .MaxInitCodeSize )
98
98
}
99
99
// Transactions can't be negative. This may never happen using RLP decoded
100
100
// transactions but may occur for transactions created using the RPC.
101
101
if tx .Value ().Sign () < 0 {
102
- meter (NegativeValue ).Mark (1 )
102
+ Meter (NegativeValue ).Mark (1 )
103
103
return ErrNegativeValue
104
104
}
105
105
// Ensure the transaction doesn't exceed the current block limit gas
@@ -108,36 +108,38 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types
108
108
}
109
109
// Sanity check for extremely large numbers (supported by RLP or RPC)
110
110
if tx .GasFeeCap ().BitLen () > 256 {
111
- meter (FeeCapVeryHigh ).Mark (1 )
111
+ Meter (FeeCapVeryHigh ).Mark (1 )
112
112
return core .ErrFeeCapVeryHigh
113
113
}
114
114
if tx .GasTipCap ().BitLen () > 256 {
115
- meter (TipVeryHigh ).Mark (1 )
115
+ Meter (TipVeryHigh ).Mark (1 )
116
116
return core .ErrTipVeryHigh
117
117
}
118
118
// Ensure gasFeeCap is greater than or equal to gasTipCap
119
119
if tx .GasFeeCapIntCmp (tx .GasTipCap ()) < 0 {
120
- meter (TipAboveFeeCap ).Mark (1 )
120
+ Meter (TipAboveFeeCap ).Mark (1 )
121
121
return core .ErrTipAboveFeeCap
122
122
}
123
123
// Make sure the transaction is signed properly
124
124
if _ , err := types .Sender (signer , tx ); err != nil {
125
- meter (InvalidSender ).Mark (1 )
125
+ Meter (InvalidSender ).Mark (1 )
126
126
return ErrInvalidSender
127
127
}
128
128
// Ensure the transaction has more gas than the bare minimum needed to cover
129
129
// the transaction metadata
130
130
intrGas , err := core .IntrinsicGas (tx .Data (), tx .AccessList (), tx .To () == nil , true , opts .Config .IsIstanbul (head .Number ), opts .Config .IsShanghai (head .Number , head .Time ))
131
131
if err != nil {
132
+ Meter (GasUnitOverflow ).Mark (1 )
132
133
return err
133
134
}
134
135
if tx .Gas () < intrGas {
136
+ Meter (IntrinsicGas ).Mark (1 )
135
137
return fmt .Errorf ("%w: needed %v, allowed %v" , core .ErrIntrinsicGas , intrGas , tx .Gas ())
136
138
}
137
139
// Ensure the gasprice is high enough to cover the requirement of the calling
138
140
// pool and/or block producer
139
141
if tx .GasTipCapIntCmp (opts .MinTip ) < 0 {
140
- meter (Underpriced ).Mark (1 )
142
+ Meter (Underpriced ).Mark (1 )
141
143
return fmt .Errorf ("%w: tip needed %v, tip permitted %v" , ErrUnderpriced , opts .MinTip , tx .GasTipCap ())
142
144
}
143
145
// Ensure blob transactions have valid commitments
@@ -240,7 +242,7 @@ func ValidateTransactionWithState(tx *types.Transaction, signer types.Signer, op
240
242
}
241
243
next := opts .State .GetNonce (from )
242
244
if next > tx .Nonce () {
243
- meter (NonceTooLow ).Mark (1 )
245
+ Meter (NonceTooLow ).Mark (1 )
244
246
return fmt .Errorf ("%w: next nonce %v, tx nonce %v" , core .ErrNonceTooLow , next , tx .Nonce ())
245
247
}
246
248
// Ensure the transaction doesn't produce a nonce gap in pools that do not
@@ -261,7 +263,7 @@ func ValidateTransactionWithState(tx *types.Transaction, signer types.Signer, op
261
263
}
262
264
}
263
265
if balance .Cmp (cost ) < 0 {
264
- meter (InsufficientFunds ).Mark (1 )
266
+ Meter (InsufficientFunds ).Mark (1 )
265
267
return fmt .Errorf ("%w: balance %v, tx cost %v, overshot %v" , core .ErrInsufficientFunds , balance , cost , new (big.Int ).Sub (cost , balance ))
266
268
}
267
269
// Ensure the transactor has enough funds to cover for replacements or nonce
@@ -271,11 +273,13 @@ func ValidateTransactionWithState(tx *types.Transaction, signer types.Signer, op
271
273
bump := new (big.Int ).Sub (cost , prev )
272
274
need := new (big.Int ).Add (spent , bump )
273
275
if balance .Cmp (need ) < 0 {
276
+ Meter (Overdraft ).Mark (1 )
274
277
return fmt .Errorf ("%w: balance %v, queued cost %v, tx bumped %v, overshot %v" , core .ErrInsufficientFunds , balance , spent , bump , new (big.Int ).Sub (need , balance ))
275
278
}
276
279
} else {
277
280
need := new (big.Int ).Add (spent , cost )
278
281
if balance .Cmp (need ) < 0 {
282
+ Meter (Overdraft ).Mark (1 )
279
283
return fmt .Errorf ("%w: balance %v, queued cost %v, tx cost %v, overshot %v" , core .ErrInsufficientFunds , balance , spent , cost , new (big.Int ).Sub (need , balance ))
280
284
}
281
285
// Transaction takes a new nonce value out of the pool. Ensure it doesn't
0 commit comments