2020-11-19 03:53:19 -08:00
package guardiand
import (
2021-10-29 08:17:11 -07:00
"encoding/hex"
2020-11-19 03:53:19 -08:00
"fmt"
2022-04-27 00:53:09 -07:00
"log"
"strconv"
"strings"
2021-10-29 08:17:11 -07:00
"github.com/btcsuite/btcutil/bech32"
"github.com/ethereum/go-ethereum/common"
"github.com/mr-tron/base58"
"github.com/spf13/pflag"
2021-09-30 11:57:44 -07:00
"github.com/tendermint/tendermint/libs/rand"
2022-08-18 01:52:36 -07:00
"github.com/wormhole-foundation/wormhole/sdk/vaa"
2020-11-19 03:53:19 -08:00
"github.com/ethereum/go-ethereum/crypto"
"github.com/spf13/cobra"
"google.golang.org/protobuf/encoding/prototext"
2021-08-26 01:35:09 -07:00
"github.com/certusone/wormhole/node/pkg/devnet"
nodev1 "github.com/certusone/wormhole/node/pkg/proto/node/v1"
2020-11-19 03:53:19 -08:00
)
2021-01-19 04:01:45 -08:00
var setUpdateNumGuardians * int
2020-11-19 03:53:19 -08:00
var templateGuardianIndex * int
2021-10-29 08:17:11 -07:00
var chainID * string
var address * string
var module * string
2020-11-19 03:53:19 -08:00
2023-03-16 07:13:50 -07:00
var circleIntegrationChainID * string
2023-03-06 11:23:48 -08:00
var circleIntegrationFinality * string
var circleIntegrationForeignEmitterChainID * string
var circleIntegrationForeignEmitterAddress * string
var circleIntegrationCircleDomain * string
var circleIntegrationNewImplementationAddress * string
2023-06-02 08:06:34 -07:00
var wormchainStoreCodeWasmHash * string
var wormchainInstantiateContractCodeId * string
var wormchainInstantiateContractInstantiationMsg * string
var wormchainInstantiateContractLabel * string
var wormchainMigrateContractCodeId * string
var wormchainMigrateContractContractAddress * string
var wormchainMigrateContractInstantiationMsg * string
2023-08-14 07:49:02 -07:00
var wormchainWasmInstantiateAllowlistCodeId * string
var wormchainWasmInstantiateAllowlistContractAddress * string
2023-08-07 11:18:40 -07:00
2023-08-16 17:24:57 -07:00
var gatewayScheduleUpgradeName * string
var gatewayScheduleUpgradeHeight * string
2023-08-14 17:37:50 -07:00
var gatewayIbcComposabilityMwContractAddress * string
2023-08-07 11:18:40 -07:00
2023-08-14 07:49:02 -07:00
var ibcUpdateChannelChainTargetChainId * string
var ibcUpdateChannelChainChannelId * string
var ibcUpdateChannelChainChainId * string
2023-05-12 03:11:21 -07:00
2020-11-19 03:53:19 -08:00
func init ( ) {
2021-10-29 08:17:11 -07:00
governanceFlagSet := pflag . NewFlagSet ( "governance" , pflag . ExitOnError )
chainID = governanceFlagSet . String ( "chain-id" , "" , "Chain ID" )
address = governanceFlagSet . String ( "new-address" , "" , "New address (hex, base58 or bech32)" )
moduleFlagSet := pflag . NewFlagSet ( "module" , pflag . ExitOnError )
module = moduleFlagSet . String ( "module" , "" , "Module name" )
2023-01-17 08:25:39 -08:00
templateGuardianIndex = TemplateCmd . PersistentFlags ( ) . Int ( "idx" , 3 , "Default current guardian set index" )
2021-10-29 08:17:11 -07:00
2021-01-19 04:01:45 -08:00
setUpdateNumGuardians = AdminClientGuardianSetTemplateCmd . Flags ( ) . Int ( "num" , 1 , "Number of devnet guardians in example file" )
2022-03-15 23:36:36 -07:00
TemplateCmd . AddCommand ( AdminClientGuardianSetTemplateCmd )
2021-01-19 04:01:45 -08:00
2021-10-29 08:17:11 -07:00
AdminClientContractUpgradeTemplateCmd . Flags ( ) . AddFlagSet ( governanceFlagSet )
2021-01-19 04:01:45 -08:00
TemplateCmd . AddCommand ( AdminClientContractUpgradeTemplateCmd )
2021-10-29 08:17:11 -07:00
AdminClientTokenBridgeRegisterChainCmd . Flags ( ) . AddFlagSet ( governanceFlagSet )
AdminClientTokenBridgeRegisterChainCmd . Flags ( ) . AddFlagSet ( moduleFlagSet )
2021-09-30 11:57:44 -07:00
TemplateCmd . AddCommand ( AdminClientTokenBridgeRegisterChainCmd )
2021-10-29 08:17:11 -07:00
AdminClientTokenBridgeUpgradeContractCmd . Flags ( ) . AddFlagSet ( governanceFlagSet )
AdminClientTokenBridgeUpgradeContractCmd . Flags ( ) . AddFlagSet ( moduleFlagSet )
node: add BridgeUpgradeContract governance VAA
Example VAA produced by the template:
(*vaa.VAA)(0xc0004f4510)({
Version: (uint8) 1,
GuardianSetIndex: (uint32) 0,
Signatures: ([]*vaa.Signature) (len=1 cap=1) {
(*vaa.Signature)(0xc0003b0370)({
Index: (uint8) 0,
Signature: (vaa.SignatureData) (len=65 cap=65) 0f97ec9093c21ccc4ce544898ed5c21b66ab4c90be894642fbb43474ed9fb48a26d6e12f3397b9fdab160fee64e797d26599a2a9d81a4bf4bc98970b5fa5122501
})
},
Timestamp: (time.Time) 1970-01-01 00:00:00 +0000 UTC,
Nonce: (uint32) 1375049878,
Sequence: (uint64) 3557202656914991802,
ConsistencyLevel: (uint8) 32,
EmitterChain: (vaa.ChainID) solana,
EmitterAddress: (vaa.Address) (len=32 cap=32) 0000000000000000000000000000000000000000000000000000000000000004,
Payload: ([]uint8) (len=67 cap=1000) {
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000010 00 00 00 00 00 54 6f 6b 65 6e 42 72 69 64 67 65 |.....TokenBridge|
00000020 02 00 05 00 00 00 00 00 00 00 00 00 00 00 00 02 |................|
00000030 90 fb 16 72 08 af 45 5b b1 37 78 01 63 b7 b7 a9 |...r..E[.7x.c...|
00000040 a1 0c 16 |...|
}
})
Change-Id: Ibe95db01e1bc0a9c36e1be06920a389db886fdd1
2021-10-08 10:41:43 -07:00
TemplateCmd . AddCommand ( AdminClientTokenBridgeUpgradeContractCmd )
2022-04-27 00:53:09 -07:00
2023-06-14 07:27:00 -07:00
AdminClientWormholeRelayerSetDefaultDeliveryProviderCmd . Flags ( ) . AddFlagSet ( governanceFlagSet )
TemplateCmd . AddCommand ( AdminClientWormholeRelayerSetDefaultDeliveryProviderCmd )
2023-03-16 07:13:50 -07:00
circleIntegrationChainIDFlagSet := pflag . NewFlagSet ( "circle-integ" , pflag . ExitOnError )
circleIntegrationChainID = circleIntegrationChainIDFlagSet . String ( "chain-id" , "" , "Target chain ID" )
2023-03-06 11:23:48 -08:00
circleIntegrationFinalityFlagSet := pflag . NewFlagSet ( "finality" , pflag . ExitOnError )
circleIntegrationFinality = circleIntegrationFinalityFlagSet . String ( "finality" , "" , "Desired wormhole finality" )
2023-03-16 07:13:50 -07:00
AdminClientCircleIntegrationUpdateWormholeFinalityCmd . Flags ( ) . AddFlagSet ( circleIntegrationChainIDFlagSet )
2023-03-06 11:23:48 -08:00
AdminClientCircleIntegrationUpdateWormholeFinalityCmd . Flags ( ) . AddFlagSet ( circleIntegrationFinalityFlagSet )
TemplateCmd . AddCommand ( AdminClientCircleIntegrationUpdateWormholeFinalityCmd )
circleIntegrationRegisterEmitterFlagSet := pflag . NewFlagSet ( "register" , pflag . ExitOnError )
circleIntegrationForeignEmitterChainID = circleIntegrationRegisterEmitterFlagSet . String ( "foreign-emitter-chain-id" , "" , "Foreign emitter chain ID" )
circleIntegrationForeignEmitterAddress = circleIntegrationRegisterEmitterFlagSet . String ( "foreign-emitter-address" , "" , "Foreign emitter address (hex, base58 or bech32)" )
circleIntegrationCircleDomain = circleIntegrationRegisterEmitterFlagSet . String ( "circle-domain" , "" , "Circle domain" )
2023-03-16 07:13:50 -07:00
AdminClientCircleIntegrationRegisterEmitterAndDomainCmd . Flags ( ) . AddFlagSet ( circleIntegrationChainIDFlagSet )
2023-03-06 11:23:48 -08:00
AdminClientCircleIntegrationRegisterEmitterAndDomainCmd . Flags ( ) . AddFlagSet ( circleIntegrationRegisterEmitterFlagSet )
TemplateCmd . AddCommand ( AdminClientCircleIntegrationRegisterEmitterAndDomainCmd )
circleIntegrationUpgradeContractImplementationFlagSet := pflag . NewFlagSet ( "upgrade" , pflag . ExitOnError )
circleIntegrationNewImplementationAddress = circleIntegrationUpgradeContractImplementationFlagSet . String ( "new-implementation-address" , "" , "New implementation address (hex, base58 or bech32)" )
2023-03-16 07:13:50 -07:00
AdminClientCircleIntegrationUpgradeContractImplementationCmd . Flags ( ) . AddFlagSet ( circleIntegrationChainIDFlagSet )
2023-03-06 11:23:48 -08:00
AdminClientCircleIntegrationUpgradeContractImplementationCmd . Flags ( ) . AddFlagSet ( circleIntegrationUpgradeContractImplementationFlagSet )
TemplateCmd . AddCommand ( AdminClientCircleIntegrationUpgradeContractImplementationCmd )
2023-05-12 03:11:21 -07:00
2023-06-02 08:06:34 -07:00
wormchainStoreCodeFlagSet := pflag . NewFlagSet ( "wormchain-store-code" , pflag . ExitOnError )
wormchainStoreCodeWasmHash = wormchainStoreCodeFlagSet . String ( "wasm-hash" , "" , "WASM Hash of the stored code" )
AdminClientWormchainStoreCodeCmd . Flags ( ) . AddFlagSet ( wormchainStoreCodeFlagSet )
TemplateCmd . AddCommand ( AdminClientWormchainStoreCodeCmd )
wormchainInstantiateContractFlagSet := pflag . NewFlagSet ( "wormchain-instantiate-contract" , pflag . ExitOnError )
wormchainInstantiateContractCodeId = wormchainInstantiateContractFlagSet . String ( "code-id" , "" , "code ID of the stored code" )
wormchainInstantiateContractLabel = wormchainInstantiateContractFlagSet . String ( "label" , "" , "label" )
wormchainInstantiateContractInstantiationMsg = wormchainInstantiateContractFlagSet . String ( "instantiation-msg" , "" , "instantiate message" )
AdminClientWormchainInstantiateContractCmd . Flags ( ) . AddFlagSet ( wormchainInstantiateContractFlagSet )
TemplateCmd . AddCommand ( AdminClientWormchainInstantiateContractCmd )
wormchainMigrateContractFlagSet := pflag . NewFlagSet ( "wormchain-migrate-contract" , pflag . ExitOnError )
wormchainMigrateContractCodeId = wormchainMigrateContractFlagSet . String ( "code-id" , "" , "code ID of the stored code" )
wormchainMigrateContractContractAddress = wormchainMigrateContractFlagSet . String ( "contract-address" , "" , "contract address" )
wormchainMigrateContractInstantiationMsg = wormchainMigrateContractFlagSet . String ( "instantiation-msg" , "" , "instantiate message" )
AdminClientWormchainMigrateContractCmd . Flags ( ) . AddFlagSet ( wormchainMigrateContractFlagSet )
TemplateCmd . AddCommand ( AdminClientWormchainMigrateContractCmd )
2023-08-14 07:49:02 -07:00
// flags for the wormchain add/delete wasm instantiate allowlist commands
wormchainWasmInstantiateAllowlistFlagSet := pflag . NewFlagSet ( "wormchain-wasm-instantiate-allowlist" , pflag . ExitOnError )
wormchainWasmInstantiateAllowlistCodeId = wormchainWasmInstantiateAllowlistFlagSet . String ( "code-id" , "" , "code ID of the stored code to add/delete allowlist wasm instantiate for" )
wormchainWasmInstantiateAllowlistContractAddress = wormchainWasmInstantiateAllowlistFlagSet . String ( "contract-address" , "" , "contract address to add/delete allowlist wasm instantiate for" )
AdminClientWormchainAddWasmInstantiateAllowlistCmd . Flags ( ) . AddFlagSet ( wormchainWasmInstantiateAllowlistFlagSet )
AdminClientWormchainDeleteWasmInstantiateAllowlistCmd . Flags ( ) . AddFlagSet ( wormchainWasmInstantiateAllowlistFlagSet )
2023-08-07 11:18:40 -07:00
TemplateCmd . AddCommand ( AdminClientWormchainAddWasmInstantiateAllowlistCmd )
TemplateCmd . AddCommand ( AdminClientWormchainDeleteWasmInstantiateAllowlistCmd )
2023-08-14 17:37:50 -07:00
// flags for the gateway-ibc-composability-mw-set-contract command
gatewayIbcComposabilityMwFlagSet := pflag . NewFlagSet ( "gateway-ibc-composability-mw-set-contract" , pflag . ExitOnError )
gatewayIbcComposabilityMwContractAddress = gatewayIbcComposabilityMwFlagSet . String ( "contract-address" , "" , "contract address to set in the ibc composability middleware" )
AdminClientGatewayIbcComposabilityMwSetContractCmd . Flags ( ) . AddFlagSet ( gatewayIbcComposabilityMwFlagSet )
TemplateCmd . AddCommand ( AdminClientGatewayIbcComposabilityMwSetContractCmd )
2023-08-14 07:49:02 -07:00
2023-08-16 17:24:57 -07:00
// 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 )
2023-08-14 07:49:02 -07:00
// flags for the ibc-receiver-update-channel-chain and ibc-translator-update-channel-chain commands
ibcUpdateChannelChainFlagSet := pflag . NewFlagSet ( "ibc-mapping" , pflag . ExitOnError )
ibcUpdateChannelChainTargetChainId = ibcUpdateChannelChainFlagSet . String ( "target-chain-id" , "" , "Target Chain ID for the governance VAA" )
ibcUpdateChannelChainChannelId = ibcUpdateChannelChainFlagSet . String ( "channel-id" , "" , "IBC Channel ID on Wormchain" )
ibcUpdateChannelChainChainId = ibcUpdateChannelChainFlagSet . String ( "chain-id" , "" , "IBC Chain ID that the channel ID corresponds to" )
AdminClientIbcReceiverUpdateChannelChainCmd . Flags ( ) . AddFlagSet ( ibcUpdateChannelChainFlagSet )
AdminClientIbcTranslatorUpdateChannelChainCmd . Flags ( ) . AddFlagSet ( ibcUpdateChannelChainFlagSet )
2023-05-12 03:11:21 -07:00
TemplateCmd . AddCommand ( AdminClientIbcReceiverUpdateChannelChainCmd )
2023-08-14 07:49:02 -07:00
TemplateCmd . AddCommand ( AdminClientIbcTranslatorUpdateChannelChainCmd )
2021-01-19 04:01:45 -08:00
}
var TemplateCmd = & cobra . Command {
Use : "template" ,
Short : "Guardian governance VAA template commands " ,
2020-11-19 03:53:19 -08:00
}
var AdminClientGuardianSetTemplateCmd = & cobra . Command {
2021-10-29 08:17:11 -07:00
Use : "guardian-set-update" ,
Short : "Generate an empty guardian set template" ,
2020-11-19 03:53:19 -08:00
Run : runGuardianSetTemplate ,
}
2021-01-19 04:01:45 -08:00
var AdminClientContractUpgradeTemplateCmd = & cobra . Command {
2021-10-29 08:17:11 -07:00
Use : "contract-upgrade" ,
Short : "Generate an empty contract upgrade template" ,
2021-01-19 04:01:45 -08:00
Run : runContractUpgradeTemplate ,
}
2021-09-30 11:57:44 -07:00
var AdminClientTokenBridgeRegisterChainCmd = & cobra . Command {
2021-10-29 08:17:11 -07:00
Use : "token-bridge-register-chain" ,
Short : "Generate an empty token bridge chain registration template at specified path" ,
2021-09-30 11:57:44 -07:00
Run : runTokenBridgeRegisterChainTemplate ,
}
node: add BridgeUpgradeContract governance VAA
Example VAA produced by the template:
(*vaa.VAA)(0xc0004f4510)({
Version: (uint8) 1,
GuardianSetIndex: (uint32) 0,
Signatures: ([]*vaa.Signature) (len=1 cap=1) {
(*vaa.Signature)(0xc0003b0370)({
Index: (uint8) 0,
Signature: (vaa.SignatureData) (len=65 cap=65) 0f97ec9093c21ccc4ce544898ed5c21b66ab4c90be894642fbb43474ed9fb48a26d6e12f3397b9fdab160fee64e797d26599a2a9d81a4bf4bc98970b5fa5122501
})
},
Timestamp: (time.Time) 1970-01-01 00:00:00 +0000 UTC,
Nonce: (uint32) 1375049878,
Sequence: (uint64) 3557202656914991802,
ConsistencyLevel: (uint8) 32,
EmitterChain: (vaa.ChainID) solana,
EmitterAddress: (vaa.Address) (len=32 cap=32) 0000000000000000000000000000000000000000000000000000000000000004,
Payload: ([]uint8) (len=67 cap=1000) {
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000010 00 00 00 00 00 54 6f 6b 65 6e 42 72 69 64 67 65 |.....TokenBridge|
00000020 02 00 05 00 00 00 00 00 00 00 00 00 00 00 00 02 |................|
00000030 90 fb 16 72 08 af 45 5b b1 37 78 01 63 b7 b7 a9 |...r..E[.7x.c...|
00000040 a1 0c 16 |...|
}
})
Change-Id: Ibe95db01e1bc0a9c36e1be06920a389db886fdd1
2021-10-08 10:41:43 -07:00
var AdminClientTokenBridgeUpgradeContractCmd = & cobra . Command {
2021-10-29 08:17:11 -07:00
Use : "token-bridge-upgrade-contract" ,
Short : "Generate an empty token bridge contract upgrade template at specified path" ,
node: add BridgeUpgradeContract governance VAA
Example VAA produced by the template:
(*vaa.VAA)(0xc0004f4510)({
Version: (uint8) 1,
GuardianSetIndex: (uint32) 0,
Signatures: ([]*vaa.Signature) (len=1 cap=1) {
(*vaa.Signature)(0xc0003b0370)({
Index: (uint8) 0,
Signature: (vaa.SignatureData) (len=65 cap=65) 0f97ec9093c21ccc4ce544898ed5c21b66ab4c90be894642fbb43474ed9fb48a26d6e12f3397b9fdab160fee64e797d26599a2a9d81a4bf4bc98970b5fa5122501
})
},
Timestamp: (time.Time) 1970-01-01 00:00:00 +0000 UTC,
Nonce: (uint32) 1375049878,
Sequence: (uint64) 3557202656914991802,
ConsistencyLevel: (uint8) 32,
EmitterChain: (vaa.ChainID) solana,
EmitterAddress: (vaa.Address) (len=32 cap=32) 0000000000000000000000000000000000000000000000000000000000000004,
Payload: ([]uint8) (len=67 cap=1000) {
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000010 00 00 00 00 00 54 6f 6b 65 6e 42 72 69 64 67 65 |.....TokenBridge|
00000020 02 00 05 00 00 00 00 00 00 00 00 00 00 00 00 02 |................|
00000030 90 fb 16 72 08 af 45 5b b1 37 78 01 63 b7 b7 a9 |...r..E[.7x.c...|
00000040 a1 0c 16 |...|
}
})
Change-Id: Ibe95db01e1bc0a9c36e1be06920a389db886fdd1
2021-10-08 10:41:43 -07:00
Run : runTokenBridgeUpgradeContractTemplate ,
}
2023-03-06 11:23:48 -08:00
var AdminClientCircleIntegrationUpdateWormholeFinalityCmd = & cobra . Command {
Use : "circle-integration-update-wormhole-finality" ,
Short : "Generate an empty circle integration update wormhole finality template at specified path" ,
Run : runCircleIntegrationUpdateWormholeFinalityTemplate ,
}
var AdminClientCircleIntegrationRegisterEmitterAndDomainCmd = & cobra . Command {
Use : "circle-integration-register-emitter-and-domain" ,
Short : "Generate an empty circle integration register emitter and domain template at specified path" ,
Run : runCircleIntegrationRegisterEmitterAndDomainTemplate ,
}
var AdminClientCircleIntegrationUpgradeContractImplementationCmd = & cobra . Command {
Use : "circle-integration-upgrade-contract-implementation" ,
Short : "Generate an empty circle integration upgrade contract implementation template at specified path" ,
Run : runCircleIntegrationUpgradeContractImplementationTemplate ,
}
2023-06-02 08:06:34 -07:00
var AdminClientWormchainStoreCodeCmd = & cobra . Command {
Use : "wormchain-store-code" ,
Short : "Generate an empty wormchain store code template at specified path" ,
Run : runWormchainStoreCodeTemplate ,
}
var AdminClientWormchainInstantiateContractCmd = & cobra . Command {
Use : "wormchain-instantiate-contract" ,
Short : "Generate an empty wormchain instantiate contract template at specified path" ,
Run : runWormchainInstantiateContractTemplate ,
}
var AdminClientWormchainMigrateContractCmd = & cobra . Command {
Use : "wormchain-migrate-contract" ,
Short : "Generate an empty wormchain migrate contract template at specified path" ,
Run : runWormchainMigrateContractTemplate ,
}
2023-08-07 11:18:40 -07:00
var AdminClientWormchainAddWasmInstantiateAllowlistCmd = & cobra . Command {
Use : "wormchain-add-wasm-instantiate-allowlist" ,
Short : "Generate an empty wormchain add wasm instantiate allowlist template at specified path" ,
Run : runWormchainAddWasmInstantiateAllowlistTemplate ,
}
var AdminClientWormchainDeleteWasmInstantiateAllowlistCmd = & cobra . Command {
Use : "wormchain-delete-wasm-instantiate-allowlist" ,
Short : "Generate an empty wormchain delete wasm instantiate allowlist template at specified path" ,
Run : runWormchainDeleteWasmInstantiateAllowlistTemplate ,
}
2023-08-16 17:24:57 -07:00
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 ,
}
2023-08-14 17:37:50 -07:00
var AdminClientGatewayIbcComposabilityMwSetContractCmd = & cobra . Command {
Use : "gateway-ibc-composability-mw-set-contract" ,
2023-08-14 07:49:02 -07:00
Short : "Set the contract that the IBC Composability middleware will query" ,
2023-08-14 17:37:50 -07:00
Run : runGatewayIbcComposabilityMwSetContractTemplate ,
}
2023-05-12 03:11:21 -07:00
var AdminClientIbcReceiverUpdateChannelChainCmd = & cobra . Command {
Use : "ibc-receiver-update-channel-chain" ,
Short : "Generate an empty ibc receiver channelId to chainId mapping update template at specified path" ,
Run : runIbcReceiverUpdateChannelChainTemplate ,
}
2023-08-14 07:49:02 -07:00
var AdminClientIbcTranslatorUpdateChannelChainCmd = & cobra . Command {
Use : "ibc-translator-update-channel-chain" ,
Short : "Generate an empty ibc translator channelId to chainId mapping update template at specified path" ,
Run : runIbcTranslatorUpdateChannelChainTemplate ,
}
2023-06-14 07:27:00 -07:00
var AdminClientWormholeRelayerSetDefaultDeliveryProviderCmd = & cobra . Command {
2023-06-16 12:14:38 -07:00
Use : "wormhole-relayer-set-default-delivery-provider" ,
Short : "Generate a 'set default delivery provider' template for specified chain and address" ,
2023-06-14 07:27:00 -07:00
Run : runWormholeRelayerSetDefaultDeliveryProviderTemplate ,
}
2020-11-19 03:53:19 -08:00
func runGuardianSetTemplate ( cmd * cobra . Command , args [ ] string ) {
// Use deterministic devnet addresses as examples in the template, such that this doubles as a test fixture.
2021-01-19 04:01:45 -08:00
guardians := make ( [ ] * nodev1 . GuardianSetUpdate_Guardian , * setUpdateNumGuardians )
for i := 0 ; i < * setUpdateNumGuardians ; i ++ {
2022-05-20 08:09:48 -07:00
k := devnet . InsecureDeterministicEcdsaKeyByIndex ( crypto . S256 ( ) , uint64 ( i ) )
2020-11-19 03:53:19 -08:00
guardians [ i ] = & nodev1 . GuardianSetUpdate_Guardian {
Pubkey : crypto . PubkeyToAddress ( k . PublicKey ) . Hex ( ) ,
Name : fmt . Sprintf ( "Example validator %d" , i ) ,
}
}
2021-01-19 04:01:45 -08:00
m := & nodev1 . InjectGovernanceVAARequest {
CurrentSetIndex : uint32 ( * templateGuardianIndex ) ,
2021-10-29 08:50:46 -07:00
Messages : [ ] * nodev1 . GovernanceMessage {
{
Sequence : rand . Uint64 ( ) ,
Nonce : rand . Uint32 ( ) ,
Payload : & nodev1 . GovernanceMessage_GuardianSet {
GuardianSet : & nodev1 . GuardianSetUpdate { Guardians : guardians } ,
} ,
} ,
2021-01-19 04:01:45 -08:00
} ,
}
b , err := prototext . MarshalOptions { Multiline : true } . Marshal ( m )
if err != nil {
panic ( err )
}
2021-10-29 08:17:11 -07:00
fmt . Print ( string ( b ) )
}
2021-01-19 04:01:45 -08:00
2021-10-29 08:17:11 -07:00
func runContractUpgradeTemplate ( cmd * cobra . Command , args [ ] string ) {
address , err := parseAddress ( * address )
if err != nil {
log . Fatal ( err )
}
chainID , err := parseChainID ( * chainID )
2021-01-19 04:01:45 -08:00
if err != nil {
log . Fatal ( err )
}
m := & nodev1 . InjectGovernanceVAARequest {
2020-11-19 03:53:19 -08:00
CurrentSetIndex : uint32 ( * templateGuardianIndex ) ,
2021-10-29 08:50:46 -07:00
Messages : [ ] * nodev1 . GovernanceMessage {
{
Sequence : rand . Uint64 ( ) ,
Nonce : rand . Uint32 ( ) ,
Payload : & nodev1 . GovernanceMessage_ContractUpgrade {
ContractUpgrade : & nodev1 . ContractUpgrade {
ChainId : uint32 ( chainID ) ,
NewContract : address ,
} ,
} ,
2021-01-19 04:01:45 -08:00
} ,
} ,
2020-11-19 03:53:19 -08:00
}
b , err := prototext . MarshalOptions { Multiline : true } . Marshal ( m )
if err != nil {
panic ( err )
}
2021-10-29 08:17:11 -07:00
fmt . Print ( string ( b ) )
}
func runTokenBridgeRegisterChainTemplate ( cmd * cobra . Command , args [ ] string ) {
address , err := parseAddress ( * address )
if err != nil {
log . Fatal ( err )
}
chainID , err := parseChainID ( * chainID )
2020-11-19 03:53:19 -08:00
if err != nil {
log . Fatal ( err )
}
2021-09-30 11:57:44 -07:00
m := & nodev1 . InjectGovernanceVAARequest {
CurrentSetIndex : uint32 ( * templateGuardianIndex ) ,
2021-10-29 08:50:46 -07:00
Messages : [ ] * nodev1 . GovernanceMessage {
{
Sequence : rand . Uint64 ( ) ,
Nonce : rand . Uint32 ( ) ,
Payload : & nodev1 . GovernanceMessage_BridgeRegisterChain {
BridgeRegisterChain : & nodev1 . BridgeRegisterChain {
Module : * module ,
ChainId : uint32 ( chainID ) ,
EmitterAddress : address ,
} ,
} ,
2021-09-30 11:57:44 -07:00
} ,
} ,
}
b , err := prototext . MarshalOptions { Multiline : true } . Marshal ( m )
if err != nil {
panic ( err )
}
2021-10-29 08:17:11 -07:00
fmt . Print ( string ( b ) )
}
2021-09-30 11:57:44 -07:00
2021-10-29 08:17:11 -07:00
func runTokenBridgeUpgradeContractTemplate ( cmd * cobra . Command , args [ ] string ) {
address , err := parseAddress ( * address )
if err != nil {
log . Fatal ( err )
}
chainID , err := parseChainID ( * chainID )
2021-09-30 11:57:44 -07:00
if err != nil {
log . Fatal ( err )
}
node: add BridgeUpgradeContract governance VAA
Example VAA produced by the template:
(*vaa.VAA)(0xc0004f4510)({
Version: (uint8) 1,
GuardianSetIndex: (uint32) 0,
Signatures: ([]*vaa.Signature) (len=1 cap=1) {
(*vaa.Signature)(0xc0003b0370)({
Index: (uint8) 0,
Signature: (vaa.SignatureData) (len=65 cap=65) 0f97ec9093c21ccc4ce544898ed5c21b66ab4c90be894642fbb43474ed9fb48a26d6e12f3397b9fdab160fee64e797d26599a2a9d81a4bf4bc98970b5fa5122501
})
},
Timestamp: (time.Time) 1970-01-01 00:00:00 +0000 UTC,
Nonce: (uint32) 1375049878,
Sequence: (uint64) 3557202656914991802,
ConsistencyLevel: (uint8) 32,
EmitterChain: (vaa.ChainID) solana,
EmitterAddress: (vaa.Address) (len=32 cap=32) 0000000000000000000000000000000000000000000000000000000000000004,
Payload: ([]uint8) (len=67 cap=1000) {
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000010 00 00 00 00 00 54 6f 6b 65 6e 42 72 69 64 67 65 |.....TokenBridge|
00000020 02 00 05 00 00 00 00 00 00 00 00 00 00 00 00 02 |................|
00000030 90 fb 16 72 08 af 45 5b b1 37 78 01 63 b7 b7 a9 |...r..E[.7x.c...|
00000040 a1 0c 16 |...|
}
})
Change-Id: Ibe95db01e1bc0a9c36e1be06920a389db886fdd1
2021-10-08 10:41:43 -07:00
m := & nodev1 . InjectGovernanceVAARequest {
CurrentSetIndex : uint32 ( * templateGuardianIndex ) ,
2021-10-29 08:50:46 -07:00
Messages : [ ] * nodev1 . GovernanceMessage {
{
Sequence : rand . Uint64 ( ) ,
Nonce : rand . Uint32 ( ) ,
Payload : & nodev1 . GovernanceMessage_BridgeContractUpgrade {
BridgeContractUpgrade : & nodev1 . BridgeUpgradeContract {
Module : * module ,
TargetChainId : uint32 ( chainID ) ,
NewContract : address ,
} ,
} ,
node: add BridgeUpgradeContract governance VAA
Example VAA produced by the template:
(*vaa.VAA)(0xc0004f4510)({
Version: (uint8) 1,
GuardianSetIndex: (uint32) 0,
Signatures: ([]*vaa.Signature) (len=1 cap=1) {
(*vaa.Signature)(0xc0003b0370)({
Index: (uint8) 0,
Signature: (vaa.SignatureData) (len=65 cap=65) 0f97ec9093c21ccc4ce544898ed5c21b66ab4c90be894642fbb43474ed9fb48a26d6e12f3397b9fdab160fee64e797d26599a2a9d81a4bf4bc98970b5fa5122501
})
},
Timestamp: (time.Time) 1970-01-01 00:00:00 +0000 UTC,
Nonce: (uint32) 1375049878,
Sequence: (uint64) 3557202656914991802,
ConsistencyLevel: (uint8) 32,
EmitterChain: (vaa.ChainID) solana,
EmitterAddress: (vaa.Address) (len=32 cap=32) 0000000000000000000000000000000000000000000000000000000000000004,
Payload: ([]uint8) (len=67 cap=1000) {
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000010 00 00 00 00 00 54 6f 6b 65 6e 42 72 69 64 67 65 |.....TokenBridge|
00000020 02 00 05 00 00 00 00 00 00 00 00 00 00 00 00 02 |................|
00000030 90 fb 16 72 08 af 45 5b b1 37 78 01 63 b7 b7 a9 |...r..E[.7x.c...|
00000040 a1 0c 16 |...|
}
})
Change-Id: Ibe95db01e1bc0a9c36e1be06920a389db886fdd1
2021-10-08 10:41:43 -07:00
} ,
} ,
}
b , err := prototext . MarshalOptions { Multiline : true } . Marshal ( m )
if err != nil {
panic ( err )
}
2021-10-29 08:17:11 -07:00
fmt . Print ( string ( b ) )
}
2023-03-06 11:23:48 -08:00
func runCircleIntegrationUpdateWormholeFinalityTemplate ( cmd * cobra . Command , args [ ] string ) {
2023-03-16 07:13:50 -07:00
if * circleIntegrationChainID == "" {
log . Fatal ( "--chain-id must be specified." )
}
chainID , err := parseChainID ( * circleIntegrationChainID )
if err != nil {
log . Fatal ( "failed to parse chain id:" , err )
}
2023-03-06 11:23:48 -08:00
if * circleIntegrationFinality == "" {
log . Fatal ( "--finality must be specified." )
}
finality , err := strconv . ParseUint ( * circleIntegrationFinality , 10 , 8 )
if err != nil {
log . Fatal ( "failed to parse finality as uint8: " , err )
}
m := & nodev1 . InjectGovernanceVAARequest {
CurrentSetIndex : uint32 ( * templateGuardianIndex ) ,
Messages : [ ] * nodev1 . GovernanceMessage {
{
Sequence : rand . Uint64 ( ) ,
Nonce : rand . Uint32 ( ) ,
Payload : & nodev1 . GovernanceMessage_CircleIntegrationUpdateWormholeFinality {
CircleIntegrationUpdateWormholeFinality : & nodev1 . CircleIntegrationUpdateWormholeFinality {
2023-03-16 07:13:50 -07:00
TargetChainId : uint32 ( chainID ) ,
Finality : uint32 ( finality ) ,
2023-03-06 11:23:48 -08:00
} ,
} ,
} ,
} ,
}
b , err := prototext . MarshalOptions { Multiline : true } . Marshal ( m )
if err != nil {
panic ( err )
}
fmt . Print ( string ( b ) )
}
func runCircleIntegrationRegisterEmitterAndDomainTemplate ( cmd * cobra . Command , args [ ] string ) {
2023-03-16 07:13:50 -07:00
if * circleIntegrationChainID == "" {
log . Fatal ( "--chain-id must be specified." )
}
chainID , err := parseChainID ( * circleIntegrationChainID )
if err != nil {
log . Fatal ( "failed to parse chain id:" , err )
}
2023-03-06 11:23:48 -08:00
if * circleIntegrationForeignEmitterChainID == "" {
log . Fatal ( "--foreign-emitter-chain-id must be specified." )
}
foreignEmitterChainId , err := parseChainID ( * circleIntegrationForeignEmitterChainID )
if err != nil {
log . Fatal ( "failed to parse foreign emitter chain id as uint8:" , err )
}
if * circleIntegrationForeignEmitterAddress == "" {
log . Fatal ( "--foreign-emitter-address must be specified." )
}
foreignEmitterAddress , err := parseAddress ( * circleIntegrationForeignEmitterAddress )
if err != nil {
log . Fatal ( "failed to parse foreign emitter address: " , err )
}
if * circleIntegrationCircleDomain == "" {
log . Fatal ( "--circle-domain must be specified." )
}
circleDomain , err := strconv . ParseUint ( * circleIntegrationCircleDomain , 10 , 32 )
if err != nil {
log . Fatal ( "failed to parse circle domain as uint32:" , err )
}
m := & nodev1 . InjectGovernanceVAARequest {
CurrentSetIndex : uint32 ( * templateGuardianIndex ) ,
Messages : [ ] * nodev1 . GovernanceMessage {
{
Sequence : rand . Uint64 ( ) ,
Nonce : rand . Uint32 ( ) ,
Payload : & nodev1 . GovernanceMessage_CircleIntegrationRegisterEmitterAndDomain {
CircleIntegrationRegisterEmitterAndDomain : & nodev1 . CircleIntegrationRegisterEmitterAndDomain {
2023-03-16 07:13:50 -07:00
TargetChainId : uint32 ( chainID ) ,
2023-03-06 11:23:48 -08:00
ForeignEmitterChainId : uint32 ( foreignEmitterChainId ) ,
ForeignEmitterAddress : foreignEmitterAddress ,
CircleDomain : uint32 ( circleDomain ) ,
} ,
} ,
} ,
} ,
}
b , err := prototext . MarshalOptions { Multiline : true } . Marshal ( m )
if err != nil {
panic ( err )
}
fmt . Print ( string ( b ) )
}
func runCircleIntegrationUpgradeContractImplementationTemplate ( cmd * cobra . Command , args [ ] string ) {
2023-03-16 07:13:50 -07:00
if * circleIntegrationChainID == "" {
log . Fatal ( "--chain-id must be specified." )
}
chainID , err := parseChainID ( * circleIntegrationChainID )
if err != nil {
log . Fatal ( "failed to parse chain id:" , err )
}
2023-03-06 11:23:48 -08:00
if * circleIntegrationNewImplementationAddress == "" {
log . Fatal ( "--new-implementation-address must be specified." )
}
newImplementationAddress , err := parseAddress ( * circleIntegrationNewImplementationAddress )
if err != nil {
log . Fatal ( "failed to parse new implementation address: " , err )
}
m := & nodev1 . InjectGovernanceVAARequest {
CurrentSetIndex : uint32 ( * templateGuardianIndex ) ,
Messages : [ ] * nodev1 . GovernanceMessage {
{
Sequence : rand . Uint64 ( ) ,
Nonce : rand . Uint32 ( ) ,
Payload : & nodev1 . GovernanceMessage_CircleIntegrationUpgradeContractImplementation {
CircleIntegrationUpgradeContractImplementation : & nodev1 . CircleIntegrationUpgradeContractImplementation {
2023-03-16 07:13:50 -07:00
TargetChainId : uint32 ( chainID ) ,
2023-03-06 11:23:48 -08:00
NewImplementationAddress : newImplementationAddress ,
} ,
} ,
} ,
} ,
}
b , err := prototext . MarshalOptions { Multiline : true } . Marshal ( m )
if err != nil {
panic ( err )
}
fmt . Print ( string ( b ) )
}
2023-06-02 08:06:34 -07:00
func runWormchainStoreCodeTemplate ( cmd * cobra . Command , args [ ] string ) {
if * wormchainStoreCodeWasmHash == "" {
log . Fatal ( "--wasm-hash must be specified." )
}
// Validate the string is valid hex.
buf , err := hex . DecodeString ( * wormchainStoreCodeWasmHash )
if err != nil {
log . Fatal ( "invalid wasm-hash (expected hex): %w" , err )
}
// Validate the string is the correct length.
if len ( buf ) != 32 {
log . Fatalf ( "wasm-hash (expected 32 bytes but received %d bytes)" , len ( buf ) )
}
m := & nodev1 . InjectGovernanceVAARequest {
CurrentSetIndex : uint32 ( * templateGuardianIndex ) ,
Messages : [ ] * nodev1 . GovernanceMessage {
{
Sequence : rand . Uint64 ( ) ,
Nonce : rand . Uint32 ( ) ,
Payload : & nodev1 . GovernanceMessage_WormchainStoreCode {
WormchainStoreCode : & nodev1 . WormchainStoreCode {
WasmHash : string ( * wormchainStoreCodeWasmHash ) ,
} ,
} ,
} ,
} ,
}
b , err := prototext . MarshalOptions { Multiline : true } . Marshal ( m )
if err != nil {
panic ( err )
}
fmt . Print ( string ( b ) )
}
func runWormchainInstantiateContractTemplate ( cmd * cobra . Command , args [ ] string ) {
if * wormchainInstantiateContractCodeId == "" {
log . Fatal ( "--code-id must be specified." )
}
codeId , err := strconv . ParseUint ( * wormchainInstantiateContractCodeId , 10 , 64 )
if err != nil {
log . Fatal ( "failed to parse code-id as uint64: " , err )
}
if * wormchainInstantiateContractLabel == "" {
log . Fatal ( "--label must be specified." )
}
if * wormchainInstantiateContractInstantiationMsg == "" {
2023-08-07 11:18:40 -07:00
log . Fatal ( "--instantiation-msg must be specified." )
2023-06-02 08:06:34 -07:00
}
m := & nodev1 . InjectGovernanceVAARequest {
CurrentSetIndex : uint32 ( * templateGuardianIndex ) ,
Messages : [ ] * nodev1 . GovernanceMessage {
{
Sequence : rand . Uint64 ( ) ,
Nonce : rand . Uint32 ( ) ,
Payload : & nodev1 . GovernanceMessage_WormchainInstantiateContract {
WormchainInstantiateContract : & nodev1 . WormchainInstantiateContract {
CodeId : codeId ,
Label : * wormchainInstantiateContractLabel ,
InstantiationMsg : * wormchainInstantiateContractInstantiationMsg ,
} ,
} ,
} ,
} ,
}
b , err := prototext . MarshalOptions { Multiline : true } . Marshal ( m )
if err != nil {
panic ( err )
}
fmt . Print ( string ( b ) )
}
func runWormchainMigrateContractTemplate ( cmd * cobra . Command , args [ ] string ) {
if * wormchainMigrateContractCodeId == "" {
log . Fatal ( "--code-id must be specified." )
}
codeId , err := strconv . ParseUint ( * wormchainMigrateContractCodeId , 10 , 64 )
if err != nil {
log . Fatal ( "failed to parse code-id as uint64: " , err )
}
if * wormchainMigrateContractContractAddress == "" {
log . Fatal ( "--contract-address must be specified." )
}
if * wormchainMigrateContractInstantiationMsg == "" {
log . Fatal ( "--instantiate-msg must be specified." )
}
m := & nodev1 . InjectGovernanceVAARequest {
CurrentSetIndex : uint32 ( * templateGuardianIndex ) ,
Messages : [ ] * nodev1 . GovernanceMessage {
{
Sequence : rand . Uint64 ( ) ,
Nonce : rand . Uint32 ( ) ,
Payload : & nodev1 . GovernanceMessage_WormchainMigrateContract {
WormchainMigrateContract : & nodev1 . WormchainMigrateContract {
CodeId : codeId ,
Contract : * wormchainMigrateContractContractAddress ,
InstantiationMsg : * wormchainMigrateContractInstantiationMsg ,
} ,
} ,
} ,
} ,
}
b , err := prototext . MarshalOptions { Multiline : true } . Marshal ( m )
if err != nil {
panic ( err )
}
fmt . Print ( string ( b ) )
}
2023-08-14 07:49:02 -07:00
func runWormchainAddWasmInstantiateAllowlistTemplate ( cmd * cobra . Command , args [ ] string ) {
runWormchainWasmInstantiateAllowlistTemplate ( nodev1 . WormchainWasmInstantiateAllowlistAction_WORMCHAIN_WASM_INSTANTIATE_ALLOWLIST_ACTION_ADD )
}
func runWormchainDeleteWasmInstantiateAllowlistTemplate ( cmd * cobra . Command , args [ ] string ) {
runWormchainWasmInstantiateAllowlistTemplate ( nodev1 . WormchainWasmInstantiateAllowlistAction_WORMCHAIN_WASM_INSTANTIATE_ALLOWLIST_ACTION_DELETE )
}
func runWormchainWasmInstantiateAllowlistTemplate ( action nodev1 . WormchainWasmInstantiateAllowlistAction ) {
if * wormchainWasmInstantiateAllowlistCodeId == "" {
2023-08-07 11:18:40 -07:00
log . Fatal ( "--code-id must be specified" )
}
2023-08-14 07:49:02 -07:00
codeId , err := strconv . ParseUint ( * wormchainWasmInstantiateAllowlistCodeId , 10 , 64 )
2023-08-07 11:18:40 -07:00
if err != nil {
log . Fatal ( "failed to parse code-id as utin64: " , err )
}
2023-08-14 07:49:02 -07:00
if * wormchainWasmInstantiateAllowlistContractAddress == "" {
2023-08-07 11:18:40 -07:00
log . Fatal ( "--contract-address must be specified" )
}
m := & nodev1 . InjectGovernanceVAARequest {
CurrentSetIndex : uint32 ( * templateGuardianIndex ) ,
Messages : [ ] * nodev1 . GovernanceMessage {
{
Sequence : rand . Uint64 ( ) ,
Nonce : rand . Uint32 ( ) ,
2023-08-14 07:49:02 -07:00
Payload : & nodev1 . GovernanceMessage_WormchainWasmInstantiateAllowlist {
WormchainWasmInstantiateAllowlist : & nodev1 . WormchainWasmInstantiateAllowlist {
2023-08-07 11:18:40 -07:00
CodeId : codeId ,
2023-08-14 07:49:02 -07:00
Contract : * wormchainWasmInstantiateAllowlistContractAddress ,
Action : action ,
2023-08-07 11:18:40 -07:00
} ,
} ,
} ,
} ,
}
b , err := prototext . MarshalOptions { Multiline : true } . Marshal ( m )
if err != nil {
panic ( err )
}
fmt . Print ( string ( b ) )
}
2023-08-16 17:24:57 -07:00
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 )
2023-08-14 07:49:02 -07:00
}
2023-08-07 11:18:40 -07:00
m := & nodev1 . InjectGovernanceVAARequest {
CurrentSetIndex : uint32 ( * templateGuardianIndex ) ,
Messages : [ ] * nodev1 . GovernanceMessage {
{
Sequence : rand . Uint64 ( ) ,
Nonce : rand . Uint32 ( ) ,
2023-08-16 17:24:57 -07:00
Payload : & nodev1 . GovernanceMessage_GatewayScheduleUpgrade {
GatewayScheduleUpgrade : & nodev1 . GatewayScheduleUpgrade {
Name : * gatewayScheduleUpgradeName ,
Height : height ,
2023-08-07 11:18:40 -07:00
} ,
} ,
} ,
} ,
}
b , err := prototext . MarshalOptions { Multiline : true } . Marshal ( m )
if err != nil {
panic ( err )
}
fmt . Print ( string ( b ) )
}
2023-08-16 17:24:57 -07:00
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 ) {
if * gatewayIbcComposabilityMwContractAddress == "" {
log . Fatal ( "--contract-address must be specified" )
}
2023-08-14 17:37:50 -07:00
m := & nodev1 . InjectGovernanceVAARequest {
CurrentSetIndex : uint32 ( * templateGuardianIndex ) ,
Messages : [ ] * nodev1 . GovernanceMessage {
{
Sequence : rand . Uint64 ( ) ,
Nonce : rand . Uint32 ( ) ,
2023-08-16 17:24:57 -07:00
Payload : & nodev1 . GovernanceMessage_GatewayIbcComposabilityMwSetContract {
GatewayIbcComposabilityMwSetContract : & nodev1 . GatewayIbcComposabilityMwSetContract {
Contract : * gatewayIbcComposabilityMwContractAddress ,
} ,
2023-08-14 17:37:50 -07:00
} ,
} ,
} ,
}
b , err := prototext . MarshalOptions { Multiline : true } . Marshal ( m )
if err != nil {
panic ( err )
}
fmt . Print ( string ( b ) )
}
2023-05-12 03:11:21 -07:00
func runIbcReceiverUpdateChannelChainTemplate ( cmd * cobra . Command , args [ ] string ) {
2023-08-14 07:49:02 -07:00
runIbcUpdateChannelChainTemplate ( nodev1 . IbcUpdateChannelChainModule_IBC_UPDATE_CHANNEL_CHAIN_MODULE_RECEIVER )
}
func runIbcTranslatorUpdateChannelChainTemplate ( cmd * cobra . Command , args [ ] string ) {
runIbcUpdateChannelChainTemplate ( nodev1 . IbcUpdateChannelChainModule_IBC_UPDATE_CHANNEL_CHAIN_MODULE_TRANSLATOR )
}
func runIbcUpdateChannelChainTemplate ( module nodev1 . IbcUpdateChannelChainModule ) {
if * ibcUpdateChannelChainTargetChainId == "" {
2023-05-12 03:11:21 -07:00
log . Fatal ( "--target-chain-id must be specified" )
}
2023-08-14 07:49:02 -07:00
targetChainId , err := parseChainID ( * ibcUpdateChannelChainTargetChainId )
2023-05-12 03:11:21 -07:00
if err != nil {
log . Fatal ( "failed to parse chain id: " , err )
}
2023-08-14 07:49:02 -07:00
if * ibcUpdateChannelChainChannelId == "" {
2023-05-12 03:11:21 -07:00
log . Fatal ( "--channel-id must be specified" )
}
2023-08-14 07:49:02 -07:00
if len ( * ibcUpdateChannelChainChannelId ) > 64 {
2023-05-12 03:11:21 -07:00
log . Fatal ( "invalid channel id length, must be <= 64" )
}
2023-08-14 07:49:02 -07:00
if * ibcUpdateChannelChainChainId == "" {
2023-05-12 03:11:21 -07:00
log . Fatal ( "--chain-id must be specified" )
}
2023-08-14 07:49:02 -07:00
chainId , err := parseChainID ( * ibcUpdateChannelChainChainId )
2023-05-12 03:11:21 -07:00
if err != nil {
log . Fatal ( "failed to parse chain id: " , err )
}
m := & nodev1 . InjectGovernanceVAARequest {
CurrentSetIndex : uint32 ( * templateGuardianIndex ) ,
Messages : [ ] * nodev1 . GovernanceMessage {
{
Sequence : rand . Uint64 ( ) ,
Nonce : rand . Uint32 ( ) ,
2023-08-14 07:49:02 -07:00
Payload : & nodev1 . GovernanceMessage_IbcUpdateChannelChain {
IbcUpdateChannelChain : & nodev1 . IbcUpdateChannelChain {
2023-05-12 03:11:21 -07:00
TargetChainId : uint32 ( targetChainId ) ,
2023-08-14 07:49:02 -07:00
ChannelId : * ibcUpdateChannelChainChannelId ,
2023-05-12 03:11:21 -07:00
ChainId : uint32 ( chainId ) ,
2023-08-14 07:49:02 -07:00
Module : module ,
2023-05-12 03:11:21 -07:00
} ,
} ,
} ,
} ,
}
2023-06-14 07:27:00 -07:00
b , err := prototext . MarshalOptions { Multiline : true } . Marshal ( m )
if err != nil {
panic ( err )
}
fmt . Print ( string ( b ) )
}
func runWormholeRelayerSetDefaultDeliveryProviderTemplate ( cmd * cobra . Command , args [ ] string ) {
address , err := parseAddress ( * address )
if err != nil {
log . Fatal ( err )
}
chainID , err := parseChainID ( * chainID )
if err != nil {
log . Fatal ( err )
}
m := & nodev1 . InjectGovernanceVAARequest {
CurrentSetIndex : uint32 ( * templateGuardianIndex ) ,
Messages : [ ] * nodev1 . GovernanceMessage {
{
Sequence : rand . Uint64 ( ) ,
Nonce : rand . Uint32 ( ) ,
Payload : & nodev1 . GovernanceMessage_WormholeRelayerSetDefaultDeliveryProvider {
WormholeRelayerSetDefaultDeliveryProvider : & nodev1 . WormholeRelayerSetDefaultDeliveryProvider {
ChainId : uint32 ( chainID ) ,
NewDefaultDeliveryProviderAddress : address ,
} ,
} ,
} ,
} ,
}
2023-05-12 03:11:21 -07:00
b , err := prototext . MarshalOptions { Multiline : true } . Marshal ( m )
if err != nil {
panic ( err )
}
fmt . Print ( string ( b ) )
}
2021-10-29 08:17:11 -07:00
// parseAddress parses either a hex-encoded address and returns
// a left-padded 32 byte hex string.
func parseAddress ( s string ) ( string , error ) {
// try base58
b , err := base58 . Decode ( s )
if err == nil {
return leftPadAddress ( b )
}
// try bech32
_ , b , err = bech32 . Decode ( s )
if err == nil {
return leftPadAddress ( b )
}
// try hex
if len ( s ) > 2 && strings . ToLower ( s [ : 2 ] ) == "0x" {
s = s [ 2 : ]
}
node: add BridgeUpgradeContract governance VAA
Example VAA produced by the template:
(*vaa.VAA)(0xc0004f4510)({
Version: (uint8) 1,
GuardianSetIndex: (uint32) 0,
Signatures: ([]*vaa.Signature) (len=1 cap=1) {
(*vaa.Signature)(0xc0003b0370)({
Index: (uint8) 0,
Signature: (vaa.SignatureData) (len=65 cap=65) 0f97ec9093c21ccc4ce544898ed5c21b66ab4c90be894642fbb43474ed9fb48a26d6e12f3397b9fdab160fee64e797d26599a2a9d81a4bf4bc98970b5fa5122501
})
},
Timestamp: (time.Time) 1970-01-01 00:00:00 +0000 UTC,
Nonce: (uint32) 1375049878,
Sequence: (uint64) 3557202656914991802,
ConsistencyLevel: (uint8) 32,
EmitterChain: (vaa.ChainID) solana,
EmitterAddress: (vaa.Address) (len=32 cap=32) 0000000000000000000000000000000000000000000000000000000000000004,
Payload: ([]uint8) (len=67 cap=1000) {
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000010 00 00 00 00 00 54 6f 6b 65 6e 42 72 69 64 67 65 |.....TokenBridge|
00000020 02 00 05 00 00 00 00 00 00 00 00 00 00 00 00 02 |................|
00000030 90 fb 16 72 08 af 45 5b b1 37 78 01 63 b7 b7 a9 |...r..E[.7x.c...|
00000040 a1 0c 16 |...|
}
})
Change-Id: Ibe95db01e1bc0a9c36e1be06920a389db886fdd1
2021-10-08 10:41:43 -07:00
2021-10-29 08:17:11 -07:00
a , err := hex . DecodeString ( s )
node: add BridgeUpgradeContract governance VAA
Example VAA produced by the template:
(*vaa.VAA)(0xc0004f4510)({
Version: (uint8) 1,
GuardianSetIndex: (uint32) 0,
Signatures: ([]*vaa.Signature) (len=1 cap=1) {
(*vaa.Signature)(0xc0003b0370)({
Index: (uint8) 0,
Signature: (vaa.SignatureData) (len=65 cap=65) 0f97ec9093c21ccc4ce544898ed5c21b66ab4c90be894642fbb43474ed9fb48a26d6e12f3397b9fdab160fee64e797d26599a2a9d81a4bf4bc98970b5fa5122501
})
},
Timestamp: (time.Time) 1970-01-01 00:00:00 +0000 UTC,
Nonce: (uint32) 1375049878,
Sequence: (uint64) 3557202656914991802,
ConsistencyLevel: (uint8) 32,
EmitterChain: (vaa.ChainID) solana,
EmitterAddress: (vaa.Address) (len=32 cap=32) 0000000000000000000000000000000000000000000000000000000000000004,
Payload: ([]uint8) (len=67 cap=1000) {
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000010 00 00 00 00 00 54 6f 6b 65 6e 42 72 69 64 67 65 |.....TokenBridge|
00000020 02 00 05 00 00 00 00 00 00 00 00 00 00 00 00 02 |................|
00000030 90 fb 16 72 08 af 45 5b b1 37 78 01 63 b7 b7 a9 |...r..E[.7x.c...|
00000040 a1 0c 16 |...|
}
})
Change-Id: Ibe95db01e1bc0a9c36e1be06920a389db886fdd1
2021-10-08 10:41:43 -07:00
if err != nil {
2021-10-29 08:17:11 -07:00
return "" , fmt . Errorf ( "invalid hex address: %v" , err )
}
return leftPadAddress ( a )
}
func leftPadAddress ( a [ ] byte ) ( string , error ) {
if len ( a ) > 32 {
return "" , fmt . Errorf ( "address longer than 32 bytes" )
}
return hex . EncodeToString ( common . LeftPadBytes ( a , 32 ) ) , nil
}
// parseChainID parses a human-readable chain name or a chain ID.
func parseChainID ( name string ) ( vaa . ChainID , error ) {
s , err := vaa . ChainIDFromString ( name )
if err == nil {
return s , nil
}
// parse as uint32
i , err := strconv . ParseUint ( name , 10 , 32 )
if err != nil {
return 0 , fmt . Errorf ( "failed to parse as name or uint32: %v" , err )
node: add BridgeUpgradeContract governance VAA
Example VAA produced by the template:
(*vaa.VAA)(0xc0004f4510)({
Version: (uint8) 1,
GuardianSetIndex: (uint32) 0,
Signatures: ([]*vaa.Signature) (len=1 cap=1) {
(*vaa.Signature)(0xc0003b0370)({
Index: (uint8) 0,
Signature: (vaa.SignatureData) (len=65 cap=65) 0f97ec9093c21ccc4ce544898ed5c21b66ab4c90be894642fbb43474ed9fb48a26d6e12f3397b9fdab160fee64e797d26599a2a9d81a4bf4bc98970b5fa5122501
})
},
Timestamp: (time.Time) 1970-01-01 00:00:00 +0000 UTC,
Nonce: (uint32) 1375049878,
Sequence: (uint64) 3557202656914991802,
ConsistencyLevel: (uint8) 32,
EmitterChain: (vaa.ChainID) solana,
EmitterAddress: (vaa.Address) (len=32 cap=32) 0000000000000000000000000000000000000000000000000000000000000004,
Payload: ([]uint8) (len=67 cap=1000) {
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000010 00 00 00 00 00 54 6f 6b 65 6e 42 72 69 64 67 65 |.....TokenBridge|
00000020 02 00 05 00 00 00 00 00 00 00 00 00 00 00 00 02 |................|
00000030 90 fb 16 72 08 af 45 5b b1 37 78 01 63 b7 b7 a9 |...r..E[.7x.c...|
00000040 a1 0c 16 |...|
}
})
Change-Id: Ibe95db01e1bc0a9c36e1be06920a389db886fdd1
2021-10-08 10:41:43 -07:00
}
2021-10-29 08:17:11 -07:00
return vaa . ChainID ( i ) , nil
node: add BridgeUpgradeContract governance VAA
Example VAA produced by the template:
(*vaa.VAA)(0xc0004f4510)({
Version: (uint8) 1,
GuardianSetIndex: (uint32) 0,
Signatures: ([]*vaa.Signature) (len=1 cap=1) {
(*vaa.Signature)(0xc0003b0370)({
Index: (uint8) 0,
Signature: (vaa.SignatureData) (len=65 cap=65) 0f97ec9093c21ccc4ce544898ed5c21b66ab4c90be894642fbb43474ed9fb48a26d6e12f3397b9fdab160fee64e797d26599a2a9d81a4bf4bc98970b5fa5122501
})
},
Timestamp: (time.Time) 1970-01-01 00:00:00 +0000 UTC,
Nonce: (uint32) 1375049878,
Sequence: (uint64) 3557202656914991802,
ConsistencyLevel: (uint8) 32,
EmitterChain: (vaa.ChainID) solana,
EmitterAddress: (vaa.Address) (len=32 cap=32) 0000000000000000000000000000000000000000000000000000000000000004,
Payload: ([]uint8) (len=67 cap=1000) {
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000010 00 00 00 00 00 54 6f 6b 65 6e 42 72 69 64 67 65 |.....TokenBridge|
00000020 02 00 05 00 00 00 00 00 00 00 00 00 00 00 00 02 |................|
00000030 90 fb 16 72 08 af 45 5b b1 37 78 01 63 b7 b7 a9 |...r..E[.7x.c...|
00000040 a1 0c 16 |...|
}
})
Change-Id: Ibe95db01e1bc0a9c36e1be06920a389db886fdd1
2021-10-08 10:41:43 -07:00
}