fix message attestation for Solana

Change-Id: Iaf79984980affe64f268c2eed9f61d5058cea0dd
This commit is contained in:
Hendrik Hofstadt 2021-07-02 14:35:04 +02:00
parent b61c08208f
commit b85cbacd3b
4 changed files with 19 additions and 7 deletions

View File

@ -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.

View File

@ -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,
}

View File

@ -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
}

View File

@ -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
}
}