Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACP-77: Update ConvertSubnetTx #3397

Draft
wants to merge 40 commits into
base: implement-acp-77-deactivation
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
b22efc6
Update SecondsUntil
StephenButtolph Sep 17, 2024
a32cec5
Prevent flaky test
StephenButtolph Sep 18, 2024
eb62df7
Implement acp-77 fee configs
StephenButtolph Sep 18, 2024
c358e0b
Merge branch 'implement-acp-77-config' into implement-acp-tx-base
StephenButtolph Sep 18, 2024
83d6932
Merge branch 'implement-acp-77-sov-validators-state' into implement-a…
StephenButtolph Sep 18, 2024
6b7a685
Add initial validators to convertSubnetTx
StephenButtolph Sep 18, 2024
5a6d1b6
Add additional checks
StephenButtolph Sep 18, 2024
d8bdb24
comment
StephenButtolph Sep 18, 2024
03d56aa
cleanup complexity
StephenButtolph Sep 18, 2024
a46ced0
test complexity
StephenButtolph Sep 18, 2024
6f64e69
nit
StephenButtolph Sep 18, 2024
ba45ab7
Add todo
StephenButtolph Sep 18, 2024
b2d76fe
Remove debug print
StephenButtolph Sep 18, 2024
9e6b6b1
nit
StephenButtolph Sep 18, 2024
ca33847
Update read/write complexity
StephenButtolph Sep 18, 2024
53e621b
Update execution tests
StephenButtolph Sep 18, 2024
ed2be76
merged
StephenButtolph Sep 18, 2024
831cb6e
merged
StephenButtolph Sep 20, 2024
f6cf86d
Merge branch 'implement-acp-77-sov-validators-state' into implement-a…
StephenButtolph Sep 22, 2024
7cea515
Merge branch 'implement-acp-77-sov-validators-state' into implement-a…
StephenButtolph Sep 23, 2024
dbd320a
Merge branch 'implement-acp-77-deactivation' into implement-acp-77-up…
StephenButtolph Sep 24, 2024
39fba65
Update wallet example
StephenButtolph Sep 24, 2024
f6b51c0
Merge branch 'implement-acp-77-deactivation' into implement-acp-77-up…
StephenButtolph Sep 24, 2024
ca79f6f
Merge branch 'implement-acp-77-deactivation' into implement-acp-77-up…
StephenButtolph Sep 25, 2024
7fe9af9
Merge branch 'implement-acp-77-deactivation' into implement-acp-77-up…
StephenButtolph Oct 1, 2024
443f2b5
Merge branch 'implement-acp-77-deactivation' into implement-acp-77-up…
StephenButtolph Oct 1, 2024
d49f77b
Update convertSubnetTx
StephenButtolph Oct 1, 2024
09c9155
merged
StephenButtolph Oct 2, 2024
cc9f7ae
write conversionID
StephenButtolph Oct 2, 2024
f13cf7a
Update validationID
StephenButtolph Oct 2, 2024
646ce06
update nodeID to variable length
StephenButtolph Oct 2, 2024
c757fac
fix executor
StephenButtolph Oct 2, 2024
e64230d
Fix verification
StephenButtolph Oct 3, 2024
3cac2b2
Merge branch 'implement-acp-77-deactivation' into implement-acp-77-up…
StephenButtolph Oct 3, 2024
e39f5c3
Merge branch 'implement-acp-77-deactivation' into implement-acp-77-up…
StephenButtolph Oct 3, 2024
232b065
Fix executor unit tests
StephenButtolph Oct 3, 2024
30537a9
Merge branch 'implement-acp-77-deactivation' into implement-acp-77-up…
StephenButtolph Oct 3, 2024
51c7c7a
Fix fee unit tests
StephenButtolph Oct 3, 2024
3ebeaba
Fix more unit tests
StephenButtolph Oct 3, 2024
363e2be
Fix e2e test
StephenButtolph Oct 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion snow/engine/snowman/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (e *Engine) Gossip(ctx context.Context) error {
// nodes with a large amount of stake weight.
vdrID, ok := e.ConnectedValidators.SampleValidator()
if !ok {
e.Ctx.Log.Warn("skipping block gossip",
e.Ctx.Log.Debug("skipping block gossip",
zap.String("reason", "no connected validators"),
)
return nil
Expand Down
59 changes: 56 additions & 3 deletions vms/platformvm/txs/convert_subnet_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,26 @@ import (

"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/snow"
"github.com/ava-labs/avalanchego/utils"
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/vms/components/verify"
"github.com/ava-labs/avalanchego/vms/platformvm/fx"
"github.com/ava-labs/avalanchego/vms/platformvm/signer"
"github.com/ava-labs/avalanchego/vms/types"
)

const MaxSubnetAddressLength = 4096

var (
_ UnsignedTx = (*TransferSubnetOwnershipTx)(nil)
_ UnsignedTx = (*ConvertSubnetTx)(nil)
_ utils.Sortable[ConvertSubnetValidator] = ConvertSubnetValidator{}

ErrConvertPermissionlessSubnet = errors.New("cannot convert a permissionless subnet")
ErrAddressTooLong = errors.New("address is too long")
ErrConvertPermissionlessSubnet = errors.New("cannot convert a permissionless subnet")
ErrAddressTooLong = errors.New("address is too long")
ErrConvertMustIncludeValidators = errors.New("conversion must include at least one validator")
ErrConvertValidatorsNotSortedAndUnique = errors.New("conversion validators must be sorted and unique")
ErrZeroWeight = errors.New("validator weight must be non-zero")
ErrMissingPublicKey = errors.New("missing public key")
)

type ConvertSubnetTx struct {
Expand All @@ -31,6 +39,8 @@ type ConvertSubnetTx struct {
ChainID ids.ID `serialize:"true" json:"chainID"`
// Address of the Subnet manager
Address types.JSONByteSlice `serialize:"true" json:"address"`
// Initial pay-as-you-go validators for the Subnet
Validators []ConvertSubnetValidator `serialize:"true" json:"validators"`
StephenButtolph marked this conversation as resolved.
Show resolved Hide resolved
// Authorizes this conversion
SubnetAuth verify.Verifiable `serialize:"true" json:"subnetAuthorization"`
}
Expand All @@ -46,11 +56,20 @@ func (tx *ConvertSubnetTx) SyntacticVerify(ctx *snow.Context) error {
return ErrConvertPermissionlessSubnet
case len(tx.Address) > MaxSubnetAddressLength:
return ErrAddressTooLong
case len(tx.Validators) == 0:
return ErrConvertMustIncludeValidators
case !utils.IsSortedAndUnique(tx.Validators):
return ErrConvertValidatorsNotSortedAndUnique
}

if err := tx.BaseTx.SyntacticVerify(ctx); err != nil {
return err
}
for _, vdr := range tx.Validators {
if err := vdr.Verify(); err != nil {
return err
}
}
if err := tx.SubnetAuth.Verify(); err != nil {
return err
}
Expand All @@ -62,3 +81,37 @@ func (tx *ConvertSubnetTx) SyntacticVerify(ctx *snow.Context) error {
func (tx *ConvertSubnetTx) Visit(visitor Visitor) error {
return visitor.ConvertSubnetTx(tx)
}

type ConvertSubnetValidator struct {
// TODO: Must be Ed25519 NodeID
NodeID ids.NodeID `serialize:"true" json:"nodeID"`
// Weight of this validator used when sampling
Weight uint64 `serialize:"true" json:"weight"`
// Initial balance for this validator
Balance uint64 `serialize:"true" json:"balance"`
Comment on lines +91 to +92
Copy link
Contributor Author

@StephenButtolph StephenButtolph Sep 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR does allow the validator to be initially inactive (by having a 0 balance)

// [Signer] is the BLS key for this validator.
// Note: We do not enforce that the BLS key is unique across all validators.
// This means that validators can share a key if they so choose.
// However, a NodeID + Subnet does uniquely map to a BLS key
Signer signer.Signer `serialize:"true" json:"signer"`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than using signer.Signer - should we just us the bls.ProofOfPossession struct? If we were to ever change the format of the BLS key... having the interface may be nice... But it feels a bit weird to use an interface where only one value is valid.

// Leftover $AVAX from the [Balance] will be issued to this owner once it is
// removed from the validator set.
RemainingBalanceOwner fx.Owner `serialize:"true" json:"remainingBalanceOwner"`
}

func (v ConvertSubnetValidator) Compare(o ConvertSubnetValidator) int {
return v.NodeID.Compare(o.NodeID)
}

func (v *ConvertSubnetValidator) Verify() error {
if v.Weight == 0 {
return ErrZeroWeight
}
StephenButtolph marked this conversation as resolved.
Show resolved Hide resolved
if err := verify.All(v.Signer, v.RemainingBalanceOwner); err != nil {
return err
}
if v.Signer.Key() == nil {
return ErrMissingPublicKey
}
return nil
}
Loading
Loading