wormchain: add upgrade vaa and upgrade handler. Removes set params vaa. (#3292)
* Add chain upgrade vaa and upgrade handler. Removes set params vaa. * Update node package * Fix vaa payload test
This commit is contained in:
parent
0dcc53cbf8
commit
6b3819cc41
|
@ -48,6 +48,8 @@ var wormchainMigrateContractInstantiationMsg *string
|
||||||
var wormchainWasmInstantiateAllowlistCodeId *string
|
var wormchainWasmInstantiateAllowlistCodeId *string
|
||||||
var wormchainWasmInstantiateAllowlistContractAddress *string
|
var wormchainWasmInstantiateAllowlistContractAddress *string
|
||||||
|
|
||||||
|
var gatewayScheduleUpgradeName *string
|
||||||
|
var gatewayScheduleUpgradeHeight *string
|
||||||
var gatewayIbcComposabilityMwContractAddress *string
|
var gatewayIbcComposabilityMwContractAddress *string
|
||||||
|
|
||||||
var ibcUpdateChannelChainTargetChainId *string
|
var ibcUpdateChannelChainTargetChainId *string
|
||||||
|
@ -138,6 +140,16 @@ func init() {
|
||||||
AdminClientGatewayIbcComposabilityMwSetContractCmd.Flags().AddFlagSet(gatewayIbcComposabilityMwFlagSet)
|
AdminClientGatewayIbcComposabilityMwSetContractCmd.Flags().AddFlagSet(gatewayIbcComposabilityMwFlagSet)
|
||||||
TemplateCmd.AddCommand(AdminClientGatewayIbcComposabilityMwSetContractCmd)
|
TemplateCmd.AddCommand(AdminClientGatewayIbcComposabilityMwSetContractCmd)
|
||||||
|
|
||||||
|
// flags for the gateway-schedule-upgrade command
|
||||||
|
gatewayScheduleUpgradeFlagSet := pflag.NewFlagSet("gateway-schedule-upgrade", pflag.ExitOnError)
|
||||||
|
gatewayScheduleUpgradeName = gatewayScheduleUpgradeFlagSet.String("name", "", "Scheduled upgrade name")
|
||||||
|
gatewayScheduleUpgradeHeight = gatewayScheduleUpgradeFlagSet.String("height", "", "Scheduled upgrade height")
|
||||||
|
AdminClientGatewayScheduleUpgradeCmd.Flags().AddFlagSet(gatewayScheduleUpgradeFlagSet)
|
||||||
|
TemplateCmd.AddCommand(AdminClientGatewayScheduleUpgradeCmd)
|
||||||
|
|
||||||
|
// AdminClientGatewayCancelUpgradeCmd doesn't have any flags
|
||||||
|
TemplateCmd.AddCommand(AdminClientGatewayCancelUpgradeCmd)
|
||||||
|
|
||||||
// flags for the ibc-receiver-update-channel-chain and ibc-translator-update-channel-chain commands
|
// flags for the ibc-receiver-update-channel-chain and ibc-translator-update-channel-chain commands
|
||||||
ibcUpdateChannelChainFlagSet := pflag.NewFlagSet("ibc-mapping", pflag.ExitOnError)
|
ibcUpdateChannelChainFlagSet := pflag.NewFlagSet("ibc-mapping", pflag.ExitOnError)
|
||||||
ibcUpdateChannelChainTargetChainId = ibcUpdateChannelChainFlagSet.String("target-chain-id", "", "Target Chain ID for the governance VAA")
|
ibcUpdateChannelChainTargetChainId = ibcUpdateChannelChainFlagSet.String("target-chain-id", "", "Target Chain ID for the governance VAA")
|
||||||
|
@ -147,9 +159,6 @@ func init() {
|
||||||
AdminClientIbcTranslatorUpdateChannelChainCmd.Flags().AddFlagSet(ibcUpdateChannelChainFlagSet)
|
AdminClientIbcTranslatorUpdateChannelChainCmd.Flags().AddFlagSet(ibcUpdateChannelChainFlagSet)
|
||||||
TemplateCmd.AddCommand(AdminClientIbcReceiverUpdateChannelChainCmd)
|
TemplateCmd.AddCommand(AdminClientIbcReceiverUpdateChannelChainCmd)
|
||||||
TemplateCmd.AddCommand(AdminClientIbcTranslatorUpdateChannelChainCmd)
|
TemplateCmd.AddCommand(AdminClientIbcTranslatorUpdateChannelChainCmd)
|
||||||
|
|
||||||
// AdminClientGatewaySetTokenfactoryPfmDefaultParamsCmd doesn't have any flags
|
|
||||||
TemplateCmd.AddCommand(AdminClientGatewaySetTokenfactoryPfmDefaultParamsCmd)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var TemplateCmd = &cobra.Command{
|
var TemplateCmd = &cobra.Command{
|
||||||
|
@ -229,18 +238,24 @@ var AdminClientWormchainDeleteWasmInstantiateAllowlistCmd = &cobra.Command{
|
||||||
Run: runWormchainDeleteWasmInstantiateAllowlistTemplate,
|
Run: runWormchainDeleteWasmInstantiateAllowlistTemplate,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var AdminClientGatewayScheduleUpgradeCmd = &cobra.Command{
|
||||||
|
Use: "gateway-schedule-upgrade",
|
||||||
|
Short: "Schedule an upgrade on Gateway with a specified name for a specified height",
|
||||||
|
Run: runGatewayScheduleUpgradeTemplate,
|
||||||
|
}
|
||||||
|
|
||||||
|
var AdminClientGatewayCancelUpgradeCmd = &cobra.Command{
|
||||||
|
Use: "gateway-cancel-upgrade",
|
||||||
|
Short: "Cancel a scheduled upgrade on Gateway",
|
||||||
|
Run: runGatewayCancelUpgradeTemplate,
|
||||||
|
}
|
||||||
|
|
||||||
var AdminClientGatewayIbcComposabilityMwSetContractCmd = &cobra.Command{
|
var AdminClientGatewayIbcComposabilityMwSetContractCmd = &cobra.Command{
|
||||||
Use: "gateway-ibc-composability-mw-set-contract",
|
Use: "gateway-ibc-composability-mw-set-contract",
|
||||||
Short: "Set the contract that the IBC Composability middleware will query",
|
Short: "Set the contract that the IBC Composability middleware will query",
|
||||||
Run: runGatewayIbcComposabilityMwSetContractTemplate,
|
Run: runGatewayIbcComposabilityMwSetContractTemplate,
|
||||||
}
|
}
|
||||||
|
|
||||||
var AdminClientGatewaySetTokenfactoryPfmDefaultParamsCmd = &cobra.Command{
|
|
||||||
Use: "gateway-set-tokenfactory-pfm-default-params",
|
|
||||||
Short: "Generate an empty gateway set tokenfactory pfm default params template at specified path",
|
|
||||||
Run: runGatewaySetTokenfactoryPfmDefaultParamsTemplate,
|
|
||||||
}
|
|
||||||
|
|
||||||
var AdminClientIbcReceiverUpdateChannelChainCmd = &cobra.Command{
|
var AdminClientIbcReceiverUpdateChannelChainCmd = &cobra.Command{
|
||||||
Use: "ibc-receiver-update-channel-chain",
|
Use: "ibc-receiver-update-channel-chain",
|
||||||
Short: "Generate an empty ibc receiver channelId to chainId mapping update template at specified path",
|
Short: "Generate an empty ibc receiver channelId to chainId mapping update template at specified path",
|
||||||
|
@ -683,6 +698,62 @@ func runWormchainWasmInstantiateAllowlistTemplate(action nodev1.WormchainWasmIns
|
||||||
fmt.Print(string(b))
|
fmt.Print(string(b))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func runGatewayScheduleUpgradeTemplate(cmd *cobra.Command, args []string) {
|
||||||
|
if *gatewayScheduleUpgradeName == "" {
|
||||||
|
log.Fatal("--name must be specified")
|
||||||
|
}
|
||||||
|
|
||||||
|
if *gatewayScheduleUpgradeHeight == "" {
|
||||||
|
log.Fatal("--height must be specified")
|
||||||
|
}
|
||||||
|
|
||||||
|
height, err := strconv.ParseUint(*gatewayScheduleUpgradeHeight, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("failed to parse height as uint64: ", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
m := &nodev1.InjectGovernanceVAARequest{
|
||||||
|
CurrentSetIndex: uint32(*templateGuardianIndex),
|
||||||
|
Messages: []*nodev1.GovernanceMessage{
|
||||||
|
{
|
||||||
|
Sequence: rand.Uint64(),
|
||||||
|
Nonce: rand.Uint32(),
|
||||||
|
Payload: &nodev1.GovernanceMessage_GatewayScheduleUpgrade{
|
||||||
|
GatewayScheduleUpgrade: &nodev1.GatewayScheduleUpgrade{
|
||||||
|
Name: *gatewayScheduleUpgradeName,
|
||||||
|
Height: height,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
fmt.Print(string(b))
|
||||||
|
}
|
||||||
|
|
||||||
|
func runGatewayCancelUpgradeTemplate(cmd *cobra.Command, args []string) {
|
||||||
|
m := &nodev1.InjectGovernanceVAARequest{
|
||||||
|
CurrentSetIndex: uint32(*templateGuardianIndex),
|
||||||
|
Messages: []*nodev1.GovernanceMessage{
|
||||||
|
{
|
||||||
|
Sequence: rand.Uint64(),
|
||||||
|
Nonce: rand.Uint32(),
|
||||||
|
Payload: &nodev1.GovernanceMessage_GatewayCancelUpgrade{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
fmt.Print(string(b))
|
||||||
|
}
|
||||||
|
|
||||||
func runGatewayIbcComposabilityMwSetContractTemplate(cmd *cobra.Command, args []string) {
|
func runGatewayIbcComposabilityMwSetContractTemplate(cmd *cobra.Command, args []string) {
|
||||||
if *gatewayIbcComposabilityMwContractAddress == "" {
|
if *gatewayIbcComposabilityMwContractAddress == "" {
|
||||||
log.Fatal("--contract-address must be specified")
|
log.Fatal("--contract-address must be specified")
|
||||||
|
@ -710,27 +781,6 @@ func runGatewayIbcComposabilityMwSetContractTemplate(cmd *cobra.Command, args []
|
||||||
fmt.Print(string(b))
|
fmt.Print(string(b))
|
||||||
}
|
}
|
||||||
|
|
||||||
func runGatewaySetTokenfactoryPfmDefaultParamsTemplate(cmd *cobra.Command, args []string) {
|
|
||||||
m := &nodev1.InjectGovernanceVAARequest{
|
|
||||||
CurrentSetIndex: uint32(*templateGuardianIndex),
|
|
||||||
Messages: []*nodev1.GovernanceMessage{
|
|
||||||
{
|
|
||||||
Sequence: rand.Uint64(),
|
|
||||||
Nonce: rand.Uint32(),
|
|
||||||
Payload: &nodev1.GovernanceMessage_GatewaySetTokenfactoryPfmDefaultParams{
|
|
||||||
GatewaySetTokenfactoryPfmDefaultParams: &nodev1.GatewaySetTokenfactoryPfmDefaultParams{},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
fmt.Print(string(b))
|
|
||||||
}
|
|
||||||
|
|
||||||
func runIbcReceiverUpdateChannelChainTemplate(cmd *cobra.Command, args []string) {
|
func runIbcReceiverUpdateChannelChainTemplate(cmd *cobra.Command, args []string) {
|
||||||
runIbcUpdateChannelChainTemplate(nodev1.IbcUpdateChannelChainModule_IBC_UPDATE_CHANNEL_CHAIN_MODULE_RECEIVER)
|
runIbcUpdateChannelChainTemplate(nodev1.IbcUpdateChannelChainModule_IBC_UPDATE_CHANNEL_CHAIN_MODULE_RECEIVER)
|
||||||
}
|
}
|
||||||
|
|
|
@ -338,6 +338,34 @@ func wormchainWasmInstantiateAllowlist(
|
||||||
return v, nil
|
return v, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func gatewayScheduleUpgrade(
|
||||||
|
req *nodev1.GatewayScheduleUpgrade,
|
||||||
|
timestamp time.Time,
|
||||||
|
guardianSetIndex uint32,
|
||||||
|
nonce uint32,
|
||||||
|
sequence uint64,
|
||||||
|
) (*vaa.VAA, error) { //nolint:unparam // error is always nil but kept to mirror function signature of other functions
|
||||||
|
v := vaa.CreateGovernanceVAA(timestamp, nonce, sequence, guardianSetIndex, vaa.BodyGatewayScheduleUpgrade{
|
||||||
|
Name: req.Name,
|
||||||
|
Height: req.Height,
|
||||||
|
}.Serialize())
|
||||||
|
|
||||||
|
return v, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func gatewayCancelUpgrade(
|
||||||
|
timestamp time.Time,
|
||||||
|
guardianSetIndex uint32,
|
||||||
|
nonce uint32,
|
||||||
|
sequence uint64,
|
||||||
|
) (*vaa.VAA, error) { //nolint:unparam // error is always nil but kept to mirror function signature of other functions
|
||||||
|
v := vaa.CreateGovernanceVAA(timestamp, nonce, sequence, guardianSetIndex,
|
||||||
|
vaa.EmptyPayloadVaa(vaa.GatewayModuleStr, vaa.ActionCancelUpgrade, vaa.ChainIDWormchain),
|
||||||
|
)
|
||||||
|
|
||||||
|
return v, nil
|
||||||
|
}
|
||||||
|
|
||||||
func gatewayIbcComposabilityMwSetContract(
|
func gatewayIbcComposabilityMwSetContract(
|
||||||
req *nodev1.GatewayIbcComposabilityMwSetContract,
|
req *nodev1.GatewayIbcComposabilityMwSetContract,
|
||||||
timestamp time.Time,
|
timestamp time.Time,
|
||||||
|
@ -360,23 +388,6 @@ func gatewayIbcComposabilityMwSetContract(
|
||||||
return v, nil
|
return v, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func gatewaySetTokenfactoryPfmDefaultParams(
|
|
||||||
timestamp time.Time,
|
|
||||||
guardianSetIndex uint32,
|
|
||||||
nonce uint32,
|
|
||||||
sequence uint64,
|
|
||||||
) *vaa.VAA {
|
|
||||||
v := vaa.CreateGovernanceVAA(
|
|
||||||
timestamp,
|
|
||||||
nonce,
|
|
||||||
sequence,
|
|
||||||
guardianSetIndex,
|
|
||||||
vaa.EmptyPayloadVaa(vaa.GatewayModuleStr, vaa.ActionSetTokenfactoryPfmDefaultParams, vaa.ChainIDWormchain),
|
|
||||||
)
|
|
||||||
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// circleIntegrationUpdateWormholeFinality converts a nodev1.CircleIntegrationUpdateWormholeFinality to its canonical VAA representation
|
// circleIntegrationUpdateWormholeFinality converts a nodev1.CircleIntegrationUpdateWormholeFinality to its canonical VAA representation
|
||||||
// Returns an error if the data is invalid
|
// Returns an error if the data is invalid
|
||||||
func circleIntegrationUpdateWormholeFinality(req *nodev1.CircleIntegrationUpdateWormholeFinality, timestamp time.Time, guardianSetIndex uint32, nonce uint32, sequence uint64) (*vaa.VAA, error) {
|
func circleIntegrationUpdateWormholeFinality(req *nodev1.CircleIntegrationUpdateWormholeFinality, timestamp time.Time, guardianSetIndex uint32, nonce uint32, sequence uint64) (*vaa.VAA, error) {
|
||||||
|
@ -548,10 +559,12 @@ func GovMsgToVaa(message *nodev1.GovernanceMessage, currentSetIndex uint32, time
|
||||||
v, err = wormchainMigrateContract(payload.WormchainMigrateContract, timestamp, currentSetIndex, message.Nonce, message.Sequence)
|
v, err = wormchainMigrateContract(payload.WormchainMigrateContract, timestamp, currentSetIndex, message.Nonce, message.Sequence)
|
||||||
case *nodev1.GovernanceMessage_WormchainWasmInstantiateAllowlist:
|
case *nodev1.GovernanceMessage_WormchainWasmInstantiateAllowlist:
|
||||||
v, err = wormchainWasmInstantiateAllowlist(payload.WormchainWasmInstantiateAllowlist, timestamp, currentSetIndex, message.Nonce, message.Sequence)
|
v, err = wormchainWasmInstantiateAllowlist(payload.WormchainWasmInstantiateAllowlist, timestamp, currentSetIndex, message.Nonce, message.Sequence)
|
||||||
|
case *nodev1.GovernanceMessage_GatewayScheduleUpgrade:
|
||||||
|
v, err = gatewayScheduleUpgrade(payload.GatewayScheduleUpgrade, timestamp, currentSetIndex, message.Nonce, message.Sequence)
|
||||||
|
case *nodev1.GovernanceMessage_GatewayCancelUpgrade:
|
||||||
|
v, err = gatewayCancelUpgrade(timestamp, currentSetIndex, message.Nonce, message.Sequence)
|
||||||
case *nodev1.GovernanceMessage_GatewayIbcComposabilityMwSetContract:
|
case *nodev1.GovernanceMessage_GatewayIbcComposabilityMwSetContract:
|
||||||
v, err = gatewayIbcComposabilityMwSetContract(payload.GatewayIbcComposabilityMwSetContract, timestamp, currentSetIndex, message.Nonce, message.Sequence)
|
v, err = gatewayIbcComposabilityMwSetContract(payload.GatewayIbcComposabilityMwSetContract, timestamp, currentSetIndex, message.Nonce, message.Sequence)
|
||||||
case *nodev1.GovernanceMessage_GatewaySetTokenfactoryPfmDefaultParams:
|
|
||||||
v = gatewaySetTokenfactoryPfmDefaultParams(timestamp, currentSetIndex, message.Nonce, message.Sequence)
|
|
||||||
case *nodev1.GovernanceMessage_CircleIntegrationUpdateWormholeFinality:
|
case *nodev1.GovernanceMessage_CircleIntegrationUpdateWormholeFinality:
|
||||||
v, err = circleIntegrationUpdateWormholeFinality(payload.CircleIntegrationUpdateWormholeFinality, timestamp, currentSetIndex, message.Nonce, message.Sequence)
|
v, err = circleIntegrationUpdateWormholeFinality(payload.CircleIntegrationUpdateWormholeFinality, timestamp, currentSetIndex, message.Nonce, message.Sequence)
|
||||||
case *nodev1.GovernanceMessage_CircleIntegrationRegisterEmitterAndDomain:
|
case *nodev1.GovernanceMessage_CircleIntegrationRegisterEmitterAndDomain:
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -95,8 +95,9 @@ message GovernanceMessage {
|
||||||
WormchainWasmInstantiateAllowlist wormchain_wasm_instantiate_allowlist = 23;
|
WormchainWasmInstantiateAllowlist wormchain_wasm_instantiate_allowlist = 23;
|
||||||
|
|
||||||
// Gateway
|
// Gateway
|
||||||
GatewayIbcComposabilityMwSetContract gateway_ibc_composability_mw_set_contract = 24;
|
GatewayScheduleUpgrade gateway_schedule_upgrade = 24;
|
||||||
GatewaySetTokenfactoryPfmDefaultParams gateway_set_tokenfactory_pfm_default_params = 25;
|
GatewayCancelUpgrade gateway_cancel_upgrade = 25;
|
||||||
|
GatewayIbcComposabilityMwSetContract gateway_ibc_composability_mw_set_contract = 26;
|
||||||
|
|
||||||
// Global Accountant
|
// Global Accountant
|
||||||
AccountantModifyBalance accountant_modify_balance = 17;
|
AccountantModifyBalance accountant_modify_balance = 17;
|
||||||
|
@ -251,7 +252,15 @@ message GatewayIbcComposabilityMwSetContract {
|
||||||
string contract = 1;
|
string contract = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message GatewaySetTokenfactoryPfmDefaultParams {}
|
message GatewayScheduleUpgrade {
|
||||||
|
// Name of the upgrade
|
||||||
|
string name = 1;
|
||||||
|
|
||||||
|
// Height of the upgrade halt
|
||||||
|
uint64 height = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GatewayCancelUpgrade {}
|
||||||
|
|
||||||
message CircleIntegrationUpdateWormholeFinality {
|
message CircleIntegrationUpdateWormholeFinality {
|
||||||
uint32 finality = 1;
|
uint32 finality = 1;
|
||||||
|
|
|
@ -74,8 +74,9 @@ var (
|
||||||
ActionDeleteWasmInstantiateAllowlist GovernanceAction = 5
|
ActionDeleteWasmInstantiateAllowlist GovernanceAction = 5
|
||||||
|
|
||||||
// Gateway governance actions
|
// Gateway governance actions
|
||||||
ActionSetIbcComposabilityMwContract GovernanceAction = 1
|
ActionScheduleUpgrade GovernanceAction = 1
|
||||||
ActionSetTokenfactoryPfmDefaultParams GovernanceAction = 2
|
ActionCancelUpgrade GovernanceAction = 2
|
||||||
|
ActionSetIbcComposabilityMwContract GovernanceAction = 3
|
||||||
|
|
||||||
// Accountant goverance actions
|
// Accountant goverance actions
|
||||||
ActionModifyBalance GovernanceAction = 1
|
ActionModifyBalance GovernanceAction = 1
|
||||||
|
@ -161,6 +162,12 @@ type (
|
||||||
CodeId uint64
|
CodeId uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BodyGatewayScheduleUpgrade is a governance message to schedule an upgrade on Gateway
|
||||||
|
BodyGatewayScheduleUpgrade struct {
|
||||||
|
Name string
|
||||||
|
Height uint64
|
||||||
|
}
|
||||||
|
|
||||||
// BodyGatewayIbcComposabilityMwContract is a governance message to set a specific contract (i.e. IBC Translator) for the ibc composability middleware to use
|
// BodyGatewayIbcComposabilityMwContract is a governance message to set a specific contract (i.e. IBC Translator) for the ibc composability middleware to use
|
||||||
BodyGatewayIbcComposabilityMwContract struct {
|
BodyGatewayIbcComposabilityMwContract struct {
|
||||||
ContractAddr [32]byte
|
ContractAddr [32]byte
|
||||||
|
@ -323,6 +330,18 @@ func (r *BodyGatewayIbcComposabilityMwContract) Deserialize(bz []byte) {
|
||||||
r.ContractAddr = contractAddr
|
r.ContractAddr = contractAddr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r BodyGatewayScheduleUpgrade) Serialize() []byte {
|
||||||
|
payload := &bytes.Buffer{}
|
||||||
|
payload.Write([]byte(r.Name))
|
||||||
|
MustWrite(payload, binary.BigEndian, r.Height)
|
||||||
|
return serializeBridgeGovernanceVaa(GatewayModuleStr, ActionScheduleUpgrade, ChainIDWormchain, payload.Bytes())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *BodyGatewayScheduleUpgrade) Deserialize(bz []byte) {
|
||||||
|
r.Name = string(bz[0 : len(bz)-8])
|
||||||
|
r.Height = binary.BigEndian.Uint64(bz[len(bz)-8:])
|
||||||
|
}
|
||||||
|
|
||||||
func (r BodyCircleIntegrationUpdateWormholeFinality) Serialize() []byte {
|
func (r BodyCircleIntegrationUpdateWormholeFinality) Serialize() []byte {
|
||||||
return serializeBridgeGovernanceVaa(CircleIntegrationModuleStr, CircleIntegrationActionUpdateWormholeFinality, r.TargetChainID, []byte{r.Finality})
|
return serializeBridgeGovernanceVaa(CircleIntegrationModuleStr, CircleIntegrationActionUpdateWormholeFinality, r.TargetChainID, []byte{r.Finality})
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,7 +211,7 @@ func TestBodyWormholeRelayerSetDefaultDeliveryProviderSerialize(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBodyGatewayIbcComposabilityMwContractSerialize(t *testing.T) {
|
func TestBodyGatewayIbcComposabilityMwContractSerialize(t *testing.T) {
|
||||||
expected := "00000000000000000000000000000000000000476174657761794d6f64756c65010c200102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20"
|
expected := "00000000000000000000000000000000000000476174657761794d6f64756c65030c200102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20"
|
||||||
bodyGatewayIbcComposabilityMwContract := BodyGatewayIbcComposabilityMwContract{
|
bodyGatewayIbcComposabilityMwContract := BodyGatewayIbcComposabilityMwContract{
|
||||||
ContractAddr: dummyBytes,
|
ContractAddr: dummyBytes,
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import (
|
||||||
"github.com/cosmos/cosmos-sdk/server/api"
|
"github.com/cosmos/cosmos-sdk/server/api"
|
||||||
"github.com/cosmos/cosmos-sdk/server/config"
|
"github.com/cosmos/cosmos-sdk/server/config"
|
||||||
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
||||||
|
store "github.com/cosmos/cosmos-sdk/store/types"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/types/module"
|
"github.com/cosmos/cosmos-sdk/types/module"
|
||||||
"github.com/cosmos/cosmos-sdk/version"
|
"github.com/cosmos/cosmos-sdk/version"
|
||||||
|
@ -85,6 +86,7 @@ import (
|
||||||
tmjson "github.com/tendermint/tendermint/libs/json"
|
tmjson "github.com/tendermint/tendermint/libs/json"
|
||||||
"github.com/tendermint/tendermint/libs/log"
|
"github.com/tendermint/tendermint/libs/log"
|
||||||
tmos "github.com/tendermint/tendermint/libs/os"
|
tmos "github.com/tendermint/tendermint/libs/os"
|
||||||
|
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||||
dbm "github.com/tendermint/tm-db"
|
dbm "github.com/tendermint/tm-db"
|
||||||
|
|
||||||
"github.com/CosmWasm/wasmd/x/wasm"
|
"github.com/CosmWasm/wasmd/x/wasm"
|
||||||
|
@ -215,6 +217,8 @@ var (
|
||||||
}
|
}
|
||||||
|
|
||||||
tokenFactoryCapabilities = []string{}
|
tokenFactoryCapabilities = []string{}
|
||||||
|
|
||||||
|
Upgrades = []Upgrade{V2_22_0_Upgrade}
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -288,6 +292,9 @@ type App struct {
|
||||||
|
|
||||||
// the module manager
|
// the module manager
|
||||||
mm *module.Manager
|
mm *module.Manager
|
||||||
|
|
||||||
|
// module configurator
|
||||||
|
configurator module.Configurator
|
||||||
}
|
}
|
||||||
|
|
||||||
// New returns a reference to an initialized Gaia.
|
// New returns a reference to an initialized Gaia.
|
||||||
|
@ -387,6 +394,7 @@ func New(
|
||||||
|
|
||||||
app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegrant.StoreKey], app.AccountKeeper)
|
app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegrant.StoreKey], app.AccountKeeper)
|
||||||
app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp)
|
app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp)
|
||||||
|
app.WormholeKeeper.SetUpgradeKeeper(app.UpgradeKeeper)
|
||||||
|
|
||||||
// register the staking hooks
|
// register the staking hooks
|
||||||
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
|
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
|
||||||
|
@ -402,7 +410,6 @@ func New(
|
||||||
)
|
)
|
||||||
|
|
||||||
app.WireICS20PreWasmKeeper(&app.WormholeKeeper)
|
app.WireICS20PreWasmKeeper(&app.WormholeKeeper)
|
||||||
app.WormholeKeeper.SetPfmKeeper(*app.PacketForwardKeeper)
|
|
||||||
|
|
||||||
// register the proposal types
|
// register the proposal types
|
||||||
govRouter := govtypes.NewRouter()
|
govRouter := govtypes.NewRouter()
|
||||||
|
@ -434,7 +441,6 @@ func New(
|
||||||
app.DistrKeeper,
|
app.DistrKeeper,
|
||||||
tokenFactoryCapabilities,
|
tokenFactoryCapabilities,
|
||||||
)
|
)
|
||||||
app.WormholeKeeper.SetTokenfactoryKeeper(app.TokenFactoryKeeper)
|
|
||||||
|
|
||||||
// The last arguments can contain custom message handlers, and custom query handlers,
|
// The last arguments can contain custom message handlers, and custom query handlers,
|
||||||
// if we want to allow any custom callbacks
|
// if we want to allow any custom callbacks
|
||||||
|
@ -482,6 +488,9 @@ func New(
|
||||||
// this line is used by starport scaffolding # ibc/app/router
|
// this line is used by starport scaffolding # ibc/app/router
|
||||||
app.IBCKeeper.SetRouter(ibcRouter)
|
app.IBCKeeper.SetRouter(ibcRouter)
|
||||||
|
|
||||||
|
//upgrade handlers
|
||||||
|
app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
|
||||||
|
|
||||||
/**** Module Options ****/
|
/**** Module Options ****/
|
||||||
|
|
||||||
// NOTE: we may consider parsing `appOpts` inside module constructors. For the moment
|
// NOTE: we may consider parsing `appOpts` inside module constructors. For the moment
|
||||||
|
@ -616,13 +625,16 @@ func New(
|
||||||
|
|
||||||
app.mm.RegisterInvariants(&app.CrisisKeeper)
|
app.mm.RegisterInvariants(&app.CrisisKeeper)
|
||||||
app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino)
|
app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino)
|
||||||
app.mm.RegisterServices(module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()))
|
app.mm.RegisterServices(app.configurator)
|
||||||
|
|
||||||
// initialize stores
|
// initialize stores
|
||||||
app.MountKVStores(keys)
|
app.MountKVStores(keys)
|
||||||
app.MountTransientStores(tkeys)
|
app.MountTransientStores(tkeys)
|
||||||
app.MountMemoryStores(memKeys)
|
app.MountMemoryStores(memKeys)
|
||||||
|
|
||||||
|
// register upgrade
|
||||||
|
app.setupUpgradeHandlers(app.configurator)
|
||||||
|
|
||||||
// initialize BaseApp
|
// initialize BaseApp
|
||||||
app.SetInitChainer(app.InitChainer)
|
app.SetInitChainer(app.InitChainer)
|
||||||
app.SetBeginBlocker(app.BeginBlocker)
|
app.SetBeginBlocker(app.BeginBlocker)
|
||||||
|
@ -644,6 +656,8 @@ func New(
|
||||||
app.SetAnteHandler(wrappedAnteHandler)
|
app.SetAnteHandler(wrappedAnteHandler)
|
||||||
app.SetEndBlocker(app.EndBlocker)
|
app.SetEndBlocker(app.EndBlocker)
|
||||||
|
|
||||||
|
app.setupUpgradeStoreLoaders()
|
||||||
|
|
||||||
if loadLatest {
|
if loadLatest {
|
||||||
if err := app.LoadLatestVersion(); err != nil {
|
if err := app.LoadLatestVersion(); err != nil {
|
||||||
tmos.Exit(err.Error())
|
tmos.Exit(err.Error())
|
||||||
|
@ -918,3 +932,63 @@ func (app *App) WireICS20PreWasmKeeper(wk *wormholemodulekeeper.Keeper) {
|
||||||
ibcComposabilityMiddleware := ibccomposabilitymw.NewIBCMiddleware(&hooksTransferModule, &ibcComposabilityMwICS4Wrapper, ibcComposabilityMwKeeper)
|
ibcComposabilityMiddleware := ibccomposabilitymw.NewIBCMiddleware(&hooksTransferModule, &ibcComposabilityMwICS4Wrapper, ibcComposabilityMwKeeper)
|
||||||
app.TransferStack = &ibcComposabilityMiddleware
|
app.TransferStack = &ibcComposabilityMiddleware
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// configure store loader that checks if version == upgradeHeight and applies store upgrades
|
||||||
|
func (app *App) setupUpgradeStoreLoaders() {
|
||||||
|
upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
|
||||||
|
if err != nil {
|
||||||
|
panic("failed to read upgrade info from disk" + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
if app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, upgrade := range Upgrades {
|
||||||
|
if upgradeInfo.Name == upgrade.UpgradeName {
|
||||||
|
storeUpgrades := upgrade.StoreUpgrades
|
||||||
|
app.SetStoreLoader(
|
||||||
|
upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (app *App) setupUpgradeHandlers(cfg module.Configurator) {
|
||||||
|
for _, upgrade := range Upgrades {
|
||||||
|
app.UpgradeKeeper.SetUpgradeHandler(
|
||||||
|
upgrade.UpgradeName,
|
||||||
|
upgrade.CreateUpgradeHandler(
|
||||||
|
app.mm,
|
||||||
|
cfg,
|
||||||
|
app,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// BaseAppParamManager defines an interrace that BaseApp is expected to fullfil
|
||||||
|
// that allows upgrade handlers to modify BaseApp parameters.
|
||||||
|
type BaseAppParamManager interface {
|
||||||
|
GetConsensusParams(ctx sdk.Context) *tmproto.ConsensusParams
|
||||||
|
StoreConsensusParams(ctx sdk.Context, cp *tmproto.ConsensusParams)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Upgrade defines a struct containing necessary fields that a SoftwareUpgradeProposal
|
||||||
|
// must have written, in order for the state migration to go smoothly.
|
||||||
|
// An upgrade must implement this struct, and then set it in the app.go.
|
||||||
|
// The app.go will then define the handler.
|
||||||
|
type Upgrade struct {
|
||||||
|
// Upgrade version name, for the upgrade handler, e.g. `v7`
|
||||||
|
UpgradeName string
|
||||||
|
|
||||||
|
// CreateUpgradeHandler defines the function that creates an upgrade handler
|
||||||
|
CreateUpgradeHandler func(
|
||||||
|
*module.Manager,
|
||||||
|
module.Configurator,
|
||||||
|
*App,
|
||||||
|
) upgradetypes.UpgradeHandler
|
||||||
|
|
||||||
|
// Store upgrades, should be used for any new modules introduced, new modules deleted, or store names renamed.
|
||||||
|
StoreUpgrades store.StoreUpgrades
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
package app
|
||||||
|
|
||||||
|
import (
|
||||||
|
store "github.com/cosmos/cosmos-sdk/store/types"
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
"github.com/cosmos/cosmos-sdk/types/module"
|
||||||
|
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
|
||||||
|
|
||||||
|
packetforwardtypes "github.com/strangelove-ventures/packet-forward-middleware/v4/router/types"
|
||||||
|
ibccomposabilitytypes "github.com/wormhole-foundation/wormchain/x/ibc-composability-mw/types"
|
||||||
|
ibchookstypes "github.com/wormhole-foundation/wormchain/x/ibc-hooks/types"
|
||||||
|
tokenfactorytypes "github.com/wormhole-foundation/wormchain/x/tokenfactory/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
var V2_22_0_Upgrade = Upgrade{
|
||||||
|
UpgradeName: "v2.22.0",
|
||||||
|
CreateUpgradeHandler: CreateV2_22_0_UpgradeHandler,
|
||||||
|
StoreUpgrades: store.StoreUpgrades{
|
||||||
|
Added: []string{
|
||||||
|
tokenfactorytypes.ModuleName,
|
||||||
|
ibchookstypes.StoreKey,
|
||||||
|
packetforwardtypes.StoreKey,
|
||||||
|
ibccomposabilitytypes.StoreKey,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateV2_22_0_UpgradeHandler(
|
||||||
|
mm *module.Manager,
|
||||||
|
cfg module.Configurator,
|
||||||
|
app *App,
|
||||||
|
) upgradetypes.UpgradeHandler {
|
||||||
|
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
|
||||||
|
logger := ctx.Logger().With("upgrade", "v2.22.0")
|
||||||
|
|
||||||
|
// TokenFactory
|
||||||
|
newTokenFactoryParams := tokenfactorytypes.Params{
|
||||||
|
DenomCreationFee: nil,
|
||||||
|
DenomCreationGasConsume: 0,
|
||||||
|
}
|
||||||
|
|
||||||
|
app.TokenFactoryKeeper.SetParams(ctx, newTokenFactoryParams)
|
||||||
|
logger.Info("set tokenfactory params")
|
||||||
|
|
||||||
|
// Packet Forward middleware initial params
|
||||||
|
app.PacketForwardKeeper.SetParams(ctx, packetforwardtypes.DefaultParams())
|
||||||
|
|
||||||
|
return mm.RunMigrations(ctx, cfg, vm)
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,8 +7,7 @@ import (
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
pfmkeeper "github.com/strangelove-ventures/packet-forward-middleware/v4/router/keeper"
|
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
|
||||||
tokenfactorykeeper "github.com/wormhole-foundation/wormchain/x/tokenfactory/keeper"
|
|
||||||
"github.com/wormhole-foundation/wormchain/x/wormhole/types"
|
"github.com/wormhole-foundation/wormchain/x/wormhole/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -18,15 +17,13 @@ type (
|
||||||
storeKey sdk.StoreKey
|
storeKey sdk.StoreKey
|
||||||
memKey sdk.StoreKey
|
memKey sdk.StoreKey
|
||||||
|
|
||||||
accountKeeper types.AccountKeeper
|
accountKeeper types.AccountKeeper
|
||||||
bankKeeper types.BankKeeper
|
bankKeeper types.BankKeeper
|
||||||
wasmdKeeper types.WasmdKeeper
|
wasmdKeeper types.WasmdKeeper
|
||||||
tokenfactoryKeeper tokenfactorykeeper.Keeper
|
upgradeKeeper upgradekeeper.Keeper
|
||||||
pfmKeeper pfmkeeper.Keeper
|
|
||||||
|
|
||||||
setWasmd bool
|
setWasmd bool
|
||||||
setTokenfactory bool
|
setUpgrade bool
|
||||||
setPfm bool
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -57,16 +54,9 @@ func (k *Keeper) SetWasmdKeeper(keeper types.WasmdKeeper) {
|
||||||
k.setWasmd = true
|
k.setWasmd = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Necessary because x/staking relies on x/wormhole and x/tokenfactory relies on x/staking (transitively)
|
func (k *Keeper) SetUpgradeKeeper(keeper upgradekeeper.Keeper) {
|
||||||
func (k *Keeper) SetTokenfactoryKeeper(keeper tokenfactorykeeper.Keeper) {
|
k.upgradeKeeper = keeper
|
||||||
k.tokenfactoryKeeper = keeper
|
k.setUpgrade = true
|
||||||
k.setTokenfactory = true
|
|
||||||
}
|
|
||||||
|
|
||||||
// Necesesary because x/staking relies on x/wormhole and PFM relies on x/staking (transitively)
|
|
||||||
func (k *Keeper) SetPfmKeeper(keeper pfmkeeper.Keeper) {
|
|
||||||
k.pfmKeeper = keeper
|
|
||||||
k.setPfm = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k Keeper) Logger(ctx sdk.Context) log.Logger {
|
func (k Keeper) Logger(ctx sdk.Context) log.Logger {
|
||||||
|
|
|
@ -5,8 +5,8 @@ import (
|
||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||||
pfmtypes "github.com/strangelove-ventures/packet-forward-middleware/v4/router/types"
|
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
|
||||||
tokenfactorytypes "github.com/wormhole-foundation/wormchain/x/tokenfactory/types"
|
|
||||||
"github.com/wormhole-foundation/wormchain/x/wormhole/types"
|
"github.com/wormhole-foundation/wormchain/x/wormhole/types"
|
||||||
"github.com/wormhole-foundation/wormhole/sdk/vaa"
|
"github.com/wormhole-foundation/wormhole/sdk/vaa"
|
||||||
)
|
)
|
||||||
|
@ -42,15 +42,39 @@ func (k msgServer) ExecuteGatewayGovernanceVaa(
|
||||||
|
|
||||||
// Execute action
|
// Execute action
|
||||||
switch vaa.GovernanceAction(action) {
|
switch vaa.GovernanceAction(action) {
|
||||||
|
case vaa.ActionScheduleUpgrade:
|
||||||
|
return k.scheduleUpgrade(ctx, payload)
|
||||||
|
case vaa.ActionCancelUpgrade:
|
||||||
|
return k.cancelUpgrade(ctx)
|
||||||
case vaa.ActionSetIbcComposabilityMwContract:
|
case vaa.ActionSetIbcComposabilityMwContract:
|
||||||
return k.setIbcComposabilityMwContract(ctx, payload)
|
return k.setIbcComposabilityMwContract(ctx, payload)
|
||||||
case vaa.ActionSetTokenfactoryPfmDefaultParams:
|
|
||||||
return k.setTokenfactoryPfmDefaultParams(ctx)
|
|
||||||
default:
|
default:
|
||||||
return nil, types.ErrUnknownGovernanceAction
|
return nil, types.ErrUnknownGovernanceAction
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (k msgServer) scheduleUpgrade(
|
||||||
|
ctx sdk.Context,
|
||||||
|
payload []byte,
|
||||||
|
) (*types.EmptyResponse, error) {
|
||||||
|
// Deserialize payload to get the name and height for the upgrade plan
|
||||||
|
var payloadBody vaa.BodyGatewayScheduleUpgrade
|
||||||
|
payloadBody.Deserialize(payload)
|
||||||
|
|
||||||
|
plan := upgradetypes.Plan{
|
||||||
|
Name: payloadBody.Name,
|
||||||
|
Height: int64(payloadBody.Height),
|
||||||
|
}
|
||||||
|
k.upgradeKeeper.ScheduleUpgrade(ctx, plan)
|
||||||
|
|
||||||
|
return &types.EmptyResponse{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (k msgServer) cancelUpgrade(ctx sdk.Context) (*types.EmptyResponse, error) {
|
||||||
|
k.upgradeKeeper.ClearUpgradePlan(ctx)
|
||||||
|
return &types.EmptyResponse{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (k msgServer) setIbcComposabilityMwContract(
|
func (k msgServer) setIbcComposabilityMwContract(
|
||||||
ctx sdk.Context,
|
ctx sdk.Context,
|
||||||
payload []byte,
|
payload []byte,
|
||||||
|
@ -76,11 +100,3 @@ func (k msgServer) setIbcComposabilityMwContract(
|
||||||
|
|
||||||
return &types.EmptyResponse{}, nil
|
return &types.EmptyResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k msgServer) setTokenfactoryPfmDefaultParams(ctx sdk.Context) (*types.EmptyResponse, error) {
|
|
||||||
// Set the default params for both tokenfactory and PFM
|
|
||||||
k.tokenfactoryKeeper.SetParams(ctx, tokenfactorytypes.DefaultParams())
|
|
||||||
k.pfmKeeper.SetParams(ctx, pfmtypes.DefaultParams())
|
|
||||||
|
|
||||||
return &types.EmptyResponse{}, nil
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue