Skip to content
This repository has been archived by the owner on Sep 23, 2023. It is now read-only.

Txpool upgrades for EIP-4844 Blob Transactions #1075

Merged
merged 32 commits into from
Sep 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
52eceb6
Ref comments
somnathb1 Aug 9, 2023
3bbd725
Improve txn replacement for blobgs in txpool
somnathb1 Aug 11, 2023
64b51a6
A few comments
somnathb1 Aug 11, 2023
f5c99a1
Merge remote-tracking branch 'origin/main' into txpool-4844-upgrades
somnathb1 Aug 11, 2023
af8ddd6
Merge branch 'main' into txpool-4844-upgrades
somnathb1 Aug 16, 2023
39a589d
Fix broadcast issue
somnathb1 Aug 18, 2023
860701b
Fix broadcast issue
somnathb1 Aug 18, 2023
2bf894b
Add some docs
somnathb1 Aug 23, 2023
566b7e0
Merge branch 'txpool-fix' into txpool-4844-upgrades
somnathb1 Aug 23, 2023
0744516
Remove always true condition
somnathb1 Aug 31, 2023
7d30d2a
Dont remove blobtx from mined + add docs
somnathb1 Aug 31, 2023
f61ab90
Add docs
somnathb1 Aug 31, 2023
1d68059
Add docs
somnathb1 Aug 31, 2023
ecf4bcc
no nonce-gapped blob txn + don't remove mined blob
somnathb1 Sep 1, 2023
ab63277
rename torquem-ch project
AskAlexSharov Aug 24, 2023
4393291
move mdbx to new org (#1083)
AskAlexSharov Aug 24, 2023
1d9df4b
Update interfaces
somnathb1 Sep 3, 2023
85fd474
Add blob mined cache
somnathb1 Sep 3, 2023
b0e38e9
Update go mod
somnathb1 Sep 3, 2023
f1780a5
Merge branch 'main' into txpool-4844-upgrades
somnathb1 Sep 3, 2023
1be7d10
update interfaces
somnathb1 Sep 4, 2023
fe29df2
Wire finalized block
somnathb1 Sep 4, 2023
5500ce8
Merge branch 'main' into txpool-4844-upgrades
somnathb1 Sep 4, 2023
aa8833d
Merge main
somnathb1 Sep 6, 2023
f5247d1
add blob spammer count
somnathb1 Sep 6, 2023
a08b3ed
fmt
somnathb1 Sep 6, 2023
c8ccfcb
Reduce SyncToNewPeersEvery
somnathb1 Sep 6, 2023
e7e02dd
Merge branch 'main' into txpool-4844-upgrades
somnathb1 Sep 6, 2023
4aff903
Doc update
somnathb1 Sep 7, 2023
0d4500d
Refactor
somnathb1 Sep 8, 2023
3ab47bb
Remove unnecessary convert
somnathb1 Sep 8, 2023
8597433
Fix nonce in blob test
somnathb1 Sep 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo=
somnathb1 marked this conversation as resolved.
Show resolved Hide resolved
google.golang.org/genproto v0.0.0-20230526161137-0005af68ea54 h1:9NWlQfY2ePejTmfwUH1OWwmznFa+0kKcHGPDvcPza9M=
379 changes: 195 additions & 184 deletions gointerfaces/remote/kv.pb.go

Large diffs are not rendered by default.

62 changes: 43 additions & 19 deletions txpool/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ func (f *Fetch) handleInboundMessage(ctx context.Context, req *sentry.InboundMes
unknownHashes = append(unknownHashes, hashes[i:i+32]...)
}
}

if len(unknownHashes) > 0 {
var encodedRequest []byte
var messageID sentry.MessageId
Expand All @@ -284,30 +285,24 @@ func (f *Fetch) handleInboundMessage(ctx context.Context, req *sentry.InboundMes
//TODO: handleInboundMessage is single-threaded - means it can accept as argument couple buffers (or analog of txParseContext). Protobuf encoding will copy data anyway, but DirectClient doesn't
var encodedRequest []byte
var messageID sentry.MessageId
switch req.Id {
case sentry.MessageId_GET_POOLED_TRANSACTIONS_66:
messageID = sentry.MessageId_POOLED_TRANSACTIONS_66
requestID, hashes, _, err := types2.ParseGetPooledTransactions66(req.Data, 0, nil)
messageID = sentry.MessageId_POOLED_TRANSACTIONS_66
requestID, hashes, _, err := types2.ParseGetPooledTransactions66(req.Data, 0, nil)
if err != nil {
return err
}
_ = requestID
var txs [][]byte
for i := 0; i < len(hashes); i += 32 {
txn, err := f.pool.GetRlp(tx, hashes[i:i+32])
if err != nil {
return err
}
_ = requestID
var txs [][]byte
for i := 0; i < len(hashes); i += 32 {
txn, err := f.pool.GetRlp(tx, hashes[i:i+32])
if err != nil {
return err
}
if txn == nil {
continue
}
txs = append(txs, txn)
if txn == nil {
continue
}

encodedRequest = types2.EncodePooledTransactions66(txs, requestID, nil)
default:
return fmt.Errorf("unexpected message: %s", req.Id.String())
txs = append(txs, txn)
}
encodedRequest = types2.EncodePooledTransactions66(txs, requestID, nil)

if _, err := sentryClient.SendMessageById(f.ctx, &sentry.SendMessageByIdRequest{
Data: &sentry.OutboundMessageData{Id: messageID, Data: encodedRequest},
Expand Down Expand Up @@ -452,6 +447,11 @@ func (f *Fetch) handleStateChanges(ctx context.Context, client StateChangesClien
if err != nil {
return err
}
tx, err := f.db.BeginRo(ctx)
if err != nil {
return err
}
defer tx.Rollback()
for req, err := stream.Recv(); ; req, err = stream.Recv() {
if err != nil {
return err
Expand Down Expand Up @@ -481,6 +481,12 @@ func (f *Fetch) handleStateChanges(ctx context.Context, client StateChangesClien
unwindTxs.Txs[i] = &types2.TxSlot{}
if err = f.threadSafeParseStateChangeTxn(func(parseContext *types2.TxParseContext) error {
_, err = parseContext.ParseTransaction(change.Txs[i], 0, unwindTxs.Txs[i], unwindTxs.Senders.At(i), false /* hasEnvelope */, false /* wrappedWithBlobs */, nil)
if unwindTxs.Txs[i].Type == types2.BlobTxType {
somnathb1 marked this conversation as resolved.
Show resolved Hide resolved
knownBlobTxn := f.pool.GetKnownBlobTxn(tx, unwindTxs.Txs[i].IDHash[:])
if knownBlobTxn != nil {
unwindTxs.Txs[i] = knownBlobTxn.Tx
}
}
return err
}); err != nil && !errors.Is(err, context.Canceled) {
f.logger.Warn("stream.Recv", "err", err)
Expand All @@ -501,3 +507,21 @@ func (f *Fetch) handleStateChanges(ctx context.Context, client StateChangesClien
}
}
}

// func (f *Fetch) requestUnknownTxs(unknownHashes types2.Hashes, sentryClient sentry.SentryClient, PeerId *types.H512) error{
// if len(unknownHashes) > 0 {
// var encodedRequest []byte
// var err error
// var messageID sentry.MessageId
// if encodedRequest, err = types2.EncodeGetPooledTransactions66(unknownHashes, uint64(1), nil); err != nil {
// return err
// }
// messageID = sentry.MessageId_GET_POOLED_TRANSACTIONS_66
// if _, err := sentryClient.SendMessageById(f.ctx, &sentry.SendMessageByIdRequest{
// Data: &sentry.OutboundMessageData{Id: messageID, Data: encodedRequest},
// PeerId: PeerId,
// }, &grpc.EmptyCallOption{}); err != nil {
// return err
// }
// }
// }
53 changes: 53 additions & 0 deletions txpool/mocks_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading