-
Notifications
You must be signed in to change notification settings - Fork 45
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
preload sender and check for errors #1480
Conversation
# Conflicts: # zk/stages/stage_sequence_execute_transactions.go
copy(sender[:], slot.Senders.At(idx)) | ||
|
||
// now attempt to recover the sender | ||
sender, err := signer.SenderWithContext(cryptoContext, transaction) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pprof shows that this line takes 27% of total time. I run sequencer and benchmark
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sender, err := signer.SenderWithContext(cryptoContext, transaction)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related issue:
okx#211
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why attempt to recover sender from public key? there should be sender address in the transaction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sender always needs recovering at some point, it isn't part of the RLP for a transaction. Once decoded it is cached on the transaction but until then something needs to recover it.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use only 1 context for all transactions. This is sequential computation. Why not parallel?
Revert some changes made in 0xPolygonHermez#1480
@hexoscott @revitteth I want to know more background about this PR.
Some optimization ideas:
My draft PR just remove "recover sender address from public key" and read sender address from transaction slot. Sequencer can be 50% faster under our benchmark. |
The context for this change was that some chains were receiving spurious transactions that looked fine but the R,S,V values on the transaction would not allow for the sender to be recovered which caused an error. So, we pre-load the sender now and check for this error ahead of time to ensure this doesn't happen. We need to do it at this point in the process otherwise the transaction has already been added to the block and it's too late to do anything about it. Fixing the issue was the priority at the time, if there is degraded performance then I'll raise a new issue with your points above. |
No description provided.