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

Implement SoV data struct #3287

Merged
merged 161 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
161 commits
Select commit Hold shift + click to select a range
1857cb9
[vms/platformvm] Add tracking of a Subnet manager
dhrubabasu Jun 18, 2024
4d11a29
Merge branch 'master' into store-warp-addressed-call-pair
dhrubabasu Jun 18, 2024
90a38ff
Update vms/platformvm/state/diff.go
dhrubabasu Jun 18, 2024
f60e4ea
nit
dhrubabasu Jun 18, 2024
1ca0caf
nit
dhrubabasu Jun 20, 2024
1cd2428
nit
dhrubabasu Jun 20, 2024
3587c32
nit
dhrubabasu Jun 20, 2024
ec16c11
[vms/platformvm] Cleanup execution config tests
dhrubabasu Jun 20, 2024
f52cbbe
Merge branch 'master' into cleanup-execution-config-test
dhrubabasu Jun 20, 2024
076b1f0
nit
dhrubabasu Jun 20, 2024
df5ca64
nit
dhrubabasu Jun 20, 2024
dcc056b
Merge branch 'master' into cleanup-execution-config-test
dhrubabasu Jun 20, 2024
3279764
nit
dhrubabasu Jun 21, 2024
911a167
mark as helper
dhrubabasu Jun 21, 2024
ddf3392
Merge branch 'master' into cleanup-execution-config-test
dhrubabasu Jun 21, 2024
25802a8
merged
dhrubabasu Jun 21, 2024
01b854a
reduce diff
dhrubabasu Jun 21, 2024
f79e0c7
add write
dhrubabasu Jun 24, 2024
1eda29c
merged
dhrubabasu Jun 24, 2024
3fa1306
nits
dhrubabasu Jun 25, 2024
16ffe7b
nit
dhrubabasu Jun 25, 2024
3035064
nits
dhrubabasu Jun 25, 2024
62ece94
Merge branch 'master' into store-warp-addressed-call-pair
dhrubabasu Jun 25, 2024
333a41e
fix UT
dhrubabasu Jun 25, 2024
520ac91
add UTs
dhrubabasu Jun 25, 2024
db5f197
lint
dhrubabasu Jun 25, 2024
574a120
nit
dhrubabasu Jun 26, 2024
501beb1
nit
dhrubabasu Jun 26, 2024
ab5c23b
add test for cache
dhrubabasu Jul 17, 2024
e0d0a00
Merge branch 'master' into store-warp-addressed-call-pair
dhrubabasu Jul 17, 2024
12a1969
wip
dhrubabasu Jul 22, 2024
cda1001
table tests
dhrubabasu Jul 23, 2024
2ff46f4
Merge branch 'master' into store-warp-addressed-call-pair
dhrubabasu Jul 23, 2024
e05a514
Merge branch 'store-warp-addressed-call-pair' into ConvertSubnetTx
dhrubabasu Jul 23, 2024
7ab0094
wip
dhrubabasu Jul 23, 2024
79e84b1
wip
dhrubabasu Jul 23, 2024
264a73f
merged
dhrubabasu Jul 23, 2024
1340a51
nits
dhrubabasu Jul 23, 2024
62f6d78
nits
dhrubabasu Jul 23, 2024
6e54ba7
nits
dhrubabasu Jul 23, 2024
68e621d
passing
dhrubabasu Jul 23, 2024
8e9f406
add tests
dhrubabasu Jul 23, 2024
dd08695
reduce scope
dhrubabasu Jul 23, 2024
3042de2
nit
dhrubabasu Jul 23, 2024
9b8aa4a
merged
dhrubabasu Aug 5, 2024
1d72e1b
nits
dhrubabasu Aug 5, 2024
5126df9
merged
dhrubabasu Aug 5, 2024
909a24c
Etna
dhrubabasu Aug 5, 2024
c1299c8
nit
dhrubabasu Aug 5, 2024
a2d0968
nit
dhrubabasu Aug 5, 2024
aa6b6f6
Implement SoV data struct
dhrubabasu Aug 11, 2024
be79d4c
Merge branch 'master' into disable-permissioned-subnet-txs-post-manager
dhrubabasu Aug 11, 2024
367cf42
disable CreateChainTx
dhrubabasu Aug 11, 2024
a14f140
pass CI
dhrubabasu Aug 12, 2024
eed7d1a
wire in validatorWeightDiffsDB and validatorPublicKeyDiffsDB
dhrubabasu Aug 12, 2024
30240fc
wip
dhrubabasu Aug 13, 2024
9fe5414
passing for now
dhrubabasu Aug 13, 2024
413a7a9
Merge branch 'master' into disable-permissioned-subnet-txs-post-manager
dhrubabasu Aug 13, 2024
c988391
nit
dhrubabasu Aug 13, 2024
3f49097
move write
dhrubabasu Aug 13, 2024
447e326
reduce footpring
dhrubabasu Aug 13, 2024
b23b654
nit
dhrubabasu Aug 14, 2024
952fd7f
nit
dhrubabasu Aug 14, 2024
db18027
nit
dhrubabasu Aug 14, 2024
e019360
Merge branch 'master' into disable-permissioned-subnet-txs-post-manager
dhrubabasu Aug 14, 2024
43b2b53
merged
dhrubabasu Aug 14, 2024
fe4f3d6
Merge branch 'disable-permissioned-subnet-txs-post-manager' into Conv…
dhrubabasu Aug 14, 2024
ddf94a4
RemoveSubnet
dhrubabasu Aug 14, 2024
4a5fecb
Merge branch 'disable-permissioned-subnet-txs-post-manager' into Conv…
dhrubabasu Aug 14, 2024
643ddbd
fix test
dhrubabasu Aug 14, 2024
215821f
Merge branch 'disable-permissioned-subnet-txs-post-manager' into Conv…
dhrubabasu Aug 14, 2024
bdc015d
wip e2e
dhrubabasu Aug 14, 2024
d1652c0
fix build
dhrubabasu Aug 14, 2024
4fb9e17
wip
dhrubabasu Aug 14, 2024
2555a6a
nit
dhrubabasu Aug 14, 2024
751bdea
nit
dhrubabasu Aug 14, 2024
1c91b02
nit
dhrubabasu Aug 14, 2024
82ce5d0
finish e2e
dhrubabasu Aug 14, 2024
4c2205e
nit
dhrubabasu Aug 14, 2024
0ba141d
nit
dhrubabasu Aug 14, 2024
e537d23
nit
dhrubabasu Aug 14, 2024
f18163b
Merge branch 'ConvertSubnetTx' into sov-data-struct
dhrubabasu Aug 15, 2024
35e0580
wip
dhrubabasu Aug 15, 2024
a61fb06
Merge branch 'ConvertSubnetTx' into sov-data-struct
dhrubabasu Aug 15, 2024
b42de99
merged
dhrubabasu Aug 19, 2024
4a1ca5c
minimize
dhrubabasu Aug 19, 2024
0b15984
nit
dhrubabasu Aug 19, 2024
99378b4
reduce diff
dhrubabasu Aug 19, 2024
1684fdb
cleanup e2e
dhrubabasu Aug 19, 2024
22ac121
Merge branch 'master' into ConvertSubnetTx
dhrubabasu Aug 19, 2024
a8524ba
cleanup
dhrubabasu Aug 19, 2024
b5df28b
cap address size to 4096
dhrubabasu Aug 19, 2024
bed839d
skip correctly
dhrubabasu Aug 19, 2024
4adc17e
nit
dhrubabasu Aug 19, 2024
ffeb3d3
nits
dhrubabasu Aug 20, 2024
37cbc52
linear scan... for now
dhrubabasu Aug 20, 2024
4edc421
Merge branch 'master' into ConvertSubnetTx
dhrubabasu Aug 20, 2024
67e2bef
Merge branch 'ConvertSubnetTx' into sov-data-struct
dhrubabasu Aug 20, 2024
63d5ac7
int
dhrubabasu Aug 20, 2024
ece7c2b
wip
dhrubabasu Aug 20, 2024
92a7187
cleanup complexity
dhrubabasu Aug 20, 2024
144dad2
fix
dhrubabasu Aug 20, 2024
6cc89e1
Merge branch 'ConvertSubnetTx' into sov-data-struct
dhrubabasu Aug 20, 2024
1503bd4
merged
dhrubabasu Aug 20, 2024
7dd74b5
Merge branch 'ConvertSubnetTx' into sov-data-struct
dhrubabasu Aug 20, 2024
6a0db3f
nit
dhrubabasu Aug 21, 2024
4afac28
merged
dhrubabasu Aug 22, 2024
5545958
Merge branch 'ConvertSubnetTx' into sov-data-struct
dhrubabasu Aug 22, 2024
41127c9
nit
dhrubabasu Aug 22, 2024
8b54f2f
Merge branch 'ConvertSubnetTx' into sov-data-struct
dhrubabasu Aug 22, 2024
13238f1
nit
dhrubabasu Aug 22, 2024
fdc1069
nit
dhrubabasu Aug 22, 2024
57dc1be
Merge branch 'ConvertSubnetTx' into sov-data-struct
dhrubabasu Aug 22, 2024
85ce497
nit
dhrubabasu Aug 22, 2024
33e7126
nit
dhrubabasu Aug 22, 2024
15473d5
Merge branch 'ConvertSubnetTx' into sov-data-struct
dhrubabasu Aug 22, 2024
58eebf4
nit
dhrubabasu Aug 22, 2024
f7a5558
wip
dhrubabasu Aug 29, 2024
f33f9a7
nit
dhrubabasu Aug 29, 2024
499f19c
Separate codec registries by upgrade
StephenButtolph Sep 2, 2024
dfaff2e
merged
StephenButtolph Sep 2, 2024
6b26b49
nit
StephenButtolph Sep 2, 2024
aeddd28
Merge branch 'separate-codec-by-upgrade' into ConvertSubnetTx
StephenButtolph Sep 2, 2024
3dcdcda
Update naming
StephenButtolph Sep 2, 2024
64a6c53
Use hex output
StephenButtolph Sep 2, 2024
ad664a0
Reduce diff
StephenButtolph Sep 2, 2024
186cf8d
Improve json format
StephenButtolph Sep 2, 2024
de97114
Improve tests
StephenButtolph Sep 2, 2024
40a2cae
Fix error
StephenButtolph Sep 2, 2024
b0ce060
cleanup test
StephenButtolph Sep 2, 2024
0ecfc50
remove static fee support
StephenButtolph Sep 2, 2024
06534fc
reduce diff
StephenButtolph Sep 2, 2024
a44b68a
nit
StephenButtolph Sep 2, 2024
68a6e24
fix comment
StephenButtolph Sep 2, 2024
61640da
Add builder test
StephenButtolph Sep 2, 2024
1619e79
nit
StephenButtolph Sep 2, 2024
f536353
Remove usage of mocks
StephenButtolph Sep 3, 2024
f6339b5
nit
StephenButtolph Sep 3, 2024
91338cb
fix test
StephenButtolph Sep 3, 2024
f602280
Support unmarshalling of json byte slices
StephenButtolph Sep 3, 2024
c3b076b
standardize json and add tests
StephenButtolph Sep 3, 2024
4328bac
fix marshal tests
StephenButtolph Sep 3, 2024
805ae43
fix marshal more tests
StephenButtolph Sep 3, 2024
518cf19
fix even marshal more tests
StephenButtolph Sep 3, 2024
26b3702
merged
StephenButtolph Sep 3, 2024
e1f55a5
Nit use var
StephenButtolph Sep 3, 2024
8895f27
Cleanup serialization tests
StephenButtolph Sep 4, 2024
aa7f222
Add comment
StephenButtolph Sep 4, 2024
91c8619
var block
StephenButtolph Sep 4, 2024
b5638e0
reorder
StephenButtolph Sep 4, 2024
4831205
Merge branch 'master' into ConvertSubnetTx
StephenButtolph Sep 4, 2024
df3fb4c
embed json
StephenButtolph Sep 4, 2024
8f8ebc9
Merge branch 'ConvertSubnetTx' of github.com:ava-labs/avalanchego int…
StephenButtolph Sep 4, 2024
d87a472
huh tabs are os dependent?
StephenButtolph Sep 4, 2024
ff95e5b
I misread the error, it was returns
StephenButtolph Sep 4, 2024
7aee249
Merge branch 'ConvertSubnetTx' into sov-data-struct
StephenButtolph Sep 4, 2024
1ca22eb
Merge branch 'master' into sov-data-struct
StephenButtolph Sep 4, 2024
471871f
Merge branch 'implement-acp-77-fees' into sov-data-struct
StephenButtolph Sep 6, 2024
a490641
merge fee implementation
StephenButtolph Sep 6, 2024
c780c34
Merge branch 'implement-acp-77-fees' into sov-data-struct
StephenButtolph Sep 6, 2024
5af7744
Remove validator state struct
StephenButtolph Sep 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
158 changes: 105 additions & 53 deletions vms/platformvm/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ var (
DelegatorPrefix = []byte("delegator")
SubnetValidatorPrefix = []byte("subnetValidator")
SubnetDelegatorPrefix = []byte("subnetDelegator")
SubnetOnlyValidatorPrefix = []byte("subnetOnlyValidator")
ValidatorWeightDiffsPrefix = []byte("flatValidatorDiffs")
ValidatorPublicKeyDiffsPrefix = []byte("flatPublicKeyDiffs")
TxPrefix = []byte("tx")
Expand Down Expand Up @@ -236,6 +237,9 @@ type stateBlk struct {
* | | '-. subnetDelegator
* | | '-. list
* | | '-- txID -> potential reward
* | | |-. subnetOnlyValidator
* | | | '-. list
* | | | '-- validationID -> subnet + nodeID + minNonce + balance + endTime
* | |-. pending
* | | |-. validator
* | | | '-. list
Expand Down Expand Up @@ -270,6 +274,8 @@ type stateBlk struct {
* | '-- txID -> nil
* |-. subnetOwners
* | '-. subnetID -> owner
* |-. subnetManagers
* | '-. subnetID -> manager
* |-. chains
* | '-. subnetID
* | '-. list
Expand All @@ -294,8 +300,9 @@ type state struct {

baseDB *versiondb.Database

currentStakers *baseStakers
pendingStakers *baseStakers
currentStakers *baseStakers
pendingStakers *baseStakers
subnetOnlyValidators *baseSubnetOnlyValidators

currentHeight uint64

Expand All @@ -307,25 +314,26 @@ type state struct {
blockCache cache.Cacher[ids.ID, block.Block] // cache of blockID -> Block; if the entry is nil, it is not in the database
blockDB database.Database

validatorsDB database.Database
currentValidatorsDB database.Database
currentValidatorBaseDB database.Database
currentValidatorList linkeddb.LinkedDB
currentDelegatorBaseDB database.Database
currentDelegatorList linkeddb.LinkedDB
currentSubnetValidatorBaseDB database.Database
currentSubnetValidatorList linkeddb.LinkedDB
currentSubnetDelegatorBaseDB database.Database
currentSubnetDelegatorList linkeddb.LinkedDB
pendingValidatorsDB database.Database
pendingValidatorBaseDB database.Database
pendingValidatorList linkeddb.LinkedDB
pendingDelegatorBaseDB database.Database
pendingDelegatorList linkeddb.LinkedDB
pendingSubnetValidatorBaseDB database.Database
pendingSubnetValidatorList linkeddb.LinkedDB
pendingSubnetDelegatorBaseDB database.Database
pendingSubnetDelegatorList linkeddb.LinkedDB
validatorsDB database.Database
currentValidatorsDB database.Database
currentValidatorBaseDB database.Database
currentValidatorList linkeddb.LinkedDB
currentDelegatorBaseDB database.Database
currentDelegatorList linkeddb.LinkedDB
currentSubnetValidatorBaseDB database.Database
currentSubnetValidatorList linkeddb.LinkedDB
currentSubnetDelegatorBaseDB database.Database
currentSubnetDelegatorList linkeddb.LinkedDB
currentSubnetOnlyValidatorBaseDB database.Database
pendingValidatorsDB database.Database
pendingValidatorBaseDB database.Database
pendingValidatorList linkeddb.LinkedDB
pendingDelegatorBaseDB database.Database
pendingDelegatorList linkeddb.LinkedDB
pendingSubnetValidatorBaseDB database.Database
pendingSubnetValidatorList linkeddb.LinkedDB
pendingSubnetDelegatorBaseDB database.Database
pendingSubnetDelegatorList linkeddb.LinkedDB

validatorWeightDiffsDB database.Database
validatorPublicKeyDiffsDB database.Database
Expand Down Expand Up @@ -489,6 +497,7 @@ func New(
currentDelegatorBaseDB := prefixdb.New(DelegatorPrefix, currentValidatorsDB)
currentSubnetValidatorBaseDB := prefixdb.New(SubnetValidatorPrefix, currentValidatorsDB)
currentSubnetDelegatorBaseDB := prefixdb.New(SubnetDelegatorPrefix, currentValidatorsDB)
currentSubnetOnlyValidatorBaseDB := prefixdb.New(SubnetOnlyValidatorPrefix, currentValidatorsDB)

pendingValidatorsDB := prefixdb.New(PendingPrefix, validatorsDB)
pendingValidatorBaseDB := prefixdb.New(ValidatorPrefix, pendingValidatorsDB)
Expand Down Expand Up @@ -604,30 +613,32 @@ func New(
blockCache: blockCache,
blockDB: prefixdb.New(BlockPrefix, baseDB),

currentStakers: newBaseStakers(),
pendingStakers: newBaseStakers(),

validatorsDB: validatorsDB,
currentValidatorsDB: currentValidatorsDB,
currentValidatorBaseDB: currentValidatorBaseDB,
currentValidatorList: linkeddb.NewDefault(currentValidatorBaseDB),
currentDelegatorBaseDB: currentDelegatorBaseDB,
currentDelegatorList: linkeddb.NewDefault(currentDelegatorBaseDB),
currentSubnetValidatorBaseDB: currentSubnetValidatorBaseDB,
currentSubnetValidatorList: linkeddb.NewDefault(currentSubnetValidatorBaseDB),
currentSubnetDelegatorBaseDB: currentSubnetDelegatorBaseDB,
currentSubnetDelegatorList: linkeddb.NewDefault(currentSubnetDelegatorBaseDB),
pendingValidatorsDB: pendingValidatorsDB,
pendingValidatorBaseDB: pendingValidatorBaseDB,
pendingValidatorList: linkeddb.NewDefault(pendingValidatorBaseDB),
pendingDelegatorBaseDB: pendingDelegatorBaseDB,
pendingDelegatorList: linkeddb.NewDefault(pendingDelegatorBaseDB),
pendingSubnetValidatorBaseDB: pendingSubnetValidatorBaseDB,
pendingSubnetValidatorList: linkeddb.NewDefault(pendingSubnetValidatorBaseDB),
pendingSubnetDelegatorBaseDB: pendingSubnetDelegatorBaseDB,
pendingSubnetDelegatorList: linkeddb.NewDefault(pendingSubnetDelegatorBaseDB),
validatorWeightDiffsDB: validatorWeightDiffsDB,
validatorPublicKeyDiffsDB: validatorPublicKeyDiffsDB,
currentStakers: newBaseStakers(),
pendingStakers: newBaseStakers(),
subnetOnlyValidators: newBaseSubnetOnlyValidators(currentSubnetOnlyValidatorBaseDB),

validatorsDB: validatorsDB,
currentValidatorsDB: currentValidatorsDB,
currentValidatorBaseDB: currentValidatorBaseDB,
currentValidatorList: linkeddb.NewDefault(currentValidatorBaseDB),
currentDelegatorBaseDB: currentDelegatorBaseDB,
currentDelegatorList: linkeddb.NewDefault(currentDelegatorBaseDB),
currentSubnetValidatorBaseDB: currentSubnetValidatorBaseDB,
currentSubnetValidatorList: linkeddb.NewDefault(currentSubnetValidatorBaseDB),
currentSubnetDelegatorBaseDB: currentSubnetDelegatorBaseDB,
currentSubnetDelegatorList: linkeddb.NewDefault(currentSubnetDelegatorBaseDB),
currentSubnetOnlyValidatorBaseDB: currentSubnetOnlyValidatorBaseDB,
pendingValidatorsDB: pendingValidatorsDB,
pendingValidatorBaseDB: pendingValidatorBaseDB,
pendingValidatorList: linkeddb.NewDefault(pendingValidatorBaseDB),
pendingDelegatorBaseDB: pendingDelegatorBaseDB,
pendingDelegatorList: linkeddb.NewDefault(pendingDelegatorBaseDB),
pendingSubnetValidatorBaseDB: pendingSubnetValidatorBaseDB,
pendingSubnetValidatorList: linkeddb.NewDefault(pendingSubnetValidatorBaseDB),
pendingSubnetDelegatorBaseDB: pendingSubnetDelegatorBaseDB,
pendingSubnetDelegatorList: linkeddb.NewDefault(pendingSubnetDelegatorBaseDB),
validatorWeightDiffsDB: validatorWeightDiffsDB,
validatorPublicKeyDiffsDB: validatorPublicKeyDiffsDB,

addedTxs: make(map[ids.ID]*txAndStatus),
txDB: prefixdb.New(TxPrefix, baseDB),
Expand Down Expand Up @@ -1709,6 +1720,7 @@ func (s *state) Close() error {
s.pendingValidatorsDB.Close(),
s.currentSubnetValidatorBaseDB.Close(),
s.currentSubnetDelegatorBaseDB.Close(),
s.currentSubnetOnlyValidatorBaseDB.Close(),
s.currentDelegatorBaseDB.Close(),
s.currentValidatorBaseDB.Close(),
s.currentValidatorsDB.Close(),
Expand Down Expand Up @@ -1939,8 +1951,11 @@ func (s *state) writeCurrentStakers(updateValidators bool, height uint64, codecV
// Record that the public key for the validator is being
// added. This means the prior value for the public key was
// nil.
err := s.validatorPublicKeyDiffsDB.Put(
marshalDiffKey(constants.PrimaryNetworkID, height, nodeID),
err := writeValidatorPublicKeyDiff(
s.validatorPublicKeyDiffsDB,
constants.PrimaryNetworkID,
height,
nodeID,
nil,
)
if err != nil {
Expand Down Expand Up @@ -1988,9 +2003,12 @@ func (s *state) writeCurrentStakers(updateValidators bool, height uint64, codecV
// Note: We store the uncompressed public key here as it is
// significantly more efficient to parse when applying
// diffs.
err := s.validatorPublicKeyDiffsDB.Put(
marshalDiffKey(constants.PrimaryNetworkID, height, nodeID),
bls.PublicKeyToUncompressedBytes(staker.PublicKey),
err := writeValidatorPublicKeyDiff(
s.validatorPublicKeyDiffsDB,
constants.PrimaryNetworkID,
height,
nodeID,
staker.PublicKey,
)
if err != nil {
return err
Expand Down Expand Up @@ -2019,9 +2037,12 @@ func (s *state) writeCurrentStakers(updateValidators bool, height uint64, codecV
continue
}

err = s.validatorWeightDiffsDB.Put(
marshalDiffKey(subnetID, height, nodeID),
marshalWeightDiff(weightDiff),
err = writeValidatorWeightDiff(
s.validatorWeightDiffsDB,
subnetID,
height,
nodeID,
weightDiff,
)
if err != nil {
return err
Expand Down Expand Up @@ -2555,3 +2576,34 @@ func getFeeState(db database.KeyValueReader) (gas.State, error) {
}
return feeState, nil
}

func writeValidatorWeightDiff(
db database.KeyValueWriter,
subnetID ids.ID,
height uint64,
nodeID ids.NodeID,
weightDiff *ValidatorWeightDiff,
) error {
return db.Put(
marshalDiffKey(subnetID, height, nodeID),
marshalWeightDiff(weightDiff),
)
}

func writeValidatorPublicKeyDiff(
db database.KeyValueWriter,
subnetID ids.ID,
height uint64,
nodeID ids.NodeID,
pk *bls.PublicKey,
) error {
value := []byte(nil)
if pk != nil {
value = bls.PublicKeyToUncompressedBytes(pk)
}

return db.Put(
marshalDiffKey(subnetID, height, nodeID),
value,
)
}
Loading
Loading