From 0152a001140775550222b22c0c7dcb3d752574c6 Mon Sep 17 00:00:00 2001 From: Leo Date: Fri, 20 Nov 2020 22:35:00 +0100 Subject: [PATCH] all: rename LockupObservation to SignedObservation We observe things other than lockups, account for it. --- bridge/cmd/guardiand/bridge.go | 2 +- bridge/pkg/p2p/p2p.go | 6 +++--- bridge/pkg/processor/broadcast.go | 4 ++-- bridge/pkg/processor/observation.go | 4 ++-- bridge/pkg/processor/processor.go | 4 ++-- proto/gossip/v1/gossip.proto | 16 +++++++++------- 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/bridge/cmd/guardiand/bridge.go b/bridge/cmd/guardiand/bridge.go index b6bb24e3..409d2b18 100644 --- a/bridge/cmd/guardiand/bridge.go +++ b/bridge/cmd/guardiand/bridge.go @@ -282,7 +282,7 @@ func runBridge(cmd *cobra.Command, args []string) { sendC := make(chan []byte) // Inbound observations - obsvC := make(chan *gossipv1.LockupObservation, 50) + obsvC := make(chan *gossipv1.SignedObservation, 50) // VAAs to submit to Solana solanaVaaC := make(chan *vaa.VAA) diff --git a/bridge/pkg/p2p/p2p.go b/bridge/pkg/p2p/p2p.go index 795cba5a..57c681e1 100644 --- a/bridge/pkg/p2p/p2p.go +++ b/bridge/pkg/p2p/p2p.go @@ -26,7 +26,7 @@ import ( "github.com/certusone/wormhole/bridge/pkg/supervisor" ) -func Run(obsvC chan *gossipv1.LockupObservation, +func Run(obsvC chan *gossipv1.SignedObservation, sendC chan []byte, priv crypto.PrivKey, port uint, @@ -228,8 +228,8 @@ func Run(obsvC chan *gossipv1.LockupObservation, logger.Debug("heartbeat received", zap.Any("value", m.Heartbeat), zap.String("from", envelope.GetFrom().String())) - case *gossipv1.GossipMessage_LockupObservation: - obsvC <- m.LockupObservation + case *gossipv1.GossipMessage_SignedObservation: + obsvC <- m.SignedObservation default: logger.Warn("received unknown message type (running outdated software?)", zap.Any("payload", msg.Message), diff --git a/bridge/pkg/processor/broadcast.go b/bridge/pkg/processor/broadcast.go index eaa9ba73..f3733e0b 100644 --- a/bridge/pkg/processor/broadcast.go +++ b/bridge/pkg/processor/broadcast.go @@ -18,13 +18,13 @@ func (p *Processor) broadcastSignature(v *vaa.VAA, signature []byte) { panic(err) } - obsv := gossipv1.LockupObservation{ + obsv := gossipv1.SignedObservation{ Addr: crypto.PubkeyToAddress(p.gk.PublicKey).Bytes(), Hash: digest.Bytes(), Signature: signature, } - w := gossipv1.GossipMessage{Message: &gossipv1.GossipMessage_LockupObservation{LockupObservation: &obsv}} + w := gossipv1.GossipMessage{Message: &gossipv1.GossipMessage_SignedObservation{SignedObservation: &obsv}} msg, err := proto.Marshal(&w) if err != nil { diff --git a/bridge/pkg/processor/observation.go b/bridge/pkg/processor/observation.go index 205ad809..4dcc505e 100644 --- a/bridge/pkg/processor/observation.go +++ b/bridge/pkg/processor/observation.go @@ -20,7 +20,7 @@ import ( // handleObservation processes a remote VAA observation, verifies it, checks whether the VAA has met quorum, // and assembles and submits a valid VAA if possible. -func (p *Processor) handleObservation(ctx context.Context, m *gossipv1.LockupObservation) { +func (p *Processor) handleObservation(ctx context.Context, m *gossipv1.SignedObservation) { // SECURITY: at this point, observations received from the p2p network are fully untrusted (all fields!) // // Note that observations are never tied to the (verified) p2p identity key - the p2p network @@ -66,7 +66,7 @@ func (p *Processor) handleObservation(ctx context.Context, m *gossipv1.LockupObs return } - // Hooray! Now, we have verified all fields on LockupObservation and know that it includes + // Hooray! Now, we have verified all fields on SignedObservation and know that it includes // a valid signature by an active guardian. We still don't fully trust them, as they may be // byzantine, but now we know who we're dealing with. diff --git a/bridge/pkg/processor/processor.go b/bridge/pkg/processor/processor.go index 67d1feaa..b16b0bff 100644 --- a/bridge/pkg/processor/processor.go +++ b/bridge/pkg/processor/processor.go @@ -46,7 +46,7 @@ type Processor struct { // sendC is a channel of outbound messages to broadcast on p2p sendC chan []byte // obsvC is a channel of inbound decoded observations from p2p - obsvC chan *gossipv1.LockupObservation + obsvC chan *gossipv1.SignedObservation // vaaC is a channel of VAAs to submit to store on Solana (either as target, or for data availability) vaaC chan *vaa.VAA @@ -86,7 +86,7 @@ func NewProcessor( lockC chan *common.ChainLock, setC chan *common.GuardianSet, sendC chan []byte, - obsvC chan *gossipv1.LockupObservation, + obsvC chan *gossipv1.SignedObservation, vaaC chan *vaa.VAA, injectC chan *vaa.VAA, gk *ecdsa.PrivateKey, diff --git a/proto/gossip/v1/gossip.proto b/proto/gossip/v1/gossip.proto index b0b3cec6..ce011c9a 100644 --- a/proto/gossip/v1/gossip.proto +++ b/proto/gossip/v1/gossip.proto @@ -7,7 +7,7 @@ option go_package = "proto/gossip/v1;gossipv1"; message GossipMessage { oneof message { Heartbeat heartbeat = 1; - LockupObservation lockup_observation = 2; + SignedObservation signed_observation = 2; } } @@ -31,18 +31,20 @@ message Heartbeat { // TODO: software version/release } -// A LockupObservation is a signed statement by a given guardian node -// that they observed a finalized lockup on a chain. +// A SignedObservation is a signed statement by a given guardian node +// that they observed a given event. // -// The lockup is uniquely identified by its hashed (tx_hash, nonce, values...) tuple. +// Observations always result from an external, final event being observed. +// Examples are lockups in finalized blocks on a block or guardian set changes +// injected by node operators after reaching off-chain consensus. +// +// The event is uniquely identified by its hashed (tx_hash, nonce, values...) tuple. // // Other nodes will verify the signature. Once any node has observed a quorum of // guardians submitting valid signatures for a given hash, they can be assembled into a VAA. // // Messages without valid signature are dropped unceremoniously. -// -// TODO: rename? we also use it for governance VAAs -message LockupObservation { +message SignedObservation { // Guardian pubkey as truncated eth address. bytes addr = 1; // The lockup's deterministic, unique hash.