Node: Drop inbound signed vaas with quorum faster (#3150)
Change-Id: I1ec23694031ecf8474ca2d4da5280eef39dd8edb
This commit is contained in:
parent
7c8874d930
commit
c7ef120806
|
@ -227,6 +227,21 @@ func (p *Processor) handleInboundSignedVAAWithQuorum(ctx context.Context, m *gos
|
|||
return
|
||||
}
|
||||
|
||||
// Check if we already store this VAA
|
||||
_, err = p.getSignedVAA(*db.VaaIDFromVAA(v))
|
||||
if err == nil {
|
||||
p.logger.Debug("ignored SignedVAAWithQuorum message for VAA we already stored",
|
||||
zap.String("vaaID", string(db.VaaIDFromVAA(v).Bytes())),
|
||||
)
|
||||
return
|
||||
} else if err != db.ErrVAANotFound {
|
||||
p.logger.Error("failed to look up VAA in database",
|
||||
zap.String("vaaID", string(db.VaaIDFromVAA(v).Bytes())),
|
||||
zap.Error(err),
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
// Calculate digest for logging
|
||||
digest := v.SigningDigest()
|
||||
hash := hex.EncodeToString(digest.Bytes())
|
||||
|
@ -258,21 +273,6 @@ func (p *Processor) handleInboundSignedVAAWithQuorum(ctx context.Context, m *gos
|
|||
// - the signature's addresses match the node's current guardian set
|
||||
// - enough signatures are present for the VAA to reach quorum
|
||||
|
||||
// Check if we already store this VAA
|
||||
_, err = p.getSignedVAA(*db.VaaIDFromVAA(v))
|
||||
if err == nil {
|
||||
p.logger.Debug("ignored SignedVAAWithQuorum message for VAA we already store",
|
||||
zap.String("digest", hash),
|
||||
)
|
||||
return
|
||||
} else if err != db.ErrVAANotFound {
|
||||
p.logger.Error("failed to look up VAA in database",
|
||||
zap.String("digest", hash),
|
||||
zap.Error(err),
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
// Store signed VAA in database.
|
||||
p.logger.Info("storing inbound signed VAA with quorum",
|
||||
zap.String("digest", hash),
|
||||
|
|
|
@ -265,6 +265,7 @@ func (p *Processor) storeSignedVAA(v *vaa.VAA) error {
|
|||
}
|
||||
|
||||
func (p *Processor) getSignedVAA(id db.VAAID) (*vaa.VAA, error) {
|
||||
|
||||
if id.EmitterChain == vaa.ChainIDPythNet {
|
||||
key := fmt.Sprintf("%v/%v", id.EmitterAddress, id.Sequence)
|
||||
ret, exists := p.pythnetVaas[key]
|
||||
|
@ -275,6 +276,10 @@ func (p *Processor) getSignedVAA(id db.VAAID) (*vaa.VAA, error) {
|
|||
return nil, db.ErrVAANotFound
|
||||
}
|
||||
|
||||
if p.db == nil {
|
||||
return nil, db.ErrVAANotFound
|
||||
}
|
||||
|
||||
vb, err := p.db.GetSignedVAABytes(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
Loading…
Reference in New Issue