Forráskód Böngészése

Node: Add adminserver command to generate template for accountant modify balance (#3905)

* Node / Adminserver: Command to modify gacct balance

* Code review rework

* More rework
bruce-riley 1 éve
szülő
commit
a4aad23507

+ 151 - 22
node/cmd/guardiand/admintemplate.go

@@ -10,6 +10,7 @@ import (
 
 
 	"github.com/btcsuite/btcutil/bech32"
 	"github.com/btcsuite/btcutil/bech32"
 	"github.com/ethereum/go-ethereum/common"
 	"github.com/ethereum/go-ethereum/common"
+	"github.com/holiman/uint256"
 	"github.com/mr-tron/base58"
 	"github.com/mr-tron/base58"
 	"github.com/spf13/pflag"
 	"github.com/spf13/pflag"
 	"github.com/tendermint/tendermint/libs/rand"
 	"github.com/tendermint/tendermint/libs/rand"
@@ -60,6 +61,16 @@ var ibcUpdateChannelChainChainId *string
 var recoverChainIdEvmChainId *string
 var recoverChainIdEvmChainId *string
 var recoverChainIdNewChainId *string
 var recoverChainIdNewChainId *string
 
 
+var accountantModifyBalanceModule *string
+var accountantModifyBalanceTargetChainId *string
+var accountantModifyBalanceSequence *string
+var accountantModifyBalanceChainId *string
+var accountantModifyBalanceTokenChainId *string
+var accountantModifyBalanceTokenAddress *string
+var accountantModifyBalanceAction *string
+var accountantModifyBalanceAmount *string
+var accountantModifyBalanceReason *string
+
 var governanceContractAddress *string
 var governanceContractAddress *string
 var governanceTargetAddress *string
 var governanceTargetAddress *string
 var governanceTargetChain *string
 var governanceTargetChain *string
@@ -177,6 +188,21 @@ func init() {
 	AdminClientRecoverChainIdCmd.Flags().AddFlagSet(moduleFlagSet)
 	AdminClientRecoverChainIdCmd.Flags().AddFlagSet(moduleFlagSet)
 	TemplateCmd.AddCommand(AdminClientRecoverChainIdCmd)
 	TemplateCmd.AddCommand(AdminClientRecoverChainIdCmd)
 
 
+	// flags for the accountant-modify-balance command
+	accountantModifyBalanceFlagSet := pflag.NewFlagSet("accountant-modify-balance", pflag.ExitOnError)
+	accountantModifyBalanceModule = accountantModifyBalanceFlagSet.String("module", "GlobalAccountant", "Module identifier of the accountant")
+	accountantModifyBalanceTargetChainId = accountantModifyBalanceFlagSet.String("target-chain-id", "", "ID of the chain to receive this modification")
+	accountantModifyBalanceSequence = accountantModifyBalanceFlagSet.String("sequence", "", "The sequence number of this modification.  Each modification must be uniquely identifiable just by its sequence number")
+	accountantModifyBalanceChainId = accountantModifyBalanceFlagSet.String("chain-id", "", "Chain ID of the account to be modified")
+	accountantModifyBalanceTokenChainId = accountantModifyBalanceFlagSet.String("token-chain-id", "", "Chain ID of the native chain for the token")
+	accountantModifyBalanceTokenAddress = accountantModifyBalanceFlagSet.String("token-address", "", "Address of the token on its native chain, hex string encoded")
+	accountantModifyBalanceAction = accountantModifyBalanceFlagSet.String("action", "", "Kind of modification to be made (1 = add, 2 = sub)")
+	accountantModifyBalanceAmount = accountantModifyBalanceFlagSet.String("amount", "", `Amount to be modified (decimal formatted string indicating the"raw" amount, not adjusted by the decimals of the token`)
+	accountantModifyBalanceReason = accountantModifyBalanceFlagSet.String("reason", "", "human-readable reason for the modification")
+	AdminClientAccountantModifyBalanceCmd.Flags().AddFlagSet(accountantModifyBalanceFlagSet)
+	AdminClientAccountantModifyBalanceCmd.Flags().AddFlagSet(moduleFlagSet)
+	TemplateCmd.AddCommand(AdminClientAccountantModifyBalanceCmd)
+
 	// flags for general-purpose governance call command
 	// flags for general-purpose governance call command
 	generalPurposeGovernanceFlagSet := pflag.NewFlagSet("general-purpose-governance", pflag.ExitOnError)
 	generalPurposeGovernanceFlagSet := pflag.NewFlagSet("general-purpose-governance", pflag.ExitOnError)
 	governanceContractAddress = generalPurposeGovernanceFlagSet.String("governance-contract", "", "Governance contract address")
 	governanceContractAddress = generalPurposeGovernanceFlagSet.String("governance-contract", "", "Governance contract address")
@@ -226,6 +252,12 @@ var AdminClientRecoverChainIdCmd = &cobra.Command{
 	Run:   runRecoverChainIdTemplate,
 	Run:   runRecoverChainIdTemplate,
 }
 }
 
 
+var AdminClientAccountantModifyBalanceCmd = &cobra.Command{
+	Use:   "accountant-modify-balance",
+	Short: "Generate an empty accountant modify balance template at specified path",
+	Run:   runAccountantModifyBalanceTemplate,
+}
+
 var AdminClientCircleIntegrationUpdateWormholeFinalityCmd = &cobra.Command{
 var AdminClientCircleIntegrationUpdateWormholeFinalityCmd = &cobra.Command{
 	Use:   "circle-integration-update-wormhole-finality",
 	Use:   "circle-integration-update-wormhole-finality",
 	Short: "Generate an empty circle integration update wormhole finality template at specified path",
 	Short: "Generate an empty circle integration update wormhole finality template at specified path",
@@ -348,7 +380,7 @@ func runGuardianSetTemplate(cmd *cobra.Command, args []string) {
 
 
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	if err != nil {
 	if err != nil {
-		panic(err)
+		log.Fatal("failed to marshal request: ", err)
 	}
 	}
 	fmt.Print(string(b))
 	fmt.Print(string(b))
 }
 }
@@ -381,7 +413,7 @@ func runContractUpgradeTemplate(cmd *cobra.Command, args []string) {
 
 
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	if err != nil {
 	if err != nil {
-		panic(err)
+		log.Fatal("failed to marshal request: ", err)
 	}
 	}
 	fmt.Print(string(b))
 	fmt.Print(string(b))
 }
 }
@@ -414,7 +446,7 @@ func runTokenBridgeRegisterChainTemplate(cmd *cobra.Command, args []string) {
 
 
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	if err != nil {
 	if err != nil {
-		panic(err)
+		log.Fatal("failed to marshal request: ", err)
 	}
 	}
 	fmt.Print(string(b))
 	fmt.Print(string(b))
 }
 }
@@ -448,7 +480,7 @@ func runTokenBridgeUpgradeContractTemplate(cmd *cobra.Command, args []string) {
 
 
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	if err != nil {
 	if err != nil {
-		panic(err)
+		log.Fatal("failed to marshal request: ", err)
 	}
 	}
 	fmt.Print(string(b))
 	fmt.Print(string(b))
 }
 }
@@ -490,7 +522,104 @@ func runRecoverChainIdTemplate(cmd *cobra.Command, args []string) {
 
 
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	if err != nil {
 	if err != nil {
-		panic(err)
+		log.Fatal("failed to marshal request: ", err)
+	}
+	fmt.Print(string(b))
+}
+
+func runAccountantModifyBalanceTemplate(cmd *cobra.Command, args []string) {
+	if *accountantModifyBalanceModule == "" {
+		log.Fatal("--module must be specified.")
+	}
+	if *accountantModifyBalanceTargetChainId == "" {
+		log.Fatal("--target-chain-id must be specified.")
+	}
+	targetChainID, err := parseChainID(*accountantModifyBalanceTargetChainId)
+	if err != nil {
+		log.Fatal("failed to parse target chain id: ", err)
+	}
+	if *accountantModifyBalanceSequence == "" {
+		log.Fatal("--sequence must be specified")
+	}
+	sequence, err := strconv.ParseUint(*accountantModifyBalanceSequence, 10, 64)
+	if err != nil {
+		log.Fatal("failed to parse sequence as uint64: ", err)
+	}
+	if *accountantModifyBalanceChainId == "" {
+		log.Fatal("--chain-id must be specified.")
+	}
+	chainID, err := parseChainID(*accountantModifyBalanceChainId)
+	if err != nil {
+		log.Fatal("failed to parse chain id: ", err)
+	}
+	if *accountantModifyBalanceTokenChainId == "" {
+		log.Fatal("--token-chain-id must be specified.")
+	}
+	tokenChainID, err := parseChainID(*accountantModifyBalanceTokenChainId)
+	if err != nil {
+		log.Fatal("failed to parse token chain id: ", err)
+	}
+	if *accountantModifyBalanceTokenAddress == "" {
+		log.Fatal("--token-address must be specified.")
+	}
+	tokenAddress, err := parseAddress(*accountantModifyBalanceTokenAddress)
+	if err != nil {
+		log.Fatal("failed to parse token address: ", err)
+	}
+	if *accountantModifyBalanceAction == "" {
+		log.Fatal("--action must be specified")
+	}
+	action, err := strconv.ParseUint(*accountantModifyBalanceAction, 10, 8)
+	if err != nil {
+		log.Fatal("failed to parse modification action as uint8: ", err)
+	}
+	if action != uint64(nodev1.ModificationKind_MODIFICATION_KIND_ADD) && action != uint64(nodev1.ModificationKind_MODIFICATION_KIND_SUBTRACT) {
+		log.Fatal("invalid modification action, must be 1 (add) or 2 (subtract)")
+	}
+	if *accountantModifyBalanceAmount == "" {
+		log.Fatal("--amount must be specified.")
+	}
+	amount_big := big.NewInt(0)
+	amount_big, ok := amount_big.SetString(*accountantModifyBalanceAmount, 10)
+	if !ok {
+		log.Fatal("failed to parse amount")
+	}
+	_, overflow := uint256.FromBig(amount_big)
+	if overflow {
+		log.Fatal("amount overflowed uint256")
+	}
+	if *accountantModifyBalanceReason == "" {
+		log.Fatal("--reason must be specified.")
+	}
+	if len(*accountantModifyBalanceReason) > vaa.AccountantModifyBalanceReasonLength {
+		log.Fatalf("reason is too long, can be at most %d bytes", vaa.AccountantModifyBalanceReasonLength)
+	}
+	m := &nodev1.InjectGovernanceVAARequest{
+		CurrentSetIndex: uint32(*templateGuardianIndex),
+		Messages: []*nodev1.GovernanceMessage{
+			{
+				Sequence: rand.Uint64(),
+				Nonce:    rand.Uint32(),
+				Payload: &nodev1.GovernanceMessage_AccountantModifyBalance{
+					AccountantModifyBalance: &nodev1.AccountantModifyBalance{
+						Module:        *accountantModifyBalanceModule,
+						TargetChainId: uint32(targetChainID),
+						Sequence:      uint64(sequence),
+						ChainId:       uint32(chainID),
+						TokenChain:    uint32(tokenChainID),
+						TokenAddress:  tokenAddress,
+						Kind:          nodev1.ModificationKind(action),
+						Amount:        *accountantModifyBalanceAmount,
+						Reason:        *accountantModifyBalanceReason,
+					},
+				},
+			},
+		},
+	}
+
+	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
+	if err != nil {
+		log.Fatal("failed to marshal request: ", err)
 	}
 	}
 	fmt.Print(string(b))
 	fmt.Print(string(b))
 }
 }
@@ -529,7 +658,7 @@ func runCircleIntegrationUpdateWormholeFinalityTemplate(cmd *cobra.Command, args
 
 
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	if err != nil {
 	if err != nil {
-		panic(err)
+		log.Fatal("failed to marshal request: ", err)
 	}
 	}
 	fmt.Print(string(b))
 	fmt.Print(string(b))
 }
 }
@@ -584,7 +713,7 @@ func runCircleIntegrationRegisterEmitterAndDomainTemplate(cmd *cobra.Command, ar
 
 
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	if err != nil {
 	if err != nil {
-		panic(err)
+		log.Fatal("failed to marshal request: ", err)
 	}
 	}
 	fmt.Print(string(b))
 	fmt.Print(string(b))
 }
 }
@@ -623,7 +752,7 @@ func runCircleIntegrationUpgradeContractImplementationTemplate(cmd *cobra.Comman
 
 
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	if err != nil {
 	if err != nil {
-		panic(err)
+		log.Fatal("failed to marshal request: ", err)
 	}
 	}
 	fmt.Print(string(b))
 	fmt.Print(string(b))
 }
 }
@@ -661,7 +790,7 @@ func runWormchainStoreCodeTemplate(cmd *cobra.Command, args []string) {
 
 
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	if err != nil {
 	if err != nil {
-		panic(err)
+		log.Fatal("failed to marshal request: ", err)
 	}
 	}
 	fmt.Print(string(b))
 	fmt.Print(string(b))
 }
 }
@@ -700,7 +829,7 @@ func runWormchainInstantiateContractTemplate(cmd *cobra.Command, args []string)
 
 
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	if err != nil {
 	if err != nil {
-		panic(err)
+		log.Fatal("failed to marshal request: ", err)
 	}
 	}
 	fmt.Print(string(b))
 	fmt.Print(string(b))
 }
 }
@@ -739,7 +868,7 @@ func runWormchainMigrateContractTemplate(cmd *cobra.Command, args []string) {
 
 
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	if err != nil {
 	if err != nil {
-		panic(err)
+		log.Fatal("failed to marshal request: ", err)
 	}
 	}
 	fmt.Print(string(b))
 	fmt.Print(string(b))
 }
 }
@@ -783,7 +912,7 @@ func runWormchainWasmInstantiateAllowlistTemplate(action nodev1.WormchainWasmIns
 
 
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	if err != nil {
 	if err != nil {
-		panic(err)
+		log.Fatal("failed to marshal request: ", err)
 	}
 	}
 	fmt.Print(string(b))
 	fmt.Print(string(b))
 }
 }
@@ -820,7 +949,7 @@ func runGatewayScheduleUpgradeTemplate(cmd *cobra.Command, args []string) {
 
 
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	if err != nil {
 	if err != nil {
-		panic(err)
+		log.Fatal("failed to marshal request: ", err)
 	}
 	}
 	fmt.Print(string(b))
 	fmt.Print(string(b))
 }
 }
@@ -839,7 +968,7 @@ func runGatewayCancelUpgradeTemplate(cmd *cobra.Command, args []string) {
 
 
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	if err != nil {
 	if err != nil {
-		panic(err)
+		log.Fatal("failed to marshal request: ", err)
 	}
 	}
 	fmt.Print(string(b))
 	fmt.Print(string(b))
 }
 }
@@ -866,7 +995,7 @@ func runGatewayIbcComposabilityMwSetContractTemplate(cmd *cobra.Command, args []
 
 
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	if err != nil {
 	if err != nil {
-		panic(err)
+		log.Fatal("failed to marshal request: ", err)
 	}
 	}
 	fmt.Print(string(b))
 	fmt.Print(string(b))
 }
 }
@@ -923,7 +1052,7 @@ func runIbcUpdateChannelChainTemplate(module nodev1.IbcUpdateChannelChainModule)
 
 
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	if err != nil {
 	if err != nil {
-		panic(err)
+		log.Fatal("failed to marshal request: ", err)
 	}
 	}
 	fmt.Print(string(b))
 	fmt.Print(string(b))
 
 
@@ -957,7 +1086,7 @@ func runWormholeRelayerSetDefaultDeliveryProviderTemplate(cmd *cobra.Command, ar
 
 
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	if err != nil {
 	if err != nil {
-		panic(err)
+		log.Fatal("failed to marshal request: ", err)
 	}
 	}
 	fmt.Print(string(b))
 	fmt.Print(string(b))
 }
 }
@@ -1008,7 +1137,7 @@ func runGeneralPurposeGovernanceEvmCallTemplate(cmd *cobra.Command, args []strin
 
 
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	if err != nil {
 	if err != nil {
-		panic(err)
+		log.Fatal("failed to marshal request: ", err)
 	}
 	}
 	fmt.Print(string(b))
 	fmt.Print(string(b))
 }
 }
@@ -1051,7 +1180,7 @@ func runGeneralPurposeGovernanceSolanaCallTemplate(cmd *cobra.Command, args []st
 
 
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
 	if err != nil {
 	if err != nil {
-		panic(err)
+		log.Fatal("failed to marshal request: ", err)
 	}
 	}
 	fmt.Print(string(b))
 	fmt.Print(string(b))
 }
 }
@@ -1097,10 +1226,10 @@ func parseChainID(name string) (vaa.ChainID, error) {
 		return s, nil
 		return s, nil
 	}
 	}
 
 
-	// parse as uint32
-	i, err := strconv.ParseUint(name, 10, 32)
+	// parse as uint16
+	i, err := strconv.ParseUint(name, 10, 16)
 	if err != nil {
 	if err != nil {
-		return 0, fmt.Errorf("failed to parse as name or uint32: %v", err)
+		return 0, fmt.Errorf("failed to parse as name or uint16: %v", err)
 	}
 	}
 
 
 	return vaa.ChainID(i), nil
 	return vaa.ChainID(i), nil

+ 2 - 2
node/pkg/adminrpc/adminserver.go

@@ -251,8 +251,8 @@ func accountantModifyBalance(req *nodev1.AccountantModifyBalance, timestamp time
 		return nil, errors.New("invalid new token address (expected 32 bytes)")
 		return nil, errors.New("invalid new token address (expected 32 bytes)")
 	}
 	}
 
 
-	if len(req.Reason) > 32 {
-		return nil, errors.New("the reason should not be larger than 32 bytes")
+	if len(req.Reason) > vaa.AccountantModifyBalanceReasonLength {
+		return nil, fmt.Errorf("the reason should not be larger than %d bytes", vaa.AccountantModifyBalanceReasonLength)
 	}
 	}
 
 
 	amount_big := big.NewInt(0)
 	amount_big := big.NewInt(0)

+ 32 - 11
node/pkg/adminrpc/prototext_test.go

@@ -352,9 +352,9 @@ var adminCommandTest = []adminCommandTestEntry{
 				}`,
 				}`,
 	},
 	},
 
 
-	// TODO: There is no admin template command for AccountantModifyBalance. Issue #3902.
+	// build/bin/guardiand template accountant-modify-balance --target-chain-id 3104 --sequence 3 --chain-id 1 --token-chain-id 2 --token-address 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 --action 1 --amount 12000000000000 --reason "fix bad value"
 	{
 	{
-		label:   "AccountantModifyBalance success",
+		label:   "AccountantModifyBalance add success",
 		errText: "",
 		errText: "",
 		prototext: `
 		prototext: `
 				current_set_index: 4
 				current_set_index: 4
@@ -368,12 +368,33 @@ var adminCommandTest = []adminCommandTestEntry{
 						chain_id: 1
 						chain_id: 1
 						token_chain: 2
 						token_chain: 2
 						token_address: "000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
 						token_address: "000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
-						kind: 1
+						kind:  MODIFICATION_KIND_ADD
 						amount: "12000000000000"
 						amount: "12000000000000"
 						reason: "fix bad value"
 						reason: "fix bad value"
 					}
 					}
 				}`,
 				}`,
 	},
 	},
+	{
+		label:   "AccountantModifyBalance subtract success",
+		errText: "",
+		prototext: `
+				current_set_index: 4
+				messages: {
+					sequence: 315027427769585223
+					nonce: 2920957782
+					accountant_modify_balance: {
+						module:  "GlobalAccountant"
+						target_chain_id: 3104
+						sequence: 3
+						chain_id: 1
+						token_chain: 2
+						token_address: "000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
+						kind:  MODIFICATION_KIND_SUBTRACT
+						amount: "12000000000"
+						reason: "fix bad value"
+					}
+				}`,
+	},
 	{
 	{
 		label:   "AccountantModifyBalance invalid target chain id",
 		label:   "AccountantModifyBalance invalid target chain id",
 		errText: "invalid target_chain_id",
 		errText: "invalid target_chain_id",
@@ -389,7 +410,7 @@ var adminCommandTest = []adminCommandTestEntry{
 						chain_id: 1
 						chain_id: 1
 						token_chain: 2
 						token_chain: 2
 						token_address: "000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
 						token_address: "000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
-						kind: 1
+						kind:  MODIFICATION_KIND_ADD
 						amount: "12000000000000"
 						amount: "12000000000000"
 						reason: "fix bad value"
 						reason: "fix bad value"
 					}
 					}
@@ -410,7 +431,7 @@ var adminCommandTest = []adminCommandTestEntry{
 						chain_id: 65536
 						chain_id: 65536
 						token_chain: 2
 						token_chain: 2
 						token_address: "000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
 						token_address: "000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
-						kind: 1
+						kind:  MODIFICATION_KIND_ADD
 						amount: "12000000000000"
 						amount: "12000000000000"
 						reason: "fix bad value"
 						reason: "fix bad value"
 					}
 					}
@@ -431,7 +452,7 @@ var adminCommandTest = []adminCommandTestEntry{
 						chain_id: 1
 						chain_id: 1
 						token_chain: 65536
 						token_chain: 65536
 						token_address: "000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
 						token_address: "000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
-						kind: 1
+						kind:  MODIFICATION_KIND_ADD
 						amount: "12000000000000"
 						amount: "12000000000000"
 						reason: "fix bad value"
 						reason: "fix bad value"
 					}
 					}
@@ -452,7 +473,7 @@ var adminCommandTest = []adminCommandTestEntry{
 						chain_id: 1
 						chain_id: 1
 						token_chain: 2
 						token_chain: 2
 						token_address: "Hello, World!"
 						token_address: "Hello, World!"
-						kind: 1
+						kind:  MODIFICATION_KIND_ADD
 						amount: "12000000000000"
 						amount: "12000000000000"
 						reason: "fix bad value"
 						reason: "fix bad value"
 					}
 					}
@@ -473,7 +494,7 @@ var adminCommandTest = []adminCommandTestEntry{
 						chain_id: 1
 						chain_id: 1
 						token_chain: 2
 						token_chain: 2
 						token_address: "0000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
 						token_address: "0000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
-						kind: 1
+						kind:  MODIFICATION_KIND_ADD
 						amount: "12000000000000"
 						amount: "12000000000000"
 						reason: "fix bad value"
 						reason: "fix bad value"
 					}
 					}
@@ -494,7 +515,7 @@ var adminCommandTest = []adminCommandTestEntry{
 						chain_id: 1
 						chain_id: 1
 						token_chain: 2
 						token_chain: 2
 						token_address: "000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
 						token_address: "000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
-						kind: 1
+						kind:  MODIFICATION_KIND_ADD
 						amount: "12000000000000"
 						amount: "12000000000000"
 						reason: "reason is too long!!!!!!!!!!!!!!!"
 						reason: "reason is too long!!!!!!!!!!!!!!!"
 					}
 					}
@@ -515,7 +536,7 @@ var adminCommandTest = []adminCommandTestEntry{
 						chain_id: 1
 						chain_id: 1
 						token_chain: 2
 						token_chain: 2
 						token_address: "000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
 						token_address: "000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
-						kind: 1
+						kind:  MODIFICATION_KIND_ADD
 						amount: "Hello, World!"
 						amount: "Hello, World!"
 						reason: "fix bad value"
 						reason: "fix bad value"
 					}
 					}
@@ -536,7 +557,7 @@ var adminCommandTest = []adminCommandTestEntry{
 						chain_id: 1
 						chain_id: 1
 						token_chain: 2
 						token_chain: 2
 						token_address: "000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
 						token_address: "000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
-						kind: 1
+						kind:  MODIFICATION_KIND_ADD
 						amount: "115792089237316195423570985008687907853269984665640564039457584007913129639936"
 						amount: "115792089237316195423570985008687907853269984665640564039457584007913129639936"
 						reason: "fix bad value"
 						reason: "fix bad value"
 					}
 					}

+ 3 - 1
sdk/vaa/payloads.go

@@ -316,6 +316,8 @@ func (r BodyRecoverChainId) Serialize() ([]byte, error) {
 	return buf.Bytes(), nil
 	return buf.Bytes(), nil
 }
 }
 
 
+const AccountantModifyBalanceReasonLength = 32
+
 func (r BodyAccountantModifyBalance) Serialize() ([]byte, error) {
 func (r BodyAccountantModifyBalance) Serialize() ([]byte, error) {
 	payload := &bytes.Buffer{}
 	payload := &bytes.Buffer{}
 	MustWrite(payload, binary.BigEndian, r.Sequence)
 	MustWrite(payload, binary.BigEndian, r.Sequence)
@@ -327,7 +329,7 @@ func (r BodyAccountantModifyBalance) Serialize() ([]byte, error) {
 	amount_bytes := r.Amount.Bytes32()
 	amount_bytes := r.Amount.Bytes32()
 	payload.Write(amount_bytes[:])
 	payload.Write(amount_bytes[:])
 
 
-	reason := make([]byte, 32)
+	reason := make([]byte, AccountantModifyBalanceReasonLength)
 
 
 	// truncate or pad "reason"
 	// truncate or pad "reason"
 	count := copy(reason, r.Reason)
 	count := copy(reason, r.Reason)