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: Implement validator state #3388

Merged
merged 227 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
227 commits
Select commit Hold shift + click to select a range
9c8835b
remove subnet IDs from uptime pkg
ceyonur Jul 24, 2024
733d5fd
remove subnet uptimes from platforvm
ceyonur Jul 25, 2024
10d8e86
remove subnet uptimes from p2p
ceyonur Jul 25, 2024
a2f69d0
remove subnet uptimes from api
ceyonur Jul 25, 2024
ee287c6
add tracked bool
ceyonur Jul 25, 2024
a42e48c
remove unnecessary err
ceyonur Jul 26, 2024
4c542af
remove connected subnet msg
ceyonur Jul 26, 2024
941f536
Merge branch 'master' into remove-subnetid-uptime-manager
ceyonur Jul 26, 2024
9161864
fix linter
ceyonur Jul 26, 2024
dfded5e
Merge branch 'master' into remove-subnetid-uptime-manager
ceyonur Jul 31, 2024
f275c15
rework on tests and reviews
ceyonur Jul 31, 2024
d9355cc
fix linter
ceyonur Jul 31, 2024
46501ad
Update proto/p2p/p2p.proto
ceyonur Aug 6, 2024
b7459bd
fix comment
ceyonur Aug 6, 2024
b81b737
Update vms/platformvm/service_test.go
ceyonur Aug 6, 2024
f6bb383
use disconnect in stop tracking
ceyonur Aug 6, 2024
7a6f7eb
remove todo comment
ceyonur Aug 6, 2024
64dec9c
Merge branch 'master' into remove-subnetid-uptime-manager
ceyonur Aug 6, 2024
33eb562
Merge branch 'master' into remove-subnetid-uptime-manager
ceyonur Sep 8, 2024
cba7a50
remove unused err
ceyonur Sep 8, 2024
b4955d6
remove subnet connector mock
ceyonur Sep 8, 2024
3c9096e
Merge branch 'master' into remove-subnetid-uptime-manager
ceyonur Sep 10, 2024
1b22842
WIP Add Expiry Replay Protection
StephenButtolph Sep 10, 2024
ad83805
rename
StephenButtolph Sep 10, 2024
7820c17
wip
StephenButtolph Sep 10, 2024
20ed013
Replace iterator equality helper
StephenButtolph Sep 10, 2024
fcb388c
merged
StephenButtolph Sep 10, 2024
a02b51c
Finish diff implementation
StephenButtolph Sep 11, 2024
daf45a3
Merge branch 'master' into implement-acp-77-add-validator-replay-prot…
StephenButtolph Sep 11, 2024
7bda9b1
Finish state implementation
StephenButtolph Sep 11, 2024
f24ca9f
lint
StephenButtolph Sep 11, 2024
463ce02
Implement iterator deduplicator
StephenButtolph Sep 11, 2024
4ce1977
Merge branch 'master' into remove-subnetid-uptime-manager
ceyonur Sep 11, 2024
3cc413a
Reuse Filter
StephenButtolph Sep 11, 2024
4de908e
Merge branch 'master' into implement-deduplication-iterator
StephenButtolph Sep 11, 2024
09f71e6
merged
StephenButtolph Sep 11, 2024
114beeb
nit
StephenButtolph Sep 11, 2024
0cd4f89
Merge branch 'master' into implement-acp-77-add-validator-replay-prot…
StephenButtolph Sep 11, 2024
57810a0
Add comments
StephenButtolph Sep 11, 2024
e89671a
otherExpiries -> unexpectedExpiries
StephenButtolph Sep 12, 2024
72f972c
restructure test
StephenButtolph Sep 12, 2024
e8eea6f
reduce diff
StephenButtolph Sep 12, 2024
d67408d
nit
StephenButtolph Sep 12, 2024
8571163
Merge branch 'master' into implement-acp-77-sov-validators-state
StephenButtolph Sep 13, 2024
6e457fa
Implement acp-77 state diff
StephenButtolph Sep 13, 2024
86754d0
Fix apply reordering
StephenButtolph Sep 13, 2024
c68afec
Implement acp-77 state diff without historical diffs
StephenButtolph Sep 14, 2024
09faa6b
nit
StephenButtolph Sep 14, 2024
51937f7
nit
StephenButtolph Sep 14, 2024
88a310e
Add num SoV validators on a subnet
StephenButtolph Sep 15, 2024
b11ff7e
fix tests
StephenButtolph Sep 15, 2024
6c9e0e0
Merge branch 'master' into implement-acp-77-sov-validators-state
StephenButtolph Sep 15, 2024
b028ada
write historical diffs
StephenButtolph Sep 15, 2024
42d61ef
Implement and test state diffs
StephenButtolph Sep 16, 2024
8ef4fcf
Store weights rather than counts
StephenButtolph Sep 16, 2024
e2045e2
load sov validators on startup
StephenButtolph Sep 16, 2024
863c92e
Merge branch 'master' into remove-subnetid-uptime-manager
ceyonur Sep 16, 2024
e0beab1
update in-memory validator sets
StephenButtolph Sep 17, 2024
410bcda
remove comment
StephenButtolph Sep 17, 2024
149e21e
Add SoV excess
StephenButtolph Sep 17, 2024
6c0945b
Merge branch 'master' into implement-acp-77-sov-validators-state
StephenButtolph Sep 18, 2024
a441d62
Merge branch 'master' into remove-subnetid-uptime-manager
ceyonur Sep 19, 2024
fbc5ce1
Merge branch 'master' into implement-acp-77-sov-validators-state
StephenButtolph Sep 20, 2024
cfc2790
Merge branch 'remove-subnetid-uptime-manager' into implement-acp-77-s…
StephenButtolph Sep 22, 2024
449994a
write subnet public key diffs
StephenButtolph Sep 23, 2024
744f4c7
merged
StephenButtolph Sep 23, 2024
d9108a7
mocks
StephenButtolph Sep 23, 2024
98020f1
Bound GetNextStakerTime
StephenButtolph Sep 24, 2024
cc9a086
fix test
StephenButtolph Sep 24, 2024
a3f0d94
add comment
StephenButtolph Sep 24, 2024
de81518
Add tests
StephenButtolph Sep 24, 2024
c062890
Merge branch 'bound-next-staker-time' into implement-acp-77-sov-valid…
StephenButtolph Sep 24, 2024
b68ed8a
merged
StephenButtolph Sep 25, 2024
8fe987c
ACP-77: Update warp messages to follow new specification
StephenButtolph Sep 30, 2024
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
a3cc8e8
merged
StephenButtolph Oct 1, 2024
ddb9ba6
Add deactivation owner
StephenButtolph Oct 1, 2024
556f1eb
fix tests
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
0d3d3b9
Merge branch 'master' into implement-acp-77-sov-validators-state
StephenButtolph Oct 3, 2024
01c9072
remove unexpected file
StephenButtolph Oct 3, 2024
01de954
Merge branch 'master' into implement-acp-77-sov-validators-state
StephenButtolph Oct 3, 2024
1ca7524
Merge branch 'master' into implement-acp-77-sov-validators-state
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
127a3fa
nit
StephenButtolph Oct 7, 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
d7ba4fb
Merge branch 'master' into implement-acp-77-sov-validators-state
StephenButtolph Oct 11, 2024
d550c97
Merge branch 'master' into implement-acp-77-sov-validators-state
StephenButtolph Oct 14, 2024
9226649
Merge branch 'master' into implement-acp-77-sov-validators-state
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
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
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
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
8f0a080
merged
StephenButtolph Oct 24, 2024
d482de8
Merge branch 'populate-subnet-public-key-diffs' into implement-acp-77…
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
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
3077356
merged
StephenButtolph Nov 4, 2024
69837c1
improve caching
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
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
9 changes: 9 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Release Notes

## Pending Release

### Configs

- Added P-chain configs
- `"l1-weights-cache-size"`
- `"l1-inactive-validators-cache-size"`
- `"l1-subnet-id-node-id-cache-size"`

## [v1.11.11](https://github.com/ava-labs/avalanchego/releases/tag/v1.11.11)

This version is backwards compatible to [v1.11.0](https://github.com/ava-labs/avalanchego/releases/tag/v1.11.0). It is optional, but encouraged.
Expand Down
2 changes: 2 additions & 0 deletions vms/platformvm/block/executor/proposal_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func TestApricotProposalBlockTimeVerification(t *testing.T) {
onParentAccept.EXPECT().GetFeeState().Return(gas.State{}).AnyTimes()
onParentAccept.EXPECT().GetSoVExcess().Return(gas.Gas(0)).AnyTimes()
onParentAccept.EXPECT().GetAccruedFees().Return(uint64(0)).AnyTimes()
onParentAccept.EXPECT().NumActiveSubnetOnlyValidators().Return(0).AnyTimes()

onParentAccept.EXPECT().GetCurrentStakerIterator().Return(
iterator.FromSlice(&state.Staker{
Expand Down Expand Up @@ -165,6 +166,7 @@ func TestBanffProposalBlockTimeVerification(t *testing.T) {
onParentAccept.EXPECT().GetFeeState().Return(gas.State{}).AnyTimes()
onParentAccept.EXPECT().GetSoVExcess().Return(gas.Gas(0)).AnyTimes()
onParentAccept.EXPECT().GetAccruedFees().Return(uint64(0)).AnyTimes()
onParentAccept.EXPECT().NumActiveSubnetOnlyValidators().Return(0).AnyTimes()
onParentAccept.EXPECT().GetCurrentSupply(constants.PrimaryNetworkID).Return(uint64(1000), nil).AnyTimes()

env.blkManager.(*manager).blkIDToState[parentID] = &blockState{
Expand Down
2 changes: 2 additions & 0 deletions vms/platformvm/block/executor/standard_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func TestApricotStandardBlockTimeVerification(t *testing.T) {
onParentAccept.EXPECT().GetFeeState().Return(gas.State{}).AnyTimes()
onParentAccept.EXPECT().GetSoVExcess().Return(gas.Gas(0)).AnyTimes()
onParentAccept.EXPECT().GetAccruedFees().Return(uint64(0)).AnyTimes()
onParentAccept.EXPECT().NumActiveSubnetOnlyValidators().Return(0).AnyTimes()

// wrong height
apricotChildBlk, err := block.NewApricotStandardBlock(
Expand Down Expand Up @@ -137,6 +138,7 @@ func TestBanffStandardBlockTimeVerification(t *testing.T) {
onParentAccept.EXPECT().GetFeeState().Return(gas.State{}).AnyTimes()
onParentAccept.EXPECT().GetSoVExcess().Return(gas.Gas(0)).AnyTimes()
onParentAccept.EXPECT().GetAccruedFees().Return(uint64(0)).AnyTimes()
onParentAccept.EXPECT().NumActiveSubnetOnlyValidators().Return(0).AnyTimes()

txID := ids.GenerateTestID()
utxo := &avax.UTXO{
Expand Down
5 changes: 5 additions & 0 deletions vms/platformvm/block/executor/verifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func TestVerifierVisitProposalBlock(t *testing.T) {
parentOnAcceptState.EXPECT().GetFeeState().Return(gas.State{}).Times(2)
parentOnAcceptState.EXPECT().GetSoVExcess().Return(gas.Gas(0)).Times(2)
parentOnAcceptState.EXPECT().GetAccruedFees().Return(uint64(0)).Times(2)
parentOnAcceptState.EXPECT().NumActiveSubnetOnlyValidators().Return(0).Times(2)

backend := &backend{
lastAccepted: parentID,
Expand Down Expand Up @@ -338,6 +339,7 @@ func TestVerifierVisitStandardBlock(t *testing.T) {
parentState.EXPECT().GetFeeState().Return(gas.State{}).Times(1)
parentState.EXPECT().GetSoVExcess().Return(gas.Gas(0)).Times(1)
parentState.EXPECT().GetAccruedFees().Return(uint64(0)).Times(1)
parentState.EXPECT().NumActiveSubnetOnlyValidators().Return(0).Times(1)
parentStatelessBlk.EXPECT().Height().Return(uint64(1)).Times(1)
mempool.EXPECT().Remove(apricotBlk.Txs()).Times(1)

Expand Down Expand Up @@ -601,6 +603,7 @@ func TestBanffAbortBlockTimestampChecks(t *testing.T) {
s.EXPECT().GetFeeState().Return(gas.State{}).Times(3)
s.EXPECT().GetSoVExcess().Return(gas.Gas(0)).Times(3)
s.EXPECT().GetAccruedFees().Return(uint64(0)).Times(3)
s.EXPECT().NumActiveSubnetOnlyValidators().Return(0).Times(3)

onDecisionState, err := state.NewDiff(parentID, backend)
require.NoError(err)
Expand Down Expand Up @@ -700,6 +703,7 @@ func TestBanffCommitBlockTimestampChecks(t *testing.T) {
s.EXPECT().GetFeeState().Return(gas.State{}).Times(3)
s.EXPECT().GetSoVExcess().Return(gas.Gas(0)).Times(3)
s.EXPECT().GetAccruedFees().Return(uint64(0)).Times(3)
s.EXPECT().NumActiveSubnetOnlyValidators().Return(0).Times(3)

onDecisionState, err := state.NewDiff(parentID, backend)
require.NoError(err)
Expand Down Expand Up @@ -817,6 +821,7 @@ func TestVerifierVisitStandardBlockWithDuplicateInputs(t *testing.T) {
parentState.EXPECT().GetFeeState().Return(gas.State{}).Times(1)
parentState.EXPECT().GetSoVExcess().Return(gas.Gas(0)).Times(1)
parentState.EXPECT().GetAccruedFees().Return(uint64(0)).Times(1)
parentState.EXPECT().NumActiveSubnetOnlyValidators().Return(0).Times(1)
parentStatelessBlk.EXPECT().Parent().Return(grandParentID).Times(1)

err = verifier.ApricotStandardBlock(blk)
Expand Down
54 changes: 30 additions & 24 deletions vms/platformvm/config/execution_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,40 @@ import (
)

var DefaultExecutionConfig = ExecutionConfig{
Network: network.DefaultConfig,
BlockCacheSize: 64 * units.MiB,
TxCacheSize: 128 * units.MiB,
TransformedSubnetTxCacheSize: 4 * units.MiB,
RewardUTXOsCacheSize: 2048,
ChainCacheSize: 2048,
ChainDBCacheSize: 2048,
BlockIDCacheSize: 8192,
FxOwnerCacheSize: 4 * units.MiB,
SubnetConversionCacheSize: 4 * units.MiB,
ChecksumsEnabled: false,
MempoolPruneFrequency: 30 * time.Minute,
Network: network.DefaultConfig,
BlockCacheSize: 64 * units.MiB,
TxCacheSize: 128 * units.MiB,
TransformedSubnetTxCacheSize: 4 * units.MiB,
RewardUTXOsCacheSize: 2048,
ChainCacheSize: 2048,
ChainDBCacheSize: 2048,
BlockIDCacheSize: 8192,
FxOwnerCacheSize: 4 * units.MiB,
SubnetConversionCacheSize: 4 * units.MiB,
L1WeightsCacheSize: 16 * units.KiB,
L1InactiveValidatorsCacheSize: 256 * units.KiB,
L1SubnetIDNodeIDCacheSize: 16 * units.KiB,
ChecksumsEnabled: false,
MempoolPruneFrequency: 30 * time.Minute,
}

// ExecutionConfig provides execution parameters of PlatformVM
type ExecutionConfig struct {
Network network.Config `json:"network"`
BlockCacheSize int `json:"block-cache-size"`
TxCacheSize int `json:"tx-cache-size"`
TransformedSubnetTxCacheSize int `json:"transformed-subnet-tx-cache-size"`
RewardUTXOsCacheSize int `json:"reward-utxos-cache-size"`
ChainCacheSize int `json:"chain-cache-size"`
ChainDBCacheSize int `json:"chain-db-cache-size"`
BlockIDCacheSize int `json:"block-id-cache-size"`
FxOwnerCacheSize int `json:"fx-owner-cache-size"`
SubnetConversionCacheSize int `json:"subnet-conversion-cache-size"`
ChecksumsEnabled bool `json:"checksums-enabled"`
MempoolPruneFrequency time.Duration `json:"mempool-prune-frequency"`
Network network.Config `json:"network"`
BlockCacheSize int `json:"block-cache-size"`
TxCacheSize int `json:"tx-cache-size"`
TransformedSubnetTxCacheSize int `json:"transformed-subnet-tx-cache-size"`
RewardUTXOsCacheSize int `json:"reward-utxos-cache-size"`
ChainCacheSize int `json:"chain-cache-size"`
ChainDBCacheSize int `json:"chain-db-cache-size"`
BlockIDCacheSize int `json:"block-id-cache-size"`
FxOwnerCacheSize int `json:"fx-owner-cache-size"`
SubnetConversionCacheSize int `json:"subnet-conversion-cache-size"`
L1WeightsCacheSize int `json:"l1-weights-cache-size"`
L1InactiveValidatorsCacheSize int `json:"l1-inactive-validators-cache-size"`
L1SubnetIDNodeIDCacheSize int `json:"l1-subnet-id-node-id-cache-size"`
ChecksumsEnabled bool `json:"checksums-enabled"`
MempoolPruneFrequency time.Duration `json:"mempool-prune-frequency"`
}

// GetExecutionConfig returns an ExecutionConfig
Expand Down
25 changes: 14 additions & 11 deletions vms/platformvm/config/execution_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,20 @@ func TestExecutionConfigUnmarshal(t *testing.T) {
ExpectedBloomFilterFalsePositiveProbability: 16,
MaxBloomFilterFalsePositiveProbability: 17,
},
BlockCacheSize: 1,
TxCacheSize: 2,
TransformedSubnetTxCacheSize: 3,
RewardUTXOsCacheSize: 5,
ChainCacheSize: 6,
ChainDBCacheSize: 7,
BlockIDCacheSize: 8,
FxOwnerCacheSize: 9,
SubnetConversionCacheSize: 10,
ChecksumsEnabled: true,
MempoolPruneFrequency: time.Minute,
BlockCacheSize: 1,
TxCacheSize: 2,
TransformedSubnetTxCacheSize: 3,
RewardUTXOsCacheSize: 5,
ChainCacheSize: 6,
ChainDBCacheSize: 7,
BlockIDCacheSize: 8,
FxOwnerCacheSize: 9,
SubnetConversionCacheSize: 10,
L1WeightsCacheSize: 11,
L1InactiveValidatorsCacheSize: 12,
L1SubnetIDNodeIDCacheSize: 13,
ChecksumsEnabled: true,
MempoolPruneFrequency: time.Minute,
}
verifyInitializedStruct(t, *expected)
verifyInitializedStruct(t, expected.Network)
Expand Down
114 changes: 101 additions & 13 deletions vms/platformvm/state/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,17 @@ type diff struct {
parentID ids.ID
stateVersions Versions

timestamp time.Time
feeState gas.State
sovExcess gas.Gas
accruedFees uint64
timestamp time.Time
feeState gas.State
sovExcess gas.Gas
accruedFees uint64
parentNumActiveSOVs int

// Subnet ID --> supply of native asset of the subnet
currentSupply map[ids.ID]uint64

expiryDiff *expiryDiff
sovDiff *subnetOnlyValidatorsDiff

currentStakerDiffs diffStakers
// map of subnetID -> nodeID -> total accrued delegatee rewards
Expand Down Expand Up @@ -77,15 +79,17 @@ func NewDiff(
return nil, fmt.Errorf("%w: %s", ErrMissingParentState, parentID)
}
return &diff{
parentID: parentID,
stateVersions: stateVersions,
timestamp: parentState.GetTimestamp(),
feeState: parentState.GetFeeState(),
sovExcess: parentState.GetSoVExcess(),
accruedFees: parentState.GetAccruedFees(),
expiryDiff: newExpiryDiff(),
subnetOwners: make(map[ids.ID]fx.Owner),
subnetConversions: make(map[ids.ID]SubnetConversion),
parentID: parentID,
stateVersions: stateVersions,
timestamp: parentState.GetTimestamp(),
feeState: parentState.GetFeeState(),
sovExcess: parentState.GetSoVExcess(),
accruedFees: parentState.GetAccruedFees(),
parentNumActiveSOVs: parentState.NumActiveSubnetOnlyValidators(),
expiryDiff: newExpiryDiff(),
sovDiff: newSubnetOnlyValidatorsDiff(),
subnetOwners: make(map[ids.ID]fx.Owner),
subnetConversions: make(map[ids.ID]SubnetConversion),
}, nil
}

Expand Down Expand Up @@ -194,6 +198,70 @@ func (d *diff) DeleteExpiry(entry ExpiryEntry) {
d.expiryDiff.DeleteExpiry(entry)
}

func (d *diff) GetActiveSubnetOnlyValidatorsIterator() (iterator.Iterator[SubnetOnlyValidator], error) {
parentState, ok := d.stateVersions.GetState(d.parentID)
if !ok {
return nil, fmt.Errorf("%w: %s", ErrMissingParentState, d.parentID)
}

parentIterator, err := parentState.GetActiveSubnetOnlyValidatorsIterator()
if err != nil {
return nil, err
}

return d.sovDiff.getActiveSubnetOnlyValidatorsIterator(parentIterator), nil
}

func (d *diff) NumActiveSubnetOnlyValidators() int {
return d.parentNumActiveSOVs + d.sovDiff.netAddedActive
}

func (d *diff) WeightOfSubnetOnlyValidators(subnetID ids.ID) (uint64, error) {
if weight, modified := d.sovDiff.modifiedTotalWeight[subnetID]; modified {
return weight, nil
}

parentState, ok := d.stateVersions.GetState(d.parentID)
Copy link
Contributor

Choose a reason for hiding this comment

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

can you explain the high level idea of doing this backwards traversal in search of the subnet, both here and in the next function?

We basically don't have a full snapshot of the validators in each state? Why is that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Performing a full copy of the validator states for each diff would be pretty expensive. The number of changes per block is typically small, but the number total entries being tracked can be quite large.

if !ok {
return 0, fmt.Errorf("%w: %s", ErrMissingParentState, d.parentID)
}

return parentState.WeightOfSubnetOnlyValidators(subnetID)
}

func (d *diff) GetSubnetOnlyValidator(validationID ids.ID) (SubnetOnlyValidator, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

A couple high level questions that may be related:

  • What triggers a new diff to be created?
  • Did you consider updating diffs in place, rather than the linked list style approach here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Diffs are created for a few reasons. But the reason the diffs are designed this way is because each diff (can) represent the changes that are performed by a block. When a block is verified a diff is created. When a block is accepted a diff is applied to the disk state.

Diffs are updated in-place during the execution (verification) of a block - but we wouldn't want a child block to modify the state that will be committed when the parent block is accepted (as the child could be rejected for a different child)

if sov, modified := d.sovDiff.modified[validationID]; modified {
if sov.isDeleted() {
return SubnetOnlyValidator{}, database.ErrNotFound
}
return sov, nil
}

parentState, ok := d.stateVersions.GetState(d.parentID)
if !ok {
return SubnetOnlyValidator{}, fmt.Errorf("%w: %s", ErrMissingParentState, d.parentID)
}

return parentState.GetSubnetOnlyValidator(validationID)
}

func (d *diff) HasSubnetOnlyValidator(subnetID ids.ID, nodeID ids.NodeID) (bool, error) {
if has, modified := d.sovDiff.hasSubnetOnlyValidator(subnetID, nodeID); modified {
return has, nil
}

parentState, ok := d.stateVersions.GetState(d.parentID)
if !ok {
return false, fmt.Errorf("%w: %s", ErrMissingParentState, d.parentID)
}

return parentState.HasSubnetOnlyValidator(subnetID, nodeID)
Copy link
Contributor

Choose a reason for hiding this comment

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

this might seem as a weird question, but - how deep is the expected recursion here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The recursion ends at the lastAcceptedState and starts at the most recently verified block, so typically the recursion is very shallow.

}

func (d *diff) PutSubnetOnlyValidator(sov SubnetOnlyValidator) error {
return d.sovDiff.putSubnetOnlyValidator(d, sov)
}

func (d *diff) GetCurrentValidator(subnetID ids.ID, nodeID ids.NodeID) (*Staker, error) {
// If the validator was modified in this diff, return the modified
// validator.
Expand Down Expand Up @@ -504,6 +572,26 @@ func (d *diff) Apply(baseState Chain) error {
baseState.DeleteExpiry(entry)
}
}
// Ensure that all sov deletions happen before any sov additions. This
// ensures that a subnetID+nodeID pair that was deleted and then re-added in
// a single diff can't get reordered into the addition happening first;
// which would return an error.
michaelkaplan13 marked this conversation as resolved.
Show resolved Hide resolved
for _, sov := range d.sovDiff.modified {
Copy link
Contributor

Choose a reason for hiding this comment

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

Playing devil's advocate here, we're iterating here over a map, and calling baseState.PutSubnetOnlyValidator which may return with different errors. This means that across different nodes, we may fail differently, no?

Is that a concern?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is generally unexpected for Apply to ever error.

Apply is called during Accept. If Apply were to return an error, that error would be propagated through Accept into the consensus engine (causing a FATAL).

if !sov.isDeleted() {
continue
}
if err := baseState.PutSubnetOnlyValidator(sov); err != nil {
return err
}
}
for _, sov := range d.sovDiff.modified {
if sov.isDeleted() {
continue
}
if err := baseState.PutSubnetOnlyValidator(sov); err != nil {
return err
}
}
for _, subnetValidatorDiffs := range d.currentStakerDiffs.validatorDiffs {
for _, validatorDiff := range subnetValidatorDiffs {
switch validatorDiff.validatorStatus {
Expand Down
Loading
Loading