Browse Source

fix message attestation for Solana

Change-Id: Iaf79984980affe64f268c2eed9f61d5058cea0dd
Hendrik Hofstadt 4 years ago
parent
commit
b85cbacd3b

+ 3 - 2
bridge/pkg/processor/message.go

@@ -22,14 +22,14 @@ var (
 			Name: "wormhole_lockups_observed_total",
 			Help: "Total number of lockups received on-chain",
 		},
-		[]string{"source_chain", "target_chain"})
+		[]string{"emitter_chain"})
 
 	lockupsSignedTotal = prometheus.NewCounterVec(
 		prometheus.CounterOpts{
 			Name: "wormhole_lockups_signed_total",
 			Help: "Total number of lockups that were successfully signed",
 		},
-		[]string{"source_chain", "target_chain"})
+		[]string{"emitter_chain"})
 )
 
 func init() {
@@ -64,6 +64,7 @@ func (p *Processor) handleLockup(ctx context.Context, k *common.MessagePublicati
 		EmitterChain:     k.EmitterChain,
 		EmitterAddress:   k.EmitterAddress,
 		Payload:          k.Payload,
+		Sequence:         k.Sequence,
 	}
 
 	// Generate digest of the unsigned VAA.

+ 4 - 0
bridge/pkg/processor/observation.go

@@ -208,6 +208,10 @@ func (p *Processor) handleObservation(ctx context.Context, m *gossipv1.SignedObs
 			GuardianSetIndex: v.GuardianSetIndex,
 			Signatures:       sigs,
 			Timestamp:        v.Timestamp,
+			Nonce:            v.Nonce,
+			Sequence:         v.Sequence,
+			EmitterChain:     v.EmitterChain,
+			EmitterAddress:   v.EmitterAddress,
 			Payload:          v.Payload,
 		}
 

+ 11 - 4
bridge/pkg/solana/client.go

@@ -114,10 +114,16 @@ func (s *SolanaWatcher) Run(ctx context.Context) error {
 						Filters: []rpc.RPCFilter{
 							{
 								Memcmp: &rpc.RPCFilterMemcmp{
-									Offset: 0,                            // Offset of VaaTime
+									Offset: 0,                            // Start of the account
 									Bytes:  solana.Base58{'m', 's', 'g'}, // Prefix of the posted message accounts
 								},
 							},
+							{
+								Memcmp: &rpc.RPCFilterMemcmp{
+									Offset: 4,                         // Offset of VaaTime
+									Bytes:  solana.Base58{0, 0, 0, 0}, // This means this VAA hasn't been signed yet
+								},
+							},
 						},
 					})
 					queryLatency.WithLabelValues("get_program_accounts").Observe(time.Since(start).Seconds())
@@ -158,7 +164,7 @@ func (s *SolanaWatcher) Run(ctx context.Context) error {
 							Timestamp:      time.Unix(int64(proposal.SubmissionTime), 0),
 							Nonce:          proposal.Nonce,
 							Sequence:       proposal.Sequence,
-							EmitterChain:   proposal.EmitterChain,
+							EmitterChain:   vaa.ChainIDSolana,
 							EmitterAddress: proposal.EmitterAddress,
 							Payload:        proposal.Payload,
 						}
@@ -188,7 +194,7 @@ type (
 		SubmissionTime      uint32
 		Nonce               uint32
 		Sequence            uint64
-		EmitterChain        vaa.ChainID
+		EmitterChain        uint16
 		EmitterAddress      vaa.Address
 		Payload             []byte
 	}
@@ -196,7 +202,8 @@ type (
 
 func ParseTransferOutProposal(data []byte) (*MessagePublicationAccount, error) {
 	prop := &MessagePublicationAccount{}
-	if err := borsh.Deserialize(prop, data); err != nil {
+	// Skip the b"msg" prefix
+	if err := borsh.Deserialize(prop, data[3:]); err != nil {
 		return nil, err
 	}
 

+ 1 - 1
solana/bridge/program/src/types.rs

@@ -188,7 +188,7 @@ pub struct PostedMessageData {
 impl Owned for PostedMessage {
     fn owner(&self) -> AccountOwner {
         AccountOwner::Other(
-            Pubkey::from_str("96RHG3mfcckmrYN1UhmJzyS1XX3fZKbkeUcpJe9Sy3FE").unwrap(),
+            Pubkey::from_str("Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o").unwrap(),
         ) // TODO key of the bridge
     }
 }