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

Unmarshalling perf #466

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

Unmarshalling perf #466

wants to merge 1 commit into from

Conversation

KonradStaniec
Copy link
Collaborator

Pr in spirit of - #441

Latest flamegraphs from load testing shown that, deserialzing btc transaction and signatures takes most time in code paths which retrieve a lot of delegations. This pr removes some unnecessary checks from db perspective.

This is not proper solution, but it can be some kind of stop-gap if we we would need around 20% perf boost (based on begin block benchmarks). It is also backward compatbile with current testnet and all the programs so this is easy gain.

Comment on lines 70 to 78
func (sig *BIP340Signature) Unmarshal(data []byte) error {
newSig := BIP340Signature(data)

// ensure that the bytes can be transformed to a *schnorr.Signature object
// this includes all format checks
_, err := newSig.ToBTCSig()
if err != nil {
return errors.New("bytes cannot be converted to a *schnorr.Signature object")
}

*sig = data
Copy link
Member

Choose a reason for hiding this comment

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

Given that we don't perform verification here, NewBIP340Signature won't perform any verification either. Since NewBIP340Signature will be the function that takes inputs from the external users, we need to move the verification removed here to NewBIP340Signature.

Comment on lines 172 to 174
_, err := m.UnbondingTxSig.ToBTCSig()

if err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
_, err := m.UnbondingTxSig.ToBTCSig()
if err != nil {
if _, err := m.UnbondingTxSig.ToBTCSig(); err != nil {

IIRC this is the practice recommended by Go. Same comments for other places in this file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants