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

Merged
merged 352 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
352 commits
Select commit Hold shift + click to select a range
30efc6d
ACP-77: Add warp message helpers to follow new specification
StephenButtolph Oct 1, 2024
903f7c3
migrate x/sync to p2p
joshua-kim Jun 11, 2024
34fe3a6
nit
joshua-kim Sep 10, 2024
b9d5507
add acp-118 implementation
joshua-kim Sep 10, 2024
99f0cde
undo diff
joshua-kim Oct 1, 2024
00fc8d1
nit
joshua-kim Oct 1, 2024
c08a1d7
undo
joshua-kim Oct 1, 2024
9d07a45
nit
joshua-kim Oct 1, 2024
f91e0a8
nit
joshua-kim Oct 1, 2024
a35b090
add context
joshua-kim Oct 1, 2024
dd7029c
fix
joshua-kim Oct 1, 2024
8978452
rename attestor -> verifier
joshua-kim Oct 1, 2024
a383209
nit
joshua-kim Oct 1, 2024
8b52ead
nit
joshua-kim Oct 1, 2024
3859d98
Merge branch 'master' into implement-acp-77-update-warp-messages
StephenButtolph Oct 1, 2024
0462fda
Merge branch 'acp-118-handler' into implement-acp-77-temp.0
StephenButtolph Oct 1, 2024
5a362bd
Merge branch 'implement-acp-77-temp.0' into implement-acp-77-sov-vali…
StephenButtolph Oct 1, 2024
3927546
Merge branch 'implement-acp-77-sov-validators-state' into implement-a…
StephenButtolph Oct 1, 2024
a3cc8e8
merged
StephenButtolph Oct 1, 2024
32cb1f0
Merge branch 'implement-acp-77-sov-validators-state' into implement-a…
StephenButtolph Oct 1, 2024
7fe9af9
Merge branch 'implement-acp-77-deactivation' into implement-acp-77-up…
StephenButtolph Oct 1, 2024
ddb9ba6
Add deactivation owner
StephenButtolph Oct 1, 2024
d806f8d
Merge branch 'implement-acp-77-sov-validators-state' into implement-a…
StephenButtolph Oct 1, 2024
556f1eb
fix tests
StephenButtolph Oct 1, 2024
6fbbf17
Merge branch 'implement-acp-77-sov-validators-state' into implement-a…
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
891bca4
Store conversionID
StephenButtolph Oct 2, 2024
a33e0df
Include validationID
StephenButtolph Oct 2, 2024
8fee2b4
Merge branch 'master' into implement-acp-77-sov-validators-state
StephenButtolph Oct 2, 2024
023aa18
Merge branch 'implement-acp-77-sov-validators-state' into implement-a…
StephenButtolph Oct 2, 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
0d3d3b9
Merge branch 'master' into implement-acp-77-sov-validators-state
StephenButtolph Oct 3, 2024
4ed0a96
Merge branch 'implement-acp-77-sov-validators-state' into implement-a…
StephenButtolph Oct 3, 2024
3cac2b2
Merge branch 'implement-acp-77-deactivation' into implement-acp-77-up…
StephenButtolph Oct 3, 2024
01c9072
remove unexpected file
StephenButtolph Oct 3, 2024
bcd9f34
Merge branch 'implement-acp-77-sov-validators-state' into implement-a…
StephenButtolph Oct 3, 2024
0893cea
Lint
StephenButtolph Oct 3, 2024
39fff73
Fix unit tests
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
01de954
Merge branch 'master' into implement-acp-77-sov-validators-state
StephenButtolph Oct 3, 2024
42fdd43
Merge branch 'implement-acp-77-sov-validators-state' into implement-a…
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
1ca7524
Merge branch 'master' into implement-acp-77-sov-validators-state
StephenButtolph Oct 7, 2024
dc0885c
Merge branch 'implement-acp-77-sov-validators-state' into implement-a…
StephenButtolph Oct 7, 2024
fe2a89a
Merge branch 'implement-acp-77-deactivation' into implement-acp-77-up…
StephenButtolph Oct 7, 2024
237f590
Allow xsvm to sign arbitrary warp messages
StephenButtolph Oct 7, 2024
bc53046
Merge branch 'implement-acp-77-allow-xsvm-signing' into implement-acp…
StephenButtolph Oct 7, 2024
f1d538a
Merge branch 'implement-acp-77-sov-validators-state' into implement-a…
StephenButtolph Oct 7, 2024
107ed35
Merge branch 'implement-acp-77-deactivation' into implement-acp-77-up…
StephenButtolph Oct 7, 2024
127a3fa
nit
StephenButtolph Oct 7, 2024
061aa6e
Merge branch 'implement-acp-77-sov-validators-state' into implement-a…
StephenButtolph Oct 7, 2024
3f21dee
Merge branch 'implement-acp-77-deactivation' into implement-acp-77-up…
StephenButtolph Oct 7, 2024
71b997c
Expand e2e test
StephenButtolph Oct 7, 2024
1562139
Merge branch 'implement-acp-77-update-convert-subnet-tx' of github.co…
StephenButtolph Oct 7, 2024
567b00f
fix test
StephenButtolph Oct 7, 2024
1471214
reduce diff
StephenButtolph Oct 8, 2024
39beefb
backport tests
StephenButtolph Oct 8, 2024
19d4c35
nit cleanup
StephenButtolph Oct 8, 2024
ab85ce1
Add ConvertSubnetTx complexity tests
StephenButtolph Oct 8, 2024
2b407e9
Update dynamic fee defaults
StephenButtolph Oct 8, 2024
1986804
nit cleanup
StephenButtolph Oct 9, 2024
8279972
Remove unexpected block unwrapping
StephenButtolph Oct 9, 2024
3d5d6c1
Merge branch 'fix-block-passing' into implement-acp-77-sov-validators…
StephenButtolph Oct 10, 2024
b5741c6
Merge branch 'implement-acp-77-sov-validators-state' into implement-a…
StephenButtolph Oct 10, 2024
8d754c0
Merge branch 'implement-acp-77-deactivation' into implement-acp-77-up…
StephenButtolph Oct 10, 2024
8d7adfc
Remove unused testing code
StephenButtolph Oct 11, 2024
d7ba4fb
Merge branch 'master' into implement-acp-77-sov-validators-state
StephenButtolph Oct 11, 2024
89603c2
Merge branch 'implement-acp-77-sov-validators-state' into implement-a…
StephenButtolph Oct 11, 2024
56bdf75
Merge branch 'implement-acp-77-deactivation' into implement-acp-77-up…
StephenButtolph Oct 11, 2024
d550c97
Merge branch 'master' into implement-acp-77-sov-validators-state
StephenButtolph Oct 14, 2024
3d3ec3e
Merge branch 'implement-acp-77-sov-validators-state' into implement-a…
StephenButtolph Oct 14, 2024
1cdaac2
Merge branch 'implement-acp-77-deactivation' into implement-acp-77-up…
StephenButtolph Oct 14, 2024
915de36
Fix merge
StephenButtolph Oct 14, 2024
9226649
Merge branch 'master' into implement-acp-77-sov-validators-state
StephenButtolph Oct 15, 2024
281ab34
Merge branch 'implement-acp-77-sov-validators-state' into implement-a…
StephenButtolph Oct 15, 2024
486226d
Merge branch 'implement-acp-77-deactivation' into implement-acp-77-up…
StephenButtolph Oct 15, 2024
83cc0dc
merged
StephenButtolph Oct 19, 2024
702639a
ACP-77: Add ConversionID to state
StephenButtolph Oct 19, 2024
4b562f0
nit
StephenButtolph Oct 19, 2024
7f3dd5e
nit
StephenButtolph Oct 19, 2024
599f1e6
Merge branch 'implement-acp-77-sov-validators-state' into implement-a…
StephenButtolph Oct 19, 2024
b9c47de
merged
StephenButtolph Oct 19, 2024
f40c1b3
nit
StephenButtolph Oct 19, 2024
f69ec51
merged
StephenButtolph Oct 19, 2024
51f009b
nit
StephenButtolph Oct 19, 2024
36714ed
Merge branch 'implement-acp-77-add-conversion-id' into implement-acp-…
StephenButtolph Oct 19, 2024
05a7b13
nit
StephenButtolph Oct 19, 2024
09c5126
Merge branch 'implement-acp-77-add-conversion-id' into implement-acp-…
StephenButtolph Oct 19, 2024
a1db89e
nit
StephenButtolph Oct 19, 2024
2e7595c
Merge branch 'implement-acp-77-add-conversion-id' into implement-acp-…
StephenButtolph Oct 19, 2024
2fb7637
Merge branch 'implement-acp-77-sov-validators-state' into implement-a…
StephenButtolph Oct 19, 2024
30d788f
merged
StephenButtolph Oct 19, 2024
575b36a
remove unneeded assignment
StephenButtolph Oct 19, 2024
d2d0f69
update comment
StephenButtolph Oct 19, 2024
b6b6515
update comment
StephenButtolph Oct 19, 2024
6ffcd1b
update doc
StephenButtolph Oct 19, 2024
ad00180
Address comments
StephenButtolph Oct 20, 2024
f1b07d2
nit
StephenButtolph Oct 20, 2024
7fb99c0
fix unit tests
StephenButtolph Oct 20, 2024
65b5d50
Merge branch 'implement-acp-77-add-conversion-id' into implement-acp-…
StephenButtolph Oct 20, 2024
8791e78
merged
StephenButtolph Oct 20, 2024
f31cfc6
Add SoV Excess to P-chain state
StephenButtolph Oct 20, 2024
fe9a76d
merged
StephenButtolph Oct 20, 2024
369545d
Merge branch 'implement-acp-77-sov-validators-state' into implement-a…
StephenButtolph Oct 20, 2024
69adceb
merged
StephenButtolph Oct 20, 2024
58d5b8d
Populate BLS key diffs for subnet validators
StephenButtolph Oct 21, 2024
273fbbe
Populate BLS key diffs for subnet validators
StephenButtolph Oct 21, 2024
290ef97
Update mocks
StephenButtolph Oct 22, 2024
9155e1f
Fix tests
StephenButtolph Oct 22, 2024
cadf8f7
Merge branch 'master' into populate-subnet-public-key-diffs
StephenButtolph Oct 22, 2024
803d0c4
nit
StephenButtolph Oct 22, 2024
76f4eee
Merge branch 'populate-subnet-public-key-diffs' of github.com:ava-lab…
StephenButtolph Oct 22, 2024
a2c7773
Update test and populate public keys during startup
StephenButtolph Oct 22, 2024
95c42a1
comment
StephenButtolph Oct 23, 2024
3d7bd81
Merge branch 'master' into populate-subnet-public-key-diffs
StephenButtolph Oct 23, 2024
bbc395b
merged
StephenButtolph Oct 23, 2024
3a03597
merged
StephenButtolph Oct 23, 2024
21cdc32
Update P-chain state staker tests
StephenButtolph Oct 24, 2024
845f1d2
merged
StephenButtolph Oct 24, 2024
91a7cd7
fix test
StephenButtolph Oct 24, 2024
df02f3c
Merge branch 'update-state-staker-tests' into populate-subnet-public-…
StephenButtolph Oct 24, 2024
c848fee
fix test
StephenButtolph Oct 24, 2024
79c9b40
nit
StephenButtolph Oct 24, 2024
d8819fc
Merge branch 'master' into update-state-staker-tests
StephenButtolph Oct 24, 2024
667002e
Merge branch 'update-state-staker-tests' into populate-subnet-public-…
StephenButtolph Oct 24, 2024
31be1e2
merged
StephenButtolph Oct 24, 2024
fb7f564
Merge branch 'implement-acp-77-sov-validators-state' into implement-a…
StephenButtolph Oct 24, 2024
cd317f5
Merge branch 'implement-acp-77-deactivation' into implement-acp-77-up…
StephenButtolph Oct 24, 2024
8f0a080
merged
StephenButtolph Oct 24, 2024
d482de8
Merge branch 'populate-subnet-public-key-diffs' into implement-acp-77…
StephenButtolph Oct 24, 2024
fc27346
Merge branch 'implement-acp-77-sov-validators-state' into implement-a…
StephenButtolph Oct 24, 2024
e8b21ec
Verify no SoV + legacy overlap
StephenButtolph Oct 24, 2024
7f517c7
Fix legacy validator migration
StephenButtolph Oct 24, 2024
7d0d7e5
merged
StephenButtolph Oct 25, 2024
08bd9e3
ACP-77: Add subnetIDNodeID struct
StephenButtolph Oct 25, 2024
78c1c3d
nit
StephenButtolph Oct 26, 2024
6547c6d
Merge branch 'master' into implement-acp-77-add-subnetid-nodeid
StephenButtolph Oct 26, 2024
38ee164
Merge branch 'implement-acp-77-add-subnetid-nodeid' into implement-ac…
StephenButtolph Oct 26, 2024
d2137ef
fix merge
StephenButtolph Oct 26, 2024
5845d11
Split writeCurrentStakers into multiple functions
StephenButtolph Oct 26, 2024
6c3116a
merged
StephenButtolph Oct 27, 2024
d0d1602
reduce diff
StephenButtolph Oct 27, 2024
d397375
reduce diff
StephenButtolph Oct 27, 2024
5f8a09c
reduce diff
StephenButtolph Oct 27, 2024
3e9dc01
reduce diff
StephenButtolph Oct 27, 2024
da3a726
reduce diff
StephenButtolph Oct 27, 2024
8483ced
cleanup
StephenButtolph Oct 27, 2024
0507ce7
nit
StephenButtolph Oct 27, 2024
0022a65
Merge branch 'refactor-write-current-stakers' into implement-acp-77-s…
StephenButtolph Oct 27, 2024
8bbeee6
Add comment
StephenButtolph Oct 27, 2024
08dd776
comment
StephenButtolph Oct 27, 2024
255b0bf
nit
StephenButtolph Oct 27, 2024
3bc547d
reduce diff
StephenButtolph Oct 27, 2024
bff468d
Merge branch 'master' into refactor-write-current-stakers
StephenButtolph Oct 28, 2024
99f3c97
Merge branch 'refactor-write-current-stakers' into implement-acp-77-s…
StephenButtolph Oct 28, 2024
7cf1668
merged
StephenButtolph Oct 29, 2024
41f78f0
nit
StephenButtolph Oct 29, 2024
29cd6ba
nit
StephenButtolph Oct 29, 2024
8dfcbb1
Fix initValidatorSets
StephenButtolph Oct 29, 2024
ef29548
nit
StephenButtolph Oct 29, 2024
a77fb3c
test subnetIDNodeIDDB
StephenButtolph Oct 29, 2024
ce05dc8
fix comments
StephenButtolph Oct 29, 2024
3d04cef
nit
StephenButtolph Oct 29, 2024
dc35645
nit
StephenButtolph Oct 29, 2024
d472a9f
Reduce diff
StephenButtolph Oct 29, 2024
34ba29b
add comment
StephenButtolph Oct 29, 2024
97029aa
reduce diff
StephenButtolph Oct 30, 2024
dbeee70
Add NumSubnets to the validator manager interface
StephenButtolph Oct 30, 2024
729ded5
merged
StephenButtolph Oct 30, 2024
3621e53
add comment
StephenButtolph Oct 30, 2024
de2be9f
merged
StephenButtolph Oct 30, 2024
92a2277
Delete empty entries
StephenButtolph Oct 30, 2024
6375aa2
simplify state futher
StephenButtolph Oct 30, 2024
aedff15
nit
StephenButtolph Oct 30, 2024
1ac030a
nit
StephenButtolph Oct 30, 2024
9e0d7d5
Add caching
StephenButtolph Oct 31, 2024
9993b05
nit
StephenButtolph Oct 31, 2024
547d426
nit
StephenButtolph Oct 31, 2024
6bcc0ea
Add TODOs
StephenButtolph Oct 31, 2024
6065604
Merge branch 'master' into implement-acp-77-sov-validators-state
StephenButtolph Oct 31, 2024
a7792c7
Add config changes to readme
StephenButtolph Oct 31, 2024
39b961b
Merge branch 'implement-acp-77-sov-validators-state' of github.com:av…
StephenButtolph Oct 31, 2024
4723c46
Improve doc for PutSubnetOnlyValidator
StephenButtolph Oct 31, 2024
46c4889
Merge branch 'master' into implement-acp-77-sov-validators-state
StephenButtolph Oct 31, 2024
a576cd1
merged
StephenButtolph Oct 31, 2024
f1ca6e6
Add test that decreases weight
StephenButtolph Oct 31, 2024
71f88e8
Fix regression
StephenButtolph Oct 31, 2024
c2ffd17
nit
StephenButtolph Oct 31, 2024
2b5d7c7
Merge branch 'implement-acp-77-sov-validators-state' into implement-a…
StephenButtolph Oct 31, 2024
91a6465
nit
StephenButtolph Oct 31, 2024
07370a5
nits
StephenButtolph Oct 31, 2024
23aff43
Add additional test
StephenButtolph Oct 31, 2024
66011f0
Move caching logic
StephenButtolph Nov 1, 2024
32bba0e
Merge branch 'master' into implement-acp-77-sov-validators-state
StephenButtolph Nov 1, 2024
d183148
merged
StephenButtolph Nov 1, 2024
b1bb458
nit
StephenButtolph Nov 1, 2024
ad31107
Add weight diff helpers
StephenButtolph Nov 1, 2024
cee236e
nit
StephenButtolph Nov 1, 2024
900eba3
add -> addOrSub
StephenButtolph Nov 1, 2024
fd48bde
merged
StephenButtolph Nov 2, 2024
7cbf31b
fix merge
StephenButtolph Nov 2, 2024
33d297d
Add test
StephenButtolph Nov 2, 2024
486f732
nit
StephenButtolph Nov 2, 2024
b448a04
reduce diff
StephenButtolph Nov 2, 2024
0685531
Add tests
StephenButtolph Nov 2, 2024
bb9f853
test excess and fees
StephenButtolph Nov 2, 2024
e6e3e76
Merge branch 'implement-acp-77-sov-validators-state' into implement-a…
StephenButtolph Nov 2, 2024
3077356
merged
StephenButtolph Nov 4, 2024
69837c1
improve caching
StephenButtolph Nov 4, 2024
8611fe4
Merge branch 'implement-acp-77-sov-validators-state' into implement-a…
StephenButtolph Nov 4, 2024
a5d3930
cleanup
StephenButtolph Nov 4, 2024
d74cdff
Simplify test
StephenButtolph Nov 4, 2024
7cddfc0
reduce diff
StephenButtolph Nov 4, 2024
afc9054
nit
StephenButtolph Nov 4, 2024
3c8246e
nit
StephenButtolph Nov 4, 2024
1268ed1
nit
StephenButtolph Nov 4, 2024
f7b75bc
nits
StephenButtolph Nov 4, 2024
82a249b
nit
StephenButtolph Nov 4, 2024
d37e9f3
nit
StephenButtolph Nov 5, 2024
9dc642a
num -> net for possibly negative value
StephenButtolph Nov 5, 2024
22de2b1
Address PR comments
StephenButtolph Nov 5, 2024
cc0e0ee
add comments
StephenButtolph Nov 5, 2024
33fea00
Merge branch 'implement-acp-77-sov-validators-state' into implement-a…
StephenButtolph Nov 5, 2024
915eb71
nit
StephenButtolph Nov 5, 2024
3811423
Merge branch 'implement-acp-77-deactivation' into implement-acp-77-up…
StephenButtolph Nov 5, 2024
b0c6f0b
merged
StephenButtolph Nov 5, 2024
74edd4f
reduce diff
StephenButtolph Nov 5, 2024
7d31e7a
nit
StephenButtolph Nov 5, 2024
fca9460
nit
StephenButtolph Nov 5, 2024
158621c
nit
StephenButtolph Nov 5, 2024
4c6462c
nit
StephenButtolph Nov 5, 2024
a217d1b
nit
StephenButtolph Nov 5, 2024
3987922
nit
StephenButtolph Nov 5, 2024
56475cf
Add nodeID tests
StephenButtolph Nov 5, 2024
db85cf1
ACP-77: Refactor e2e test
StephenButtolph Nov 5, 2024
8a18b14
nit
StephenButtolph Nov 5, 2024
6dc3e84
merged
StephenButtolph Nov 5, 2024
f8552ba
reduce diff
StephenButtolph Nov 5, 2024
88fe959
merged
StephenButtolph Nov 5, 2024
5b08c6a
test subnet state prior to conversion
StephenButtolph Nov 6, 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
86 changes: 86 additions & 0 deletions tests/e2e/p/l1.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,26 @@ import (
"github.com/stretchr/testify/require"

"github.com/ava-labs/avalanchego/api/info"
"github.com/ava-labs/avalanchego/config"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/tests/fixture/e2e"
"github.com/ava-labs/avalanchego/tests/fixture/tmpnet"
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/utils/crypto/bls"
"github.com/ava-labs/avalanchego/utils/crypto/secp256k1"
"github.com/ava-labs/avalanchego/utils/units"
"github.com/ava-labs/avalanchego/vms/example/xsvm/genesis"
"github.com/ava-labs/avalanchego/vms/platformvm"
"github.com/ava-labs/avalanchego/vms/platformvm/txs"
"github.com/ava-labs/avalanchego/vms/secp256k1fx"

snowvalidators "github.com/ava-labs/avalanchego/snow/validators"
warpmessage "github.com/ava-labs/avalanchego/vms/platformvm/warp/message"
)

const (
genesisWeight = units.Schmeckle
genesisBalance = units.Avax
)

var _ = e2e.DescribePChain("[L1]", func() {
Expand Down Expand Up @@ -111,18 +124,80 @@ var _ = e2e.DescribePChain("[L1]", func() {
chainID = chainTx.ID()
})

verifyValidatorSet := func(expectedValidators map[ids.NodeID]*snowvalidators.GetValidatorOutput) {
height, err := pClient.GetHeight(tc.DefaultContext())
require.NoError(err)

subnetValidators, err := pClient.GetValidatorsAt(tc.DefaultContext(), subnetID, height)
require.NoError(err)
require.Equal(expectedValidators, subnetValidators)
}
tc.By("verifying the Permissioned Subnet is configured as expected", func() {
tc.By("verifying the subnet reports as permissioned", func() {
subnet, err := pClient.GetSubnet(tc.DefaultContext(), subnetID)
require.NoError(err)
require.Equal(
platformvm.GetSubnetClientResponse{
IsPermissioned: true,
ControlKeys: []ids.ShortID{
keychain.Keys[0].Address(),
},
Threshold: 1,
},
subnet,
)
})

tc.By("verifying the validator set is empty", func() {
verifyValidatorSet(map[ids.NodeID]*snowvalidators.GetValidatorOutput{})
})
})

tc.By("creating the genesis validator")
subnetGenesisNode := e2e.AddEphemeralNode(tc, env.GetNetwork(), tmpnet.FlagsMap{
config.TrackSubnetsKey: subnetID.String(),
})

genesisNodePoP, err := subnetGenesisNode.GetProofOfPossession()
require.NoError(err)

genesisNodePK, err := bls.PublicKeyFromCompressedBytes(genesisNodePoP.PublicKey[:])
require.NoError(err)

address := []byte{}
tc.By("issuing a ConvertSubnetTx", func() {
_, err := pWallet.IssueConvertSubnetTx(
subnetID,
chainID,
address,
[]*txs.ConvertSubnetValidator{
{
NodeID: subnetGenesisNode.NodeID.Bytes(),
Weight: genesisWeight,
Balance: genesisBalance,
Signer: *genesisNodePoP,
},
},
tc.WithDefaultContext(),
)
require.NoError(err)
})

tc.By("verifying the Permissioned Subnet was converted to an L1", func() {
expectedConversionID, err := warpmessage.SubnetConversionID(warpmessage.SubnetConversionData{
SubnetID: subnetID,
ManagerChainID: chainID,
ManagerAddress: address,
Validators: []warpmessage.SubnetConversionValidatorData{
{
NodeID: subnetGenesisNode.NodeID.Bytes(),
BLSPublicKey: genesisNodePoP.PublicKey,
Weight: genesisWeight,
},
},
})
require.NoError(err)

tc.By("verifying the subnet reports as being converted", func() {
subnet, err := pClient.GetSubnet(tc.DefaultContext(), subnetID)
require.NoError(err)
Expand All @@ -133,12 +208,23 @@ var _ = e2e.DescribePChain("[L1]", func() {
keychain.Keys[0].Address(),
},
Threshold: 1,
ConversionID: expectedConversionID,
ManagerChainID: chainID,
ManagerAddress: address,
},
subnet,
)
})

tc.By("verifying the validator set was updated", func() {
verifyValidatorSet(map[ids.NodeID]*snowvalidators.GetValidatorOutput{
Copy link
Contributor

Choose a reason for hiding this comment

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

curious what the expected validatorSet is before the conversion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added as part of the test

subnetGenesisNode.NodeID: {
NodeID: subnetGenesisNode.NodeID,
PublicKey: genesisNodePK,
Weight: genesisWeight,
},
})
})
})

_ = e2e.CheckBootstrapIsPossible(tc, env.GetNetwork())
Expand Down
73 changes: 70 additions & 3 deletions vms/platformvm/txs/convert_subnet_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,31 @@
package txs

import (
"bytes"
"errors"

"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/signer"
"github.com/ava-labs/avalanchego/vms/platformvm/warp/message"
"github.com/ava-labs/avalanchego/vms/secp256k1fx"
"github.com/ava-labs/avalanchego/vms/types"
)

const MaxSubnetAddressLength = 4096

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

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")
)

type ConvertSubnetTx struct {
Expand All @@ -31,6 +40,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"`
// Authorizes this conversion
SubnetAuth verify.Verifiable `serialize:"true" json:"subnetAuthorization"`
}
Expand All @@ -46,11 +57,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 +82,50 @@ func (tx *ConvertSubnetTx) SyntacticVerify(ctx *snow.Context) error {
func (tx *ConvertSubnetTx) Visit(visitor Visitor) error {
return visitor.ConvertSubnetTx(tx)
}

type ConvertSubnetValidator struct {
// NodeID of this validator
NodeID types.JSONByteSlice `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"`
StephenButtolph marked this conversation as resolved.
Show resolved Hide resolved
// [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.ProofOfPossession `serialize:"true" json:"signer"`
// Leftover $AVAX from the [Balance] will be issued to this owner once it is
// removed from the validator set.
RemainingBalanceOwner message.PChainOwner `serialize:"true" json:"remainingBalanceOwner"`
// This owner has the authority to manually deactivate this validator.
DeactivationOwner message.PChainOwner `serialize:"true" json:"deactivationOwner"`
StephenButtolph marked this conversation as resolved.
Show resolved Hide resolved
}

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

func (v *ConvertSubnetValidator) Verify() error {
if v.Weight == 0 {
return ErrZeroWeight
}
StephenButtolph marked this conversation as resolved.
Show resolved Hide resolved
nodeID, err := ids.ToNodeID(v.NodeID)
if err != nil {
return err
}
if nodeID == ids.EmptyNodeID {
return errEmptyNodeID
}
return verify.All(
&v.Signer,
&secp256k1fx.OutputOwners{
Threshold: v.RemainingBalanceOwner.Threshold,
Addrs: v.RemainingBalanceOwner.Addresses,
},
&secp256k1fx.OutputOwners{
Threshold: v.DeactivationOwner.Threshold,
Addrs: v.DeactivationOwner.Addresses,
},
)
}
Loading
Loading