Skip to content

Commit

Permalink
move subnet validator
Browse files Browse the repository at this point in the history
  • Loading branch information
sukantoraymond committed Aug 22, 2024
1 parent a638db7 commit 87c9443
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
12 changes: 0 additions & 12 deletions avalanche/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,3 @@ type PrimaryNetworkValidatorParams struct {
// For more information on delegation fee, please head to https://docs.avax.network/nodes/validate/node-validator#delegation-fee-rate
DelegationFee uint32
}

type SubnetValidatorParams struct {
// NodeID is the unique identifier of the node to be added as a validator on the specified Subnet.
NodeID ids.NodeID
// Duration is how long the node will be staking the Subnet
// Duration has to be less than or equal to the duration that the node will be validating the Primary
// Network
Duration time.Duration
// Weight is the validator's weight when sampling validators.
// Weight for subnet validators is set to 20 by default
Weight uint64
}
17 changes: 14 additions & 3 deletions subnet/add_validator_subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package subnet
import (
"errors"
"fmt"
"github.com/ava-labs/avalanche-tooling-sdk-go/avalanche"
"time"

"github.com/ava-labs/avalanche-tooling-sdk-go/multisig"
Expand All @@ -23,10 +22,22 @@ var (
ErrEmptySubnetAuth = errors.New("no subnet auth keys is provided")
)

type SubnetValidatorParams struct {
// NodeID is the unique identifier of the node to be added as a validator on the specified Subnet.
NodeID ids.NodeID
// Duration is how long the node will be staking the Subnet
// Duration has to be less than or equal to the duration that the node will be validating the Primary
// Network
Duration time.Duration
// Weight is the validator's weight when sampling validators.
// Weight for subnet validators is set to 20 by default
Weight uint64
}

// AddValidator adds validator to subnet
// Before an Avalanche Node can be added as a validator to a Subnet, the node must already be
// tracking the subnet
func (c *Subnet) AddValidator(wallet wallet.Wallet, validatorInput avalanche.SubnetValidatorParams) (*multisig.Multisig, error) {
// tracking the subnet, which can be done by calling SyncSubnets in node package
func (c *Subnet) AddValidator(wallet wallet.Wallet, validatorInput SubnetValidatorParams) (*multisig.Multisig, error) {
if validatorInput.NodeID == ids.EmptyNodeID {
return nil, ErrEmptyValidatorNodeID
}
Expand Down
2 changes: 1 addition & 1 deletion subnet/add_validator_subnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func TestValidateSubnet(t *testing.T) {
panic(err)
}

validator := avalanche.SubnetValidatorParams{
validator := SubnetValidatorParams{
NodeID: nodeID,
// Validate Subnet for 48 hours
Duration: 48 * time.Hour,
Expand Down

0 comments on commit 87c9443

Please sign in to comment.