-
Notifications
You must be signed in to change notification settings - Fork 172
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
base: dev
Are you sure you want to change the base?
Unmarshalling perf #466
Conversation
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 |
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.
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
.
x/btcstaking/types/msg.go
Outdated
_, err := m.UnbondingTxSig.ToBTCSig() | ||
|
||
if err != nil { |
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.
_, 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
db0bcb9
to
3eaede2
Compare
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.