forked from palomachain/paloma
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add legacy skyway message (#1234)
# Related Github tickets - Closes #1921 # Background We need these messages to be registered so they can be correctly unmarshalled, both on genesis import/export, as well as pruning the skyway attestation queue. # 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
Showing
4 changed files
with
737 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
syntax = "proto3"; | ||
package palomachain.paloma.skyway; | ||
|
||
import "cosmos/msg/v1/msg.proto"; | ||
import "gogoproto/gogo.proto"; | ||
import "palomachain/paloma/valset/common.proto"; | ||
|
||
option go_package = "github.com/palomachain/paloma/x/skyway/types"; | ||
|
||
// This message was renamed to `MsgBatchSendToRemoteClaim`. However, since we | ||
// already had some messages in the skyway attestation queue, we now get errors | ||
// on genesis import and when trying to prune the queue. | ||
// The queue only keeps the latest 1000 events, so we can remove this file once | ||
// the messages are rotated out. | ||
message MsgBatchSendToEthClaim { | ||
option (cosmos.msg.v1.signer) = "metadata"; | ||
uint64 event_nonce = 1; | ||
uint64 eth_block_height = 2; | ||
uint64 batch_nonce = 3; | ||
string token_contract = 4; | ||
string chain_reference_id = 5; | ||
string orchestrator = 6; | ||
palomachain.paloma.valset.MsgMetadata metadata = 7 | ||
[ (gogoproto.nullable) = false ]; | ||
uint64 skyway_nonce = 8; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package types | ||
|
||
import ( | ||
fmt "fmt" | ||
|
||
sdkerrors "cosmossdk.io/errors" | ||
"github.com/cometbft/cometbft/crypto/tmhash" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/palomachain/paloma/util/libmeta" | ||
) | ||
|
||
var _ sdk.Msg = &MsgBatchSendToEthClaim{} | ||
|
||
var _ EthereumClaim = &MsgBatchSendToEthClaim{} | ||
|
||
func (msg *MsgBatchSendToEthClaim) SetOrchestrator(orchestrator sdk.AccAddress) { | ||
msg.Orchestrator = orchestrator.String() | ||
} | ||
|
||
// GetType returns the claim type | ||
func (msg *MsgBatchSendToEthClaim) GetType() ClaimType { | ||
return CLAIM_TYPE_BATCH_SEND_TO_ETH | ||
} | ||
|
||
// ValidateBasic performs stateless checks | ||
func (e *MsgBatchSendToEthClaim) ValidateBasic() error { | ||
if err := libmeta.ValidateBasic(e); err != nil { | ||
return err | ||
} | ||
if e.EventNonce == 0 { | ||
return fmt.Errorf("event_nonce == 0") | ||
} | ||
if e.SkywayNonce == 0 { | ||
return fmt.Errorf("skyway_nonce == 0") | ||
} | ||
if e.BatchNonce == 0 { | ||
return fmt.Errorf("batch_nonce == 0") | ||
} | ||
if err := ValidateEthAddress(e.TokenContract); err != nil { | ||
return sdkerrors.Wrap(err, "erc20 token") | ||
} | ||
return nil | ||
} | ||
|
||
// Hash implements WithdrawBatch.Hash | ||
func (msg *MsgBatchSendToEthClaim) ClaimHash() ([]byte, error) { | ||
path := fmt.Sprintf("%d/%d/%d/%s", msg.SkywayNonce, msg.EthBlockHeight, msg.BatchNonce, msg.TokenContract) | ||
return tmhash.Sum([]byte(path)), nil | ||
} | ||
|
||
func (msg MsgBatchSendToEthClaim) GetClaimer() sdk.AccAddress { | ||
err := msg.ValidateBasic() | ||
if err != nil { | ||
panic(fmt.Errorf("MsgBatchSendToEthClaim failed ValidateBasic! Should have been handled earlier: %v", err)) | ||
} | ||
val, err := sdk.AccAddressFromBech32(msg.Orchestrator) | ||
if err != nil { | ||
panic(fmt.Errorf("Invalid orchestrator: %v", err)) | ||
} | ||
return val | ||
} | ||
|
||
// GetSigners defines whose signature is required | ||
func (msg MsgBatchSendToEthClaim) GetSigners() []sdk.AccAddress { | ||
return libmeta.GetSigners(&msg) | ||
} | ||
|
||
// Route should return the name of the module | ||
func (msg MsgBatchSendToEthClaim) Route() string { return RouterKey } | ||
|
||
// Type should return the action | ||
func (msg MsgBatchSendToEthClaim) Type() string { return "batch_send_to_eth_claim" } |
Oops, something went wrong.