Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fast adding transaction to pool, without recover address from public key #219

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
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
23 changes: 12 additions & 11 deletions zk/stages/stage_sequence_execute_transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/ledgerwatch/erigon/core/vm/evmtypes"
"github.com/ledgerwatch/erigon/zk/utils"
"github.com/ledgerwatch/log/v3"
"github.com/ledgerwatch/secp256k1"
)

func getNextPoolTransactions(ctx context.Context, cfg SequenceBlockCfg, executionAt, forkId uint64, alreadyYielded mapset.Set[[32]byte]) ([]types.Transaction, []common.Hash, bool, error) {
Expand Down Expand Up @@ -89,8 +88,8 @@ func extractTransactionsFromSlot(slot *types2.TxsRlp, currentHeight uint64, cfg
ids := make([]common.Hash, 0, len(slot.TxIds))
transactions := make([]types.Transaction, 0, len(slot.Txs))
toRemove := make([]common.Hash, 0)
signer := types.MakeSigner(cfg.chainConfig, currentHeight, 0)
cryptoContext := secp256k1.ContextForThread(1)
// signer := types.MakeSigner(cfg.chainConfig, currentHeight, 0)
// cryptoContext := secp256k1.ContextForThread(1)
for idx, txBytes := range slot.Txs {
transaction, err := types.DecodeTransaction(txBytes)
if err == io.EOF {
Expand All @@ -106,15 +105,17 @@ func extractTransactionsFromSlot(slot *types2.TxsRlp, currentHeight uint64, cfg
continue
}

var sender common.Address
copy(sender[:], slot.Senders.At(idx))
// now attempt to recover the sender
sender, err := signer.SenderWithContext(cryptoContext, transaction)
if err != nil {
log.Warn("[extractTransaction] Failed to recover sender from transaction, skipping and removing from pool",
"error", err,
"hash", transaction.Hash())
toRemove = append(toRemove, slot.TxIds[idx])
continue
}
// sender, err := signer.SenderWithContext(cryptoContext, transaction)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seams in some case, the tx will error.
We can execute concurrently in advance, before the for loop and remote the tx, then it will have the same function and better safety.

// if err != nil {
// log.Warn("[extractTransaction] Failed to recover sender from transaction, skipping and removing from pool",
// "error", err,
// "hash", transaction.Hash())
// toRemove = append(toRemove, slot.TxIds[idx])
// continue
// }

transaction.SetSender(sender)
transactions = append(transactions, transaction)
Expand Down
Loading