Skip to content

Commit

Permalink
node/processor: Remove dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
tbjump authored and tbjump committed Aug 22, 2023
1 parent dcb7203 commit b780b3d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 63 deletions.
34 changes: 0 additions & 34 deletions node/pkg/processor/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/hex"

"github.com/certusone/wormhole/node/pkg/db"
"github.com/mr-tron/base58"

"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -95,39 +94,6 @@ func (p *Processor) handleMessage(ctx context.Context, k *common.MessagePublicat
return
}

// Ignore incoming observations when our database already has a quorum VAA for it.
// This can occur when we're receiving late observations due to node catchup, and
// processing those won't do us any good.
//
// Exception: if an observation is made within the settlement time (30s), we'll
// process it so other nodes won't consider it a miss.

if existing, err := p.getSignedVAA(*db.VaaIDFromVAA(&v.VAA)); err == nil {
if k.Timestamp.Sub(existing.Timestamp) > settlementTime {
p.logger.Info("ignoring observation since we already have a quorum VAA for it",
zap.Stringer("emitter_chain", k.EmitterChain),
zap.Stringer("emitter_address", k.EmitterAddress),
zap.String("emitter_address_b58", base58.Encode(k.EmitterAddress.Bytes())),
zap.Uint32("nonce", k.Nonce),
zap.Stringer("txhash", k.TxHash),
zap.String("txhash_b58", base58.Encode(k.TxHash.Bytes())),
zap.Time("timestamp", k.Timestamp),
zap.String("message_id", v.MessageID()),
zap.Duration("settlement_time", settlementTime),
)
return
}
} else if err != db.ErrVAANotFound {
p.logger.Error("failed to get VAA from db",
zap.Stringer("emitter_chain", k.EmitterChain),
zap.Stringer("emitter_address", k.EmitterAddress),
zap.Uint32("nonce", k.Nonce),
zap.Stringer("txhash", k.TxHash),
zap.Time("timestamp", k.Timestamp),
zap.Error(err),
)
}

// Generate digest of the unsigned VAA.
digest := v.SigningDigest()

Expand Down
29 changes: 0 additions & 29 deletions node/pkg/processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,32 +327,3 @@ func (p *Processor) haveSignedVAA(id db.VAAID) bool {

return ok
}

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]
if exists {
return ret.v, nil
}

return nil, db.ErrVAANotFound
}

if p.db == nil {
return nil, db.ErrVAANotFound
}

vb, err := p.db.GetSignedVAABytes(id)
if err != nil {
return nil, err
}

vaa, err := vaa.Unmarshal(vb)
if err != nil {
panic("failed to unmarshal VAA from db")
}

return vaa, err
}

0 comments on commit b780b3d

Please sign in to comment.