mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
replaced 4337 with PIP-15
This commit is contained in:
parent
d0c74c4cf2
commit
6939df80da
9 changed files with 29 additions and 29 deletions
|
|
@ -109,7 +109,7 @@ func TestFilterTxConditional(t *testing.T) {
|
||||||
// and add to the list.
|
// and add to the list.
|
||||||
tx2 := transaction(1, 1000, key)
|
tx2 := transaction(1, 1000, key)
|
||||||
|
|
||||||
var options types.OptionsAA4337
|
var options types.OptionsPIP15
|
||||||
|
|
||||||
options.KnownAccounts = types.KnownAccounts{
|
options.KnownAccounts = types.KnownAccounts{
|
||||||
common.Address{19: 1}: &types.Value{
|
common.Address{19: 1}: &types.Value{
|
||||||
|
|
|
||||||
|
|
@ -189,8 +189,8 @@ func (h *Header) EmptyReceipts() bool {
|
||||||
return h.ReceiptHash == EmptyReceiptsHash
|
return h.ReceiptHash == EmptyReceiptsHash
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateBlockNumberOptions4337 validates the block range passed as in the options parameter in the conditional transaction (EIP-4337)
|
// ValidateBlockNumberOptionsPIP15 validates the block range passed as in the options parameter in the conditional transaction (PIP-15)
|
||||||
func (h *Header) ValidateBlockNumberOptions4337(minBlockNumber *big.Int, maxBlockNumber *big.Int) error {
|
func (h *Header) ValidateBlockNumberOptionsPIP15(minBlockNumber *big.Int, maxBlockNumber *big.Int) error {
|
||||||
currentBlockNumber := h.Number
|
currentBlockNumber := h.Number
|
||||||
|
|
||||||
if minBlockNumber != nil {
|
if minBlockNumber != nil {
|
||||||
|
|
@ -208,8 +208,8 @@ func (h *Header) ValidateBlockNumberOptions4337(minBlockNumber *big.Int, maxBloc
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateBlockNumberOptions4337 validates the timestamp range passed as in the options parameter in the conditional transaction (EIP-4337)
|
// ValidateBlockNumberOptionsPIP15 validates the timestamp range passed as in the options parameter in the conditional transaction (PIP-15)
|
||||||
func (h *Header) ValidateTimestampOptions4337(minTimestamp *uint64, maxTimestamp *uint64) error {
|
func (h *Header) ValidateTimestampOptionsPIP15(minTimestamp *uint64, maxTimestamp *uint64) error {
|
||||||
currentBlockTime := h.Time
|
currentBlockTime := h.Time
|
||||||
|
|
||||||
if minTimestamp != nil {
|
if minTimestamp != nil {
|
||||||
|
|
|
||||||
|
|
@ -435,7 +435,7 @@ func TestRlpDecodeParentHash(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValidateBlockNumberOptions4337(t *testing.T) {
|
func TestValidateBlockNumberOptionsPIP15(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
testsPass := []struct {
|
testsPass := []struct {
|
||||||
|
|
@ -503,19 +503,19 @@ func TestValidateBlockNumberOptions4337(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range testsPass {
|
for _, test := range testsPass {
|
||||||
if err := test.header.ValidateBlockNumberOptions4337(test.minBlockNumber, test.maxBlockNumber); err != nil {
|
if err := test.header.ValidateBlockNumberOptionsPIP15(test.minBlockNumber, test.maxBlockNumber); err != nil {
|
||||||
t.Fatalf("test number %v should not have failed. err: %v", test.number, err)
|
t.Fatalf("test number %v should not have failed. err: %v", test.number, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range testsFail {
|
for _, test := range testsFail {
|
||||||
if err := test.header.ValidateBlockNumberOptions4337(test.minBlockNumber, test.maxBlockNumber); err == nil {
|
if err := test.header.ValidateBlockNumberOptionsPIP15(test.minBlockNumber, test.maxBlockNumber); err == nil {
|
||||||
t.Fatalf("test number %v should have failed. err is nil", test.number)
|
t.Fatalf("test number %v should have failed. err is nil", test.number)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValidateTimestampOptions4337(t *testing.T) {
|
func TestValidateTimestampOptionsPIP15(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
u64Ptr := func(n uint64) *uint64 {
|
u64Ptr := func(n uint64) *uint64 {
|
||||||
|
|
@ -587,13 +587,13 @@ func TestValidateTimestampOptions4337(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range testsPass {
|
for _, test := range testsPass {
|
||||||
if err := test.header.ValidateTimestampOptions4337(test.minTimestamp, test.maxTimestamp); err != nil {
|
if err := test.header.ValidateTimestampOptionsPIP15(test.minTimestamp, test.maxTimestamp); err != nil {
|
||||||
t.Fatalf("test number %v should not have failed. err: %v", test.number, err)
|
t.Fatalf("test number %v should not have failed. err: %v", test.number, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range testsFail {
|
for _, test := range testsFail {
|
||||||
if err := test.header.ValidateTimestampOptions4337(test.minTimestamp, test.maxTimestamp); err == nil {
|
if err := test.header.ValidateTimestampOptionsPIP15(test.minTimestamp, test.maxTimestamp); err == nil {
|
||||||
t.Fatalf("test number %v should have failed. err is nil", test.number)
|
t.Fatalf("test number %v should have failed. err is nil", test.number)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,8 +57,8 @@ type Transaction struct {
|
||||||
time time.Time // Time first seen locally (spam avoidance)
|
time time.Time // Time first seen locally (spam avoidance)
|
||||||
|
|
||||||
// BOR specific - DO NOT REMOVE
|
// BOR specific - DO NOT REMOVE
|
||||||
// knownAccounts (EIP-4337)
|
// knownAccounts (PIP-15)
|
||||||
optionsAA4337 *OptionsAA4337
|
optionsPIP15 *OptionsPIP15
|
||||||
|
|
||||||
// caches
|
// caches
|
||||||
hash atomic.Value
|
hash atomic.Value
|
||||||
|
|
@ -106,14 +106,14 @@ type TxData interface {
|
||||||
decode([]byte) error
|
decode([]byte) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// PutOptions stores the optionsAA4337 field of the conditional transaction (EIP-4337)
|
// PutOptions stores the optionsPIP15 field of the conditional transaction (PIP-15)
|
||||||
func (tx *Transaction) PutOptions(options *OptionsAA4337) {
|
func (tx *Transaction) PutOptions(options *OptionsPIP15) {
|
||||||
tx.optionsAA4337 = options
|
tx.optionsPIP15 = options
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetOptions returns the optionsAA4337 field of the conditional transaction (EIP-4337)
|
// GetOptions returns the optionsPIP15 field of the conditional transaction (PIP-15)
|
||||||
func (tx *Transaction) GetOptions() *OptionsAA4337 {
|
func (tx *Transaction) GetOptions() *OptionsPIP15 {
|
||||||
return tx.optionsAA4337
|
return tx.optionsPIP15
|
||||||
}
|
}
|
||||||
|
|
||||||
// EncodeRLP implements rlp.Encoder
|
// EncodeRLP implements rlp.Encoder
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ func InsertKnownAccounts[T common.Hash | map[common.Hash]common.Hash](accounts K
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type OptionsAA4337 struct {
|
type OptionsPIP15 struct {
|
||||||
KnownAccounts KnownAccounts `json:"knownAccounts"`
|
KnownAccounts KnownAccounts `json:"knownAccounts"`
|
||||||
BlockNumberMin *big.Int `json:"blockNumberMin"`
|
BlockNumberMin *big.Int `json:"blockNumberMin"`
|
||||||
BlockNumberMax *big.Int `json:"blockNumberMax"`
|
BlockNumberMax *big.Int `json:"blockNumberMax"`
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ func (p *Peer) broadcastTransactions() {
|
||||||
tx := p.txpool.Get(queue[i])
|
tx := p.txpool.Get(queue[i])
|
||||||
|
|
||||||
// BOR specific - DO NOT REMOVE
|
// BOR specific - DO NOT REMOVE
|
||||||
// Skip EIP-4337 bundled transactions
|
// Skip PIP-15 bundled transactions
|
||||||
if tx != nil && tx.GetOptions() == nil {
|
if tx != nil && tx.GetOptions() == nil {
|
||||||
txs = append(txs, tx)
|
txs = append(txs, tx)
|
||||||
size += common.StorageSize(tx.Size())
|
size += common.StorageSize(tx.Size())
|
||||||
|
|
@ -156,7 +156,7 @@ func (p *Peer) announceTransactions() {
|
||||||
for count = 0; count < len(queue) && size < maxTxPacketSize; count++ {
|
for count = 0; count < len(queue) && size < maxTxPacketSize; count++ {
|
||||||
tx := p.txpool.Get(queue[count])
|
tx := p.txpool.Get(queue[count])
|
||||||
// BOR specific - DO NOT REMOVE
|
// BOR specific - DO NOT REMOVE
|
||||||
// Skip EIP-4337 bundled transactions
|
// Skip PIP-15 bundled transactions
|
||||||
if tx != nil && tx.GetOptions() == nil {
|
if tx != nil && tx.GetOptions() == nil {
|
||||||
pending = append(pending, queue[count])
|
pending = append(pending, queue[count])
|
||||||
pendingTypes = append(pendingTypes, tx.Type())
|
pendingTypes = append(pendingTypes, tx.Type())
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ func NewBorAPI(b Backend) *BorAPI {
|
||||||
|
|
||||||
// SendRawTransactionConditional will add the signed transaction to the transaction pool.
|
// SendRawTransactionConditional will add the signed transaction to the transaction pool.
|
||||||
// The sender/bundler is responsible for signing the transaction
|
// The sender/bundler is responsible for signing the transaction
|
||||||
func (api *BorAPI) SendRawTransactionConditional(ctx context.Context, input hexutil.Bytes, options types.OptionsAA4337) (common.Hash, error) {
|
func (api *BorAPI) SendRawTransactionConditional(ctx context.Context, input hexutil.Bytes, options types.OptionsPIP15) (common.Hash, error) {
|
||||||
tx := new(types.Transaction)
|
tx := new(types.Transaction)
|
||||||
if err := tx.UnmarshalBinary(input); err != nil {
|
if err := tx.UnmarshalBinary(input); err != nil {
|
||||||
return common.Hash{}, err
|
return common.Hash{}, err
|
||||||
|
|
@ -81,12 +81,12 @@ func (api *BorAPI) SendRawTransactionConditional(ctx context.Context, input hexu
|
||||||
}
|
}
|
||||||
|
|
||||||
// check block number range
|
// check block number range
|
||||||
if err := currentHeader.ValidateBlockNumberOptions4337(options.BlockNumberMin, options.BlockNumberMax); err != nil {
|
if err := currentHeader.ValidateBlockNumberOptionsPIP15(options.BlockNumberMin, options.BlockNumberMax); err != nil {
|
||||||
return common.Hash{}, &rpc.OptionsValidateError{Message: "out of block range. err: " + err.Error()}
|
return common.Hash{}, &rpc.OptionsValidateError{Message: "out of block range. err: " + err.Error()}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check timestamp range
|
// check timestamp range
|
||||||
if err := currentHeader.ValidateTimestampOptions4337(options.TimestampMin, options.TimestampMax); err != nil {
|
if err := currentHeader.ValidateTimestampOptionsPIP15(options.TimestampMin, options.TimestampMax); err != nil {
|
||||||
return common.Hash{}, &rpc.OptionsValidateError{Message: "out of time range. err: " + err.Error()}
|
return common.Hash{}, &rpc.OptionsValidateError{Message: "out of time range. err: " + err.Error()}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -601,14 +601,14 @@ mainloop:
|
||||||
// not prioritising conditional transaction, yet.
|
// not prioritising conditional transaction, yet.
|
||||||
//nolint:nestif
|
//nolint:nestif
|
||||||
if options := tx.GetOptions(); options != nil {
|
if options := tx.GetOptions(); options != nil {
|
||||||
if err := env.header.ValidateBlockNumberOptions4337(options.BlockNumberMin, options.BlockNumberMax); err != nil {
|
if err := env.header.ValidateBlockNumberOptionsPIP15(options.BlockNumberMin, options.BlockNumberMax); err != nil {
|
||||||
log.Trace("Dropping conditional transaction", "from", from, "hash", tx.Hash(), "reason", err)
|
log.Trace("Dropping conditional transaction", "from", from, "hash", tx.Hash(), "reason", err)
|
||||||
txs.Pop()
|
txs.Pop()
|
||||||
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := env.header.ValidateTimestampOptions4337(options.TimestampMin, options.TimestampMax); err != nil {
|
if err := env.header.ValidateTimestampOptionsPIP15(options.TimestampMin, options.TimestampMax); err != nil {
|
||||||
log.Trace("Dropping conditional transaction", "from", from, "hash", tx.Hash(), "reason", err)
|
log.Trace("Dropping conditional transaction", "from", from, "hash", tx.Hash(), "reason", err)
|
||||||
txs.Pop()
|
txs.Pop()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1023,14 +1023,14 @@ mainloop:
|
||||||
// not prioritising conditional transaction, yet.
|
// not prioritising conditional transaction, yet.
|
||||||
//nolint:nestif
|
//nolint:nestif
|
||||||
if options := tx.GetOptions(); options != nil {
|
if options := tx.GetOptions(); options != nil {
|
||||||
if err := env.header.ValidateBlockNumberOptions4337(options.BlockNumberMin, options.BlockNumberMax); err != nil {
|
if err := env.header.ValidateBlockNumberOptionsPIP15(options.BlockNumberMin, options.BlockNumberMax); err != nil {
|
||||||
log.Trace("Dropping conditional transaction", "from", from, "hash", tx.Hash(), "reason", err)
|
log.Trace("Dropping conditional transaction", "from", from, "hash", tx.Hash(), "reason", err)
|
||||||
txs.Pop()
|
txs.Pop()
|
||||||
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := env.header.ValidateTimestampOptions4337(options.TimestampMin, options.TimestampMax); err != nil {
|
if err := env.header.ValidateTimestampOptionsPIP15(options.TimestampMin, options.TimestampMax); err != nil {
|
||||||
log.Trace("Dropping conditional transaction", "from", from, "hash", tx.Hash(), "reason", err)
|
log.Trace("Dropping conditional transaction", "from", from, "hash", tx.Hash(), "reason", err)
|
||||||
txs.Pop()
|
txs.Pop()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue