Skip to content

Commit

Permalink
fix: verifyTX on message attestation (#1218)
Browse files Browse the repository at this point in the history
# Related Github tickets

- #1857

# Background

Get the valset ID from the message public access data, set by pigeon.
Paloma uses this public access data when verifying the TX and get the
same valset as pigeon.

- Add valsetID as new field, instead of packing it into the
PublicAccessData data. This makes it more explicit and less error prone.
- When attesting SLC and UpdateValset messages we now get the same
valset as pigeon (which it gets from compass), instead of the latest
version store in paloma.
- Update the SetPublicAccessData so pigeon can set the valset ID.

# Testing completed

- [x] test coverage exists or has been added/updated
- [x] tested in a private testnet

# Breaking changes

- [x] I have checked my code for breaking changes
- [x] If there are breaking changes, there is a supporting migration.
  • Loading branch information
maharifu authored Jul 10, 2024
1 parent 56966af commit 1e19cf8
Show file tree
Hide file tree
Showing 12 changed files with 389 additions and 384 deletions.
1 change: 1 addition & 0 deletions proto/palomachain/paloma/consensus/consensus_queue.proto
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ message PublicAccessData {
bytes valAddress = 1 [ (gogoproto.casttype) =
"github.com/cosmos/cosmos-sdk/types.ValAddress" ];
bytes data = 2;
uint64 valsetID = 3;
}

message ErrorData {
Expand Down
1 change: 1 addition & 0 deletions proto/palomachain/paloma/consensus/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ message MessageWithSignatures {
bytes publicAccessData = 6;
bytes errorData = 7;
repeated Evidence evidence = 8;
uint64 valsetID = 9;
}

message QueryMessageByIDRequest {
Expand Down
1 change: 1 addition & 0 deletions proto/palomachain/paloma/consensus/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ message MsgSetPublicAccessData {
bytes data = 4;
palomachain.paloma.valset.MsgMetadata metadata = 5
[ (gogoproto.nullable) = false ];
uint64 valsetID = 6;
}

message MsgSetPublicAccessDataResponse {}
Expand Down
1 change: 1 addition & 0 deletions x/consensus/keeper/concensus_keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ func (k Keeper) SetMessagePublicAccessData(
payload := &types.PublicAccessData{
ValAddress: valAddr,
Data: msg.GetData(),
ValsetID: msg.GetValsetID(),
}
err = cq.SetPublicAccessData(sdkCtx, msg.GetMessageID(), payload)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions x/consensus/keeper/consensus/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,11 @@ func ToMessageWithSignatures(msg types.QueuedSignedMessageI, cdc codec.BinaryCod
}

var publicAccessData []byte
var valsetID uint64

if msg.GetPublicAccessData() != nil {
publicAccessData = msg.GetPublicAccessData().GetData()
valsetID = msg.GetPublicAccessData().GetValsetID()
}

var errorData []byte
Expand All @@ -491,6 +493,7 @@ func ToMessageWithSignatures(msg types.QueuedSignedMessageI, cdc codec.BinaryCod
BytesToSign: msg.GetBytesToSign(),
SignData: []*types.ValidatorSignature{},
PublicAccessData: publicAccessData,
ValsetID: valsetID,
ErrorData: errorData,
}
for _, signData := range msg.GetSignData() {
Expand Down
132 changes: 84 additions & 48 deletions x/consensus/types/consensus_queue.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1e19cf8

Please sign in to comment.