mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
add delegate tx support in legacypool
This commit is contained in:
parent
2f1cb35252
commit
947a5383ef
2 changed files with 59 additions and 3 deletions
|
|
@ -274,10 +274,10 @@ func New(config Config, chain BlockChain) *LegacyPool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter returns whether the given transaction can be consumed by the legacy
|
// Filter returns whether the given transaction can be consumed by the legacy
|
||||||
// pool, specifically, whether it is a Legacy, AccessList or Dynamic transaction.
|
// pool, specifically, whether it is a Legacy, AccessList, Dynamic or Delegate transaction.
|
||||||
func (pool *LegacyPool) Filter(tx *types.Transaction) bool {
|
func (pool *LegacyPool) Filter(tx *types.Transaction) bool {
|
||||||
switch tx.Type() {
|
switch tx.Type() {
|
||||||
case types.LegacyTxType, types.AccessListTxType, types.DynamicFeeTxType:
|
case types.LegacyTxType, types.AccessListTxType, types.DynamicFeeTxType, types.DelegateTxType:
|
||||||
return true
|
return true
|
||||||
default:
|
default:
|
||||||
return false
|
return false
|
||||||
|
|
@ -609,7 +609,8 @@ func (pool *LegacyPool) validateTxBasics(tx *types.Transaction, local bool) erro
|
||||||
Accept: 0 |
|
Accept: 0 |
|
||||||
1<<types.LegacyTxType |
|
1<<types.LegacyTxType |
|
||||||
1<<types.AccessListTxType |
|
1<<types.AccessListTxType |
|
||||||
1<<types.DynamicFeeTxType,
|
1<<types.DynamicFeeTxType |
|
||||||
|
1<<types.DelegateTxType,
|
||||||
MaxSize: txMaxSize,
|
MaxSize: txMaxSize,
|
||||||
MinTip: pool.gasTip.Load().ToBig(),
|
MinTip: pool.gasTip.Load().ToBig(),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -409,6 +409,61 @@ func (tx *Transaction) UnmarshalJSON(input []byte) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case DelegateTxType:
|
||||||
|
var itx DelegateTx
|
||||||
|
inner = &itx
|
||||||
|
if dec.ChainID == nil {
|
||||||
|
return errors.New("missing required field 'chainId' in transaction")
|
||||||
|
}
|
||||||
|
itx.ChainID = (*big.Int)(dec.ChainID)
|
||||||
|
if dec.Nonce == nil {
|
||||||
|
return errors.New("missing required field 'nonce' in transaction")
|
||||||
|
}
|
||||||
|
itx.Nonce = uint64(*dec.Nonce)
|
||||||
|
if dec.To != nil {
|
||||||
|
itx.To = dec.To
|
||||||
|
}
|
||||||
|
if dec.Gas == nil {
|
||||||
|
return errors.New("missing required field 'gas' for txdata")
|
||||||
|
}
|
||||||
|
itx.Gas = uint64(*dec.Gas)
|
||||||
|
if dec.MaxPriorityFeePerGas == nil {
|
||||||
|
return errors.New("missing required field 'maxPriorityFeePerGas' for txdata")
|
||||||
|
}
|
||||||
|
itx.GasTipCap = (*big.Int)(dec.MaxPriorityFeePerGas)
|
||||||
|
if dec.MaxFeePerGas == nil {
|
||||||
|
return errors.New("missing required field 'maxFeePerGas' for txdata")
|
||||||
|
}
|
||||||
|
itx.GasFeeCap = (*big.Int)(dec.MaxFeePerGas)
|
||||||
|
if dec.Value == nil {
|
||||||
|
return errors.New("missing required field 'value' in transaction")
|
||||||
|
}
|
||||||
|
itx.Data = *dec.Input
|
||||||
|
if dec.AccessList != nil {
|
||||||
|
itx.AccessList = *dec.AccessList
|
||||||
|
}
|
||||||
|
|
||||||
|
// signature R
|
||||||
|
if dec.R == nil {
|
||||||
|
return errors.New("missing required field 'r' in transaction")
|
||||||
|
}
|
||||||
|
itx.R = (*big.Int)(dec.R)
|
||||||
|
// signature S
|
||||||
|
if dec.S == nil {
|
||||||
|
return errors.New("missing required field 's' in transaction")
|
||||||
|
}
|
||||||
|
itx.S = (*big.Int)(dec.S)
|
||||||
|
// signature V
|
||||||
|
itx.V, err = dec.yParityValue()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if itx.V.Sign() != 0 || itx.R.Sign() != 0 || itx.S.Sign() != 0 {
|
||||||
|
if err := sanityCheckSignature(itx.V, itx.R, itx.S, false); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return ErrTxTypeNotSupported
|
return ErrTxTypeNotSupported
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue