Skip to content

Commit

Permalink
txpool changes for set_code_tx support (#12181)
Browse files Browse the repository at this point in the history
Cherry pick #11235

Co-authored-by: sudeep <sudeepdino008@gmail.com>
  • Loading branch information
2 people authored and AskAlexSharov committed Oct 21, 2024
1 parent bf0398d commit 1cabe82
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 23 deletions.
4 changes: 2 additions & 2 deletions cmd/txpool/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/ledgerwatch/erigon-lib/kv/remotedbserver"
"github.com/ledgerwatch/erigon-lib/txpool"
"github.com/ledgerwatch/erigon-lib/txpool/txpoolcfg"
"github.com/ledgerwatch/erigon-lib/txpool/txpooluitl"
"github.com/ledgerwatch/erigon-lib/txpool/txpoolutil"
"github.com/ledgerwatch/erigon-lib/types"
"github.com/ledgerwatch/erigon/cmd/rpcdaemon/rpcdaemontest"
common2 "github.com/ledgerwatch/erigon/common"
Expand Down Expand Up @@ -166,7 +166,7 @@ func doTxpool(ctx context.Context, logger log.Logger) error {

newTxs := make(chan types.Announcements, 1024)
defer close(newTxs)
txPoolDB, txPool, fetch, send, txpoolGrpcServer, err := txpooluitl.AllComponents(ctx, cfg,
txPoolDB, txPool, fetch, send, txpoolGrpcServer, err := txpoolutil.AllComponents(ctx, cfg,
kvcache.New(cacheConfig), newTxs, coreDB, sentryClients, kvClient, misc.Eip1559FeeCalculator, logger)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion core/types/encdec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func (tr *TRand) RandTransaction() Transaction {
FeeCap: uint256.NewInt(*tr.RandUint64()),
AccessList: tr.RandAccessList(tr.RandIntInRange(1, 5)),
},
Authorizations: tr.RandAuthorizations(tr.RandIntInRange(1, 5)),
Authorizations: tr.RandAuthorizations(tr.RandIntInRange(0, 5)),
}
default:
fmt.Printf("unexpected txType %v", txType)
Expand Down
46 changes: 43 additions & 3 deletions erigon-lib/txpool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ type TxPool struct {
isPostAgra atomic.Bool
cancunTime *uint64
isPostCancun atomic.Bool
pragueTime *uint64
isPostPrague atomic.Bool
maxBlobsPerBlock uint64
feeCalculator FeeCalculator
logger log.Logger
Expand All @@ -240,7 +242,7 @@ type FeeCalculator interface {
}

func New(newTxs chan types.Announcements, coreDB kv.RoDB, cfg txpoolcfg.Config, cache kvcache.Cache,
chainID uint256.Int, shanghaiTime, agraBlock, cancunTime *big.Int, maxBlobsPerBlock uint64,
chainID uint256.Int, shanghaiTime, agraBlock, cancunTime, pragueTime *big.Int, maxBlobsPerBlock uint64,
feeCalculator FeeCalculator, logger log.Logger,
) (*TxPool, error) {
localsHistory, err := simplelru.NewLRU[string, struct{}](10_000, nil)
Expand Down Expand Up @@ -312,6 +314,13 @@ func New(newTxs chan types.Announcements, coreDB kv.RoDB, cfg txpoolcfg.Config,
cancunTimeU64 := cancunTime.Uint64()
res.cancunTime = &cancunTimeU64
}
if pragueTime != nil {
if !pragueTime.IsUint64() {
return nil, errors.New("pragueTime overflow")
}
pragueTimeU64 := pragueTime.Uint64()
res.pragueTime = &pragueTimeU64
}

return res, nil
}
Expand Down Expand Up @@ -764,7 +773,7 @@ func (p *TxPool) best(n uint16, txs *types.TxsRlp, tx kv.Tx, onTopOf, availableG
// make sure we have enough gas in the caller to add this transaction.
// not an exact science using intrinsic gas but as close as we could hope for at
// this stage
intrinsicGas, _ := txpoolcfg.CalcIntrinsicGas(uint64(mt.Tx.DataLen), uint64(mt.Tx.DataNonZeroLen), 0, nil, mt.Tx.Creation, true, true, isShanghai)
intrinsicGas, _ := txpoolcfg.CalcIntrinsicGas(uint64(mt.Tx.DataLen), uint64(mt.Tx.DataNonZeroLen), uint64(mt.Tx.AuthorizationLen), nil, mt.Tx.Creation, true, true, isShanghai)
if intrinsicGas > availableGas {
// we might find another TX with a low enough intrinsic gas to include so carry on
continue
Expand Down Expand Up @@ -888,14 +897,20 @@ func (p *TxPool) validateTx(txn *types.TxSlot, isLocal bool, stateCache kvcache.
}
}

if txn.Type == types.SetCodeTxType {
if !p.isPrague() {
return txpoolcfg.TypeNotActivated
}
}

// Drop non-local transactions under our own minimal accepted gas price or tip
if !isLocal && uint256.NewInt(p.cfg.MinFeeCap).Cmp(&txn.FeeCap) == 1 {
if txn.Traced {
p.logger.Info(fmt.Sprintf("TX TRACING: validateTx underpriced idHash=%x local=%t, feeCap=%d, cfg.MinFeeCap=%d", txn.IDHash, isLocal, txn.FeeCap, p.cfg.MinFeeCap))
}
return txpoolcfg.UnderPriced
}
gas, reason := txpoolcfg.CalcIntrinsicGas(uint64(txn.DataLen), uint64(txn.DataNonZeroLen), 0, nil, txn.Creation, true, true, isShanghai)
gas, reason := txpoolcfg.CalcIntrinsicGas(uint64(txn.DataLen), uint64(txn.DataNonZeroLen), uint64(txn.AuthorizationLen), nil, txn.Creation, true, true, isShanghai)
if txn.Traced {
p.logger.Info(fmt.Sprintf("TX TRACING: validateTx intrinsic gas idHash=%x gas=%d", txn.IDHash, gas))
}
Expand Down Expand Up @@ -1056,6 +1071,31 @@ func (p *TxPool) isCancun() bool {
return activated
}

func (p *TxPool) isPrague() bool {
// once this flag has been set for the first time we no longer need to check the timestamp
set := p.isPostPrague.Load()
if set {
return true
}
if p.pragueTime == nil {
return false
}
pragueTime := *p.pragueTime

// a zero here means Prague is always active
if pragueTime == 0 {
p.isPostPrague.Swap(true)
return true
}

now := time.Now().Unix()
activated := uint64(now) >= pragueTime
if activated {
p.isPostPrague.Swap(true)
}
return activated
}

// Check that the serialized txn should not exceed a certain max size
func (p *TxPool) ValidateSerializedTxn(serializedTxn []byte) error {
const (
Expand Down
4 changes: 2 additions & 2 deletions erigon-lib/txpool/pool_fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ func FuzzOnNewBlocks(f *testing.F) {

cfg := txpoolcfg.DefaultConfig
sendersCache := kvcache.New(kvcache.DefaultCoherentConfig)
pool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, nil, nil, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
pool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, nil, nil, nil, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
assert.NoError(err)

err = pool.Start(ctx, db)
Expand Down Expand Up @@ -540,7 +540,7 @@ func FuzzOnNewBlocks(f *testing.F) {
check(p2pReceived, types.TxSlots{}, "after_flush")
checkNotify(p2pReceived, types.TxSlots{}, "after_flush")

p2, err := New(ch, coreDB, txpoolcfg.DefaultConfig, sendersCache, *u256.N1, nil, nil, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
p2, err := New(ch, coreDB, txpoolcfg.DefaultConfig, sendersCache, *u256.N1, nil, nil, nil, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
assert.NoError(err)

p2.senders = pool.senders // senders are not persisted
Expand Down
18 changes: 9 additions & 9 deletions erigon-lib/txpool/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestNonceFromAddress(t *testing.T) {

cfg := txpoolcfg.DefaultConfig
sendersCache := kvcache.New(kvcache.DefaultCoherentConfig)
pool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, nil, nil, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
pool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, nil, nil, nil, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
assert.NoError(err)
require.True(pool != nil)
ctx := context.Background()
Expand Down Expand Up @@ -173,7 +173,7 @@ func TestReplaceWithHigherFee(t *testing.T) {

cfg := txpoolcfg.DefaultConfig
sendersCache := kvcache.New(kvcache.DefaultCoherentConfig)
pool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, nil, nil, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
pool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, nil, nil, nil, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
assert.NoError(err)
require.NotEqual(nil, pool)
ctx := context.Background()
Expand Down Expand Up @@ -290,7 +290,7 @@ func TestReverseNonces(t *testing.T) {

cfg := txpoolcfg.DefaultConfig
sendersCache := kvcache.New(kvcache.DefaultCoherentConfig)
pool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, nil, nil, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
pool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, nil, nil, nil, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
assert.NoError(err)
require.True(pool != nil)
ctx := context.Background()
Expand Down Expand Up @@ -417,7 +417,7 @@ func TestTxPoke(t *testing.T) {

cfg := txpoolcfg.DefaultConfig
sendersCache := kvcache.New(kvcache.DefaultCoherentConfig)
pool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, nil, nil, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
pool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, nil, nil, nil, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
assert.NoError(err)
require.True(pool != nil)
ctx := context.Background()
Expand Down Expand Up @@ -705,7 +705,7 @@ func TestShanghaiValidateTx(t *testing.T) {
}

cache := &kvcache.DummyCache{}
pool, err := New(ch, coreDB, cfg, cache, *u256.N1, shanghaiTime, nil /* agraBlock */, nil /* cancunTime */, fixedgas.DefaultMaxBlobsPerBlock, nil, logger)
pool, err := New(ch, coreDB, cfg, cache, *u256.N1, shanghaiTime, nil /* agraBlock */, nil /* cancunTime */, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, logger)
asrt.NoError(err)
ctx := context.Background()
tx, err := coreDB.BeginRw(ctx)
Expand Down Expand Up @@ -751,7 +751,7 @@ func TestBlobTxReplacement(t *testing.T) {
db, coreDB := memdb.NewTestPoolDB(t), memdb.NewTestDB(t)
cfg := txpoolcfg.DefaultConfig
sendersCache := kvcache.New(kvcache.DefaultCoherentConfig)
pool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, common.Big0, nil, common.Big0, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
pool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, common.Big0, nil, common.Big0, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
assert.NoError(err)
require.True(pool != nil)
ctx := context.Background()
Expand Down Expand Up @@ -968,7 +968,7 @@ func TestDropRemoteAtNoGossip(t *testing.T) {
logger := log.New()
sendersCache := kvcache.New(kvcache.DefaultCoherentConfig)

txPool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, big.NewInt(0), big.NewInt(0), nil, fixedgas.DefaultMaxBlobsPerBlock, nil, logger)
txPool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, big.NewInt(0), big.NewInt(0), nil, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, logger)
assert.NoError(err)
require.True(txPool != nil)

Expand Down Expand Up @@ -1074,7 +1074,7 @@ func TestBlobSlots(t *testing.T) {
cfg.TotalBlobPoolLimit = 20

sendersCache := kvcache.New(kvcache.DefaultCoherentConfig)
pool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, common.Big0, nil, common.Big0, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
pool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, common.Big0, nil, common.Big0, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
assert.NoError(err)
require.True(pool != nil)
ctx := context.Background()
Expand Down Expand Up @@ -1148,7 +1148,7 @@ func TestGasLimitChanged(t *testing.T) {

cfg := txpoolcfg.DefaultConfig
sendersCache := kvcache.New(kvcache.DefaultCoherentConfig)
pool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, nil, nil, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
pool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, nil, nil, nil, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
assert.NoError(err)
require.True(pool != nil)
ctx := context.Background()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package txpooluitl
package txpoolutil

import (
"context"
Expand Down Expand Up @@ -140,8 +140,9 @@ func AllComponents(ctx context.Context, cfg txpoolcfg.Config, cache kvcache.Cach
agraBlock = chainConfig.Bor.GetAgraBlock()
}
cancunTime := chainConfig.CancunTime
pragueTime := chainConfig.PragueTime

txPool, err := txpool.New(newTxs, chainDB, cfg, cache, *chainID, shanghaiTime, agraBlock, cancunTime, maxBlobsPerBlock, feeCalculator, logger)
txPool, err := txpool.New(newTxs, chainDB, cfg, cache, *chainID, shanghaiTime, agraBlock, cancunTime, pragueTime, maxBlobsPerBlock, feeCalculator, logger)
if err != nil {
return nil, nil, nil, nil, nil, err
}
Expand Down
25 changes: 24 additions & 1 deletion erigon-lib/types/txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ type TxSlot struct {
Blobs [][]byte
Commitments []gokzg4844.KZGCommitment
Proofs []gokzg4844.KZGProof

// EIP-7702: set code tx
AuthorizationLen int
}

const (
Expand Down Expand Up @@ -185,7 +188,7 @@ func (ctx *TxParseContext) ParseTransaction(payload []byte, pos int, slot *TxSlo
// If it is non-legacy transaction, the transaction type follows, and then the list
if !legacy {
slot.Type = payload[p]
if slot.Type > BlobTxType {
if slot.Type > SetCodeTxType {
return 0, fmt.Errorf("%w: unknown transaction type: %d", ErrParseTxn, slot.Type)
}
p++
Expand Down Expand Up @@ -443,6 +446,26 @@ func (ctx *TxParseContext) parseTransactionBody(payload []byte, pos, p0 int, slo
}
p = dataPos + dataLen
}
if slot.Type == SetCodeTxType {
dataPos, dataLen, err = rlp.List(payload, p)
if err != nil {
return 0, fmt.Errorf("%w: authorizations len: %s", ErrParseTxn, err) //nolint
}
authPos := dataPos
var authLen int
for authPos < dataPos+dataLen {
authPos, authLen, err = rlp.List(payload, authPos)
if err != nil {
return 0, fmt.Errorf("%w: authorization: %s", ErrParseTxn, err) //nolint
}
slot.AuthorizationLen++
authPos += authLen
}
if authPos != dataPos+dataLen {
return 0, fmt.Errorf("%w: extraneous space in the authorizations", ErrParseTxn)
}
p = dataPos + dataLen
}
if slot.Type == BlobTxType {
p, err = rlp.U256(payload, p, &slot.BlobFeeCap)
if err != nil {
Expand Down
67 changes: 67 additions & 0 deletions erigon-lib/types/txn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,3 +292,70 @@ func TestBlobTxParsing(t *testing.T) {
assert.Equal(t, proof0, fatTx.Proofs[0])
assert.Equal(t, proof1, fatTx.Proofs[1])
}

func TestSetCodeTxParsing(t *testing.T) {
bodyRlxHex := "0x04f902b10188a804b97e55f1619888a08ae04b7dc9b296889262bfb381a9852c88c3ed5816717427719426b97a6e638930cd51d0482d4c3908e171c848ca88e7fcd96deec354e0b8b45c84e7ba97d4d60285eebbf3f7be79aed25dfe2a9f086c69c8ae152aa777b806f45ab602f4b354a6537154e24b4f6b85b58535726876fa885dba96b202417326bb4e4ba5e0bcccd9b4e4df6096401c19e7d38df3599157249a72ac3cf095c39cfde8d4233303823f5341ccaa9ebaf78cd8dd06ec61af9924df9a2f97d13c88ae737a017c914d21d3390984a6102c51293b3b2cec8214e6be2ee033ed4795f1158d9103c9ab5f50786729dd9baf395bb20c71456cf8d5f89b94f8032107975d3fbd90ffa74185a0cb5ab43afe85f884a037e36aea1770355c584876f969c7014017aa51a5e287c9679f4402d1a878b6e3a0be3cdb54e9c5fc3032535d262e6e9ce6a092e068ad0c95f19b4022c1111652b0a0562f7754a0c1d29acfbdaad8ae779125ccc6afec0ec1177056391479b25cee72a069a8be541415e284e16be88ecdb73d5e14ae0e0ade0db635a8d717b70d98293ef794cad5e3980e2d53db6d79d5e6821cff73bef01803e1a0415787a09d11b750dfd34dfe0868ab2c7e6bd8d7ef1a66720f2ea6c7f6e9bb01f8ccf201943d8b4362475b3d0504ccd9e63cddd351b88fa052c088832c50d9581133828864e3d39680cff14988237c283c57f04c54f201940e7ceefb1855e91bd085d85852b2a9df4f9da4f0c088a87ef261eb89b837882d717143b8cb5e718854d879dc9f18304ef2019477be91ff1fb94eb618aebb4d829e9f8eeec4301bc088343c738cf5c7f5b1880521e62bff507ec288ce2f51e36cb6d54ef20194c32daf3ad4597567184d790ab83d7bf34cf0e446c088c04ac61fbe29181988f8c0d967f0799fb988772265a4be2b26ab0188c91023f53ea594d7881c46b9feb3b7cbc6"
bodyRlx := hexutility.MustDecodeHex(bodyRlxHex)

hasEnvelope := false
ctx := NewTxParseContext(*uint256.NewInt(1))
ctx.withSender = false

var tx TxSlot
txType, err := PeekTransactionType(bodyRlx)
require.NoError(t, err)
assert.Equal(t, SetCodeTxType, txType)

_, err = ctx.ParseTransaction(bodyRlx, 0, &tx, nil, hasEnvelope, false, nil)
require.NoError(t, err)
assert.Equal(t, 4, tx.AuthorizationLen)
assert.Equal(t, SetCodeTxType, tx.Type)

// test empty authorizations
bodyRlxHex = "0x04f903420188db1b29114eba96ab887145908699cc1f3488987b96c0c55fced7886b85e4937b481442949a60a150fda306891ad7aff6d47584c8a0e1571788c5f7682286d452e0b9021164b57ad1f652639f5d44536f1b868437787082df48b3e2a684742d0eafcfda5336e7a958afb22ae57aad8e9a271528f9aa1f4a34e29491a8929732e22c04a438578b2b8510862572dd36b5304a9c3b6668b7c8f818be8411c07866ccb1fbe34586f80a1ace62753b918139acefc71f92d0c4679c0a56bb6c8ae38bc37a7ee8f348255c8ada95e842b52d4bd2b2447789a8543beda9f3bc8e27f28d51373ef9b1494c3d21adc6b0416444088ed08834eb5736d48566da000356bbcd7d78b118c39d15a56874fd254dcfcc172cd7a82e36621b964ebc54fdaa64de9e381b1545cfc7c4ea1cfccff829f0dfa395ef5f750b79689e5c8e3f6c7de9afe34d05f599dac8e3ae999f7acb32f788991425a7d8b36bf92a7dc14d913c3cc5854e580f48d507bf06018f3d012155791e1930791afccefe46f268b59e023ddacaf1e8278026a4c962f9b968f065e7c33d98d2aea49e8885ac77bfcc952e322c5e414cb5b4e7477829c0a4b8b0964fc28d202bca1b3bedca34f3fe12d62629b30a4764121440d0ea0f50f26579c486070d00309a44c14f6c3347c5d14b520eca8a399a1cd3c421f28ae5485e96b4c500a411754a78f558701d1a9788d22e6d2f02fefd1c45c2d427b518adda66a34432c3f94b4b3811e2d063dca2917f403033b0400e4e9dc3fd327b10a43a15229332596671d0392e501c39f43b23f814e95b093e981418091f9e2a32013ab8fa7a409d5636b52fded6f8d5f794de688ae4be9a54b20eb5366903223863de2bc895e1a0f5ecb3956919b8e9e9956c20c89b523e71c5803592c99871b7d5ee025e402941f89b94ae16863cc3bf6e6946f186d0f63d77343f81363ef884a0b09afe54c0376e3e3091473edb4e2bf43f08530356a2c9236bf373869b79c8d0a0ec2c57ca577173865f340a7cd13cf0051e52229722e3a529f851d4b74e315c8ca00bbe5f1a1ef2e5830d0c5cb8e93a05d4d29b4d7bf244ceea432888c4fbd5d5d5a0823b7ceaeba3a4cd70572c2ccc560d588ffeed638aec7c0cc364afa7dbf1c51cc0018818848492f65ca7bd88ea2017dc526fff7f"
bodyRlx = hexutility.MustDecodeHex(bodyRlxHex)
ctx = NewTxParseContext(*uint256.NewInt(1))
ctx.withSender = false
var tx2 TxSlot

txType, err = PeekTransactionType(bodyRlx)
require.NoError(t, err)
assert.Equal(t, SetCodeTxType, txType)

_, err = ctx.ParseTransaction(bodyRlx, 0, &tx2, nil, hasEnvelope, false, nil)
require.NoError(t, err)
assert.Equal(t, 0, tx2.AuthorizationLen)
assert.Equal(t, SetCodeTxType, tx2.Type)

// generated using this in encdec_test.go
/*
func TestGenerateSetCodeTxRlp(t *testing.T) {
tr := NewTRand()
var tx Transaction
requiredAuthLen := 0
for tx = tr.RandTransaction(); tx.Type() != types2.SetCodeTxType || len(tx.(*SetCodeTransaction).GetAuthorizations()) != requiredAuthLen; tx = tr.RandTransaction() {
}
v, _, _ := tx.RawSignatureValues()
v.SetUint64(uint64(randIntInRange(0, 2)))
tx.GetChainID().SetUint64(1)
for _, auth := range tx.(*SetCodeTransaction).GetAuthorizations() {
auth.ChainID.SetUint64(1)
auth.V.SetUint64(uint64(randIntInRange(0, 2)))
}
w := bytes.NewBuffer(nil)
if err := tx.MarshalBinary(w); err != nil {
t.Error(err)
}
hex := hexutility.Bytes(w.Bytes()).String()
//hex := libcommon.BytesToHash().Hex()
authj, err := json.Marshal(tx.(*SetCodeTransaction).GetAuthorizations())
if err != nil {
t.Error(err)
}
fmt.Println("tx", hex, len(tx.(*SetCodeTransaction).GetAuthorizations()), string(authj))
}
*/
}
4 changes: 2 additions & 2 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ import (
libstate "github.com/ledgerwatch/erigon-lib/state"
"github.com/ledgerwatch/erigon-lib/txpool"
"github.com/ledgerwatch/erigon-lib/txpool/txpoolcfg"
"github.com/ledgerwatch/erigon-lib/txpool/txpooluitl"
"github.com/ledgerwatch/erigon-lib/txpool/txpoolutil"
libtypes "github.com/ledgerwatch/erigon-lib/types"
"github.com/ledgerwatch/erigon-lib/wrap"
"github.com/ledgerwatch/erigon/cl/clparams"
Expand Down Expand Up @@ -627,7 +627,7 @@ func New(ctx context.Context, stack *node.Node, config *ethconfig.Config, logger

backend.newTxs = make(chan libtypes.Announcements, 1024)
//defer close(newTxs)
backend.txPoolDB, backend.txPool, backend.txPoolFetch, backend.txPoolSend, backend.txPoolGrpcServer, err = txpooluitl.AllComponents(
backend.txPoolDB, backend.txPool, backend.txPoolFetch, backend.txPoolSend, backend.txPoolGrpcServer, err = txpoolutil.AllComponents(
ctx, config.TxPool, kvcache.NewDummy(), backend.newTxs, backend.chainDB, backend.sentriesClient.Sentries(), stateDiffClient, misc.Eip1559FeeCalculator, logger,
)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion turbo/stages/mock/mock_sentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,9 @@ func MockWithEverything(tb testing.TB, gspec *types.Genesis, key *ecdsa.PrivateK
chainID, _ := uint256.FromBig(mock.ChainConfig.ChainID)
shanghaiTime := mock.ChainConfig.ShanghaiTime
cancunTime := mock.ChainConfig.CancunTime
pragueTime := mock.ChainConfig.PragueTime
maxBlobsPerBlock := mock.ChainConfig.GetMaxBlobsPerBlock()
mock.TxPool, err = txpool.New(newTxs, mock.DB, poolCfg, kvcache.NewDummy(), *chainID, shanghaiTime, nil /* agraBlock */, cancunTime, maxBlobsPerBlock, nil, logger)
mock.TxPool, err = txpool.New(newTxs, mock.DB, poolCfg, kvcache.NewDummy(), *chainID, shanghaiTime, nil /* agraBlock */, cancunTime, pragueTime, maxBlobsPerBlock, nil, logger)
if err != nil {
tb.Fatal(err)
}
Expand Down

0 comments on commit 1cabe82

Please sign in to comment.