From 8526670f303fdb37b11e0405b83af815b6f228e9 Mon Sep 17 00:00:00 2001 From: Raymond Sukanto Date: Wed, 2 Oct 2024 20:11:42 -0400 Subject: [PATCH] set subnet validator weight --- go.mod | 2 +- go.sum | 4 ++-- pkg/subnet/public.go | 32 ++++++++++---------------------- 3 files changed, 13 insertions(+), 25 deletions(-) diff --git a/go.mod b/go.mod index 56ebe700e..b2a8f3348 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.22.8 require ( github.com/ava-labs/apm v1.0.0 github.com/ava-labs/avalanche-network-runner v1.8.4-0.20240930181211-bfc2f5f85973 - github.com/ava-labs/avalanchego v1.11.12-rc.2.0.20241002224617-90256044ffad + github.com/ava-labs/avalanchego v1.11.12-rc.2.0.20241002224658-b6cbfeed382d github.com/ava-labs/awm-relayer v1.4.1-0.20240910171125-3c2ae781fb32 github.com/ava-labs/coreth v0.13.8 github.com/ava-labs/subnet-evm v0.6.10 diff --git a/go.sum b/go.sum index ff2e08c18..6f2dce070 100644 --- a/go.sum +++ b/go.sum @@ -85,8 +85,8 @@ github.com/ava-labs/apm v1.0.0 h1:6FwozH67hEkbWVsOXNZGexBy5KLpNeYucN9zcFUHv+Q= github.com/ava-labs/apm v1.0.0/go.mod h1:TJL7pTlZNvQatsQPsLUtDHApEwVZ/qS7iSNtRFU83mc= github.com/ava-labs/avalanche-network-runner v1.8.4-0.20240930181211-bfc2f5f85973 h1:rsAfxjQLCs9dyDGqUZK29fGDrW4uzLzYjQLUVMEkvdQ= github.com/ava-labs/avalanche-network-runner v1.8.4-0.20240930181211-bfc2f5f85973/go.mod h1:T6AYu2HBw4N6oAIRJWATSLx3/uWLVVADTbfSCIcSlEY= -github.com/ava-labs/avalanchego v1.11.12-rc.2.0.20241002224617-90256044ffad h1:2FArSjp+e97YEIyUhUWVxwhVOmHthcG6SByYq+C8kDQ= -github.com/ava-labs/avalanchego v1.11.12-rc.2.0.20241002224617-90256044ffad/go.mod h1:qSHmog3wMVjo/ruIAQo0ppXAilyni07NIu5K88RyhWE= +github.com/ava-labs/avalanchego v1.11.12-rc.2.0.20241002224658-b6cbfeed382d h1:zENrqqsYaWnPklhDbYkzOA61AlY6aHUNpSuY7BHuslE= +github.com/ava-labs/avalanchego v1.11.12-rc.2.0.20241002224658-b6cbfeed382d/go.mod h1:qSHmog3wMVjo/ruIAQo0ppXAilyni07NIu5K88RyhWE= github.com/ava-labs/awm-relayer v1.4.1-0.20240910171125-3c2ae781fb32 h1:KcrFCyWU6A+GJ/E2fZSI6qGjU3M2NPl7QrzJ5fH3t2Q= github.com/ava-labs/awm-relayer v1.4.1-0.20240910171125-3c2ae781fb32/go.mod h1:Pen08eCEURnN4unfkAdYEIoKo/4RujaLV6ISgRUHj5g= github.com/ava-labs/coreth v0.13.8 h1:f14X3KgwHl9LwzfxlN6S4bbn5VA2rhEsNnHaRLSTo/8= diff --git a/pkg/subnet/public.go b/pkg/subnet/public.go index a4c80f149..4713bdc8a 100644 --- a/pkg/subnet/public.go +++ b/pkg/subnet/public.go @@ -113,31 +113,19 @@ func (d *PublicDeployer) AddValidatorNonSOV( return false, tx, remainingSubnetAuthKeys, nil } -// type SetSubnetValidatorWeightTx struct { -// // Metadata, inputs and outputs -// BaseTx -// // AddressedCall with Payload: -// // - ValidationID (SHA256 of the AddressedCall Payload of the RegisterSubnetValidatorTx adding the validator) -// // - Nonce -// // - Weight -// Message warp.Message `json:"message"` -// } func (d *PublicDeployer) SetSubnetValidatorWeight( message warp.Message, ) (*txs.Tx, error) { - // create tx - //unsignedTx, err := wallet.P().Builder().NewSetSubnetValidatorWeightTx(args...) - //if err != nil { - // return nil, fmt.Errorf("error building tx: %w", err) - //} - //tx := txs.Tx{Unsigned: unsignedTx} - // sign with current wallet that contains EVM address controlling POA Validator Manager - // TODO: change code below - //if err := wallet.P().Signer().Sign(context.Background(), &tx); err != nil { - // return nil, fmt.Errorf("error signing tx: %w", err) - //} - //return &tx, nil - return nil, nil + wallet, err := d.loadCacheWallet() + if err != nil { + return nil, err + } + //create tx + tx, err := wallet.P().IssueSetSubnetValidatorWeightTx(message.Bytes()) + if err != nil { + return nil, fmt.Errorf("error building tx: %w", err) + } + return tx, nil } func (d *PublicDeployer) RegisterSubnetValidator(