Explorar o código

node/cmd: hex-encoded address for ContractUpgrade

For consistency

Change-Id: Ife43c1381ad3933524d895145c5bdb865ef9f1e7
Leo %!s(int64=4) %!d(string=hai) anos
pai
achega
1d1422e416

+ 6 - 1
node/cmd/guardiand/adminserver.go

@@ -73,7 +73,12 @@ func adminGuardianSetUpdateToVAA(req *nodev1.GuardianSetUpdate, guardianSetIndex
 // adminContractUpgradeToVAA converts a nodev1.ContractUpgrade message to its canonical VAA representation.
 // Returns an error if the data is invalid.
 func adminContractUpgradeToVAA(req *nodev1.ContractUpgrade, guardianSetIndex uint32, nonce uint32, sequence uint64) (*vaa.VAA, error) {
-	if len(req.NewContract) != 32 {
+	b, err := hex.DecodeString(req.NewContract)
+	if err != nil {
+		return nil, errors.New("invalid new contract address encoding (expected hex)")
+	}
+
+	if len(b) != 32 {
 		return nil, errors.New("invalid new_contract address")
 	}
 

+ 2 - 2
node/cmd/guardiand/admintemplate.go

@@ -98,12 +98,12 @@ func runContractUpgradeTemplate(cmd *cobra.Command, args []string) {
 
 	m := &nodev1.InjectGovernanceVAARequest{
 		CurrentSetIndex: uint32(*templateGuardianIndex),
-		Sequence:        1234,
+		Sequence:        rand.Uint64(),
 		Nonce:           rand.Uint32(),
 		Payload: &nodev1.InjectGovernanceVAARequest_ContractUpgrade{
 			ContractUpgrade: &nodev1.ContractUpgrade{
 				ChainId:     1,
-				NewContract: make([]byte, 32),
+				NewContract: "0000000000000000000000000290FB167208Af455bB137780163b7B7a9a10C16",
 			},
 		},
 	}

+ 3 - 3
proto/node/v1/node.proto

@@ -94,8 +94,8 @@ message ContractUpgrade {
   // ID of the chain where the Wormhole contract should be updated (uint8).
   uint32 chain_id = 1;
 
-  // Address of the new program/contract.
-  bytes new_contract = 2;
+  // Hex-encoded address (without leading 0x) address of the new program/contract.
+  string new_contract = 2;
 }
 
 message BridgeUpgradeContract {
@@ -105,7 +105,7 @@ message BridgeUpgradeContract {
   // ID of the chain where the bridge contract should be updated (uint16).
   uint32 target_chain_id = 2;
 
-  // Address of the new program/contract.
+  // Hex-encoded address (without leading 0x) of the new program/contract.
   string new_contract = 3;
 }