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

ProposerVM Extend windows 2- extend windowing #2401

Merged
merged 145 commits into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
1d23375
nits
abi87 Nov 29, 2023
48aceae
extended windower
abi87 Nov 29, 2023
78e1240
nit
abi87 Nov 29, 2023
b3ffd15
nits
abi87 Nov 29, 2023
64e0cc5
adding UTs
abi87 Nov 29, 2023
392e991
introduced proposervm config
abi87 Nov 29, 2023
96ddd5c
fixed UTs
abi87 Nov 30, 2023
ea743bf
nit
abi87 Nov 30, 2023
8631693
introduced post durango verification
abi87 Nov 30, 2023
86153c0
minor refactoring
abi87 Nov 30, 2023
4b21cbd
introduced post durango block build timing logic
abi87 Nov 30, 2023
bcd06b3
Merge branch 'dev' into proposervm-upgraded-windowing
abi87 Dec 1, 2023
4fc372d
proposervm config + minor refactoring
abi87 Dec 1, 2023
1b80e78
Merge branch 'proposervm_config' into proposervm-upgraded-windowing
abi87 Dec 1, 2023
2af05f8
added test for expected proposer variance
abi87 Dec 1, 2023
d226792
nit
abi87 Dec 1, 2023
6edf17d
wip: updating proposerVM UTs to post durango
abi87 Dec 1, 2023
8dde95e
wip: some more updating proposerVM UTs to post durango
abi87 Dec 1, 2023
0dc76b7
wip: adding post durango UTs
abi87 Dec 1, 2023
6f98bf4
UTs cleanup
abi87 Dec 1, 2023
c2419b1
some more UTs updated to durango
abi87 Dec 1, 2023
29eefbc
nit
abi87 Dec 1, 2023
640984a
nit
abi87 Dec 1, 2023
0857fa6
Merge branch 'dev' into proposervm_config
abi87 Dec 1, 2023
d488e1a
Merge branch 'proposervm_config' into proposervm-upgraded-windowing
abi87 Dec 1, 2023
91c4a16
Merge branch 'dev' into proposervm_config
abi87 Dec 3, 2023
c8e1b33
nits
abi87 Dec 3, 2023
d1c8bb4
nit
abi87 Dec 3, 2023
3a4ec5f
Merge branch 'proposervm_config' into proposervm-upgraded-windowing
abi87 Dec 3, 2023
e8d18d8
fixes + more UTs
abi87 Dec 3, 2023
50a40e3
wip: some more UTs update to post durango fork
abi87 Dec 3, 2023
07e53ab
wip: some more UTs update to post durango fork
abi87 Dec 3, 2023
46235b9
wip: some more UTs updated to post durango fork
abi87 Dec 3, 2023
6d78042
wip: some more UTs updated to post durango fork
abi87 Dec 3, 2023
37fab9d
nit
abi87 Dec 4, 2023
a12ae77
proposerVM UTs cleanup
abi87 Dec 4, 2023
793e210
leftovers
abi87 Dec 4, 2023
2b4d88f
nit
abi87 Dec 4, 2023
d8ac4a2
nit
abi87 Dec 4, 2023
5f89fda
fixed UTs
abi87 Dec 4, 2023
20a9a93
some more cleanup
abi87 Dec 4, 2023
89bd4a2
fixed TestBlockVerify_PostForkBlock_PChainHeightChecks
abi87 Dec 4, 2023
5b773dc
fixed TestBlockVerify_PostForkBlockBuiltOnOption_PChainHeightChecks
abi87 Dec 4, 2023
970dff9
nit
abi87 Dec 4, 2023
04905c6
cleaned up post fork option tests
abi87 Dec 4, 2023
18ce5ed
cleaned up state syncable vm tests
abi87 Dec 4, 2023
c9b32a3
reduced changes scope
abi87 Dec 4, 2023
13407eb
nits
abi87 Dec 4, 2023
542e9c6
nits
abi87 Dec 4, 2023
fbdb075
nits
abi87 Dec 4, 2023
dd2820e
Merge branch 'dev' into proposervm_config
abi87 Dec 4, 2023
46254a7
Merge branch 'proposervm_config' into proposervm-uts-cleanup
abi87 Dec 4, 2023
5355218
Merge branch 'dev' into proposervm_config
abi87 Dec 5, 2023
39281b9
Merge branch 'proposervm_config' into proposervm-uts-cleanup
abi87 Dec 5, 2023
0e92339
some more cleanup
abi87 Dec 5, 2023
c366887
nit
abi87 Dec 5, 2023
948a98b
Merge branch 'proposervm-uts-cleanup' into proposervm-upgraded-windowing
abi87 Dec 5, 2023
41ca1a0
nit
abi87 Dec 5, 2023
a6b478d
Merge branch 'proposervm-uts-cleanup' into proposervm-upgraded-windowing
abi87 Dec 5, 2023
005e9c8
fixed windowing seed
abi87 Dec 5, 2023
6409bed
fixed test
abi87 Dec 5, 2023
6126df5
Merge branch 'proposervm-uts-cleanup' into proposervm-upgraded-windowing
abi87 Dec 5, 2023
37c3e2f
Merge branch 'dev' into proposervm-uts-cleanup
abi87 Dec 6, 2023
922f0d1
Merge branch 'proposervm-uts-cleanup' into proposervm-upgraded-windowing
abi87 Dec 6, 2023
75595dc
mega nits
StephenButtolph Dec 6, 2023
0a1595d
merged
StephenButtolph Dec 6, 2023
ee99881
merged
StephenButtolph Dec 6, 2023
fb9b4eb
Merge branch 'dev' into proposervm-upgraded-windowing
abi87 Dec 7, 2023
62a25ea
Merge branch 'dev' into proposervm-upgraded-windowing
abi87 Dec 8, 2023
db91261
Merge branch 'proposervm-upgraded-windowing' of github.com:ava-labs/a…
abi87 Dec 8, 2023
60ea9db
fix merge
abi87 Dec 8, 2023
19fe2ce
Merge branch 'dev' into proposervm-upgraded-windowing
abi87 Dec 9, 2023
82656aa
Remove ClearSeed()
StephenButtolph Dec 10, 2023
e37816e
Remove rng switching
StephenButtolph Dec 10, 2023
5375c51
Allow custom rng sources
StephenButtolph Dec 10, 2023
b864f6b
Fix tests
StephenButtolph Dec 10, 2023
69d6cdd
Merge branch 'simplify-sampling-seeding' into proposervm-upgraded-win…
StephenButtolph Dec 10, 2023
a7231af
Address comments
StephenButtolph Dec 10, 2023
2fcfea7
nit
StephenButtolph Dec 10, 2023
790215e
nit
StephenButtolph Dec 10, 2023
d120dd6
nit
StephenButtolph Dec 10, 2023
e72b46b
nit
StephenButtolph Dec 10, 2023
608de01
nit
StephenButtolph Dec 10, 2023
07a1498
nit
StephenButtolph Dec 10, 2023
0f1f526
wip: fixing scheduler
abi87 Dec 10, 2023
bb0386d
updated block scheduler
abi87 Dec 10, 2023
0fd6eeb
Merge branch 'dev' into proposervm-upgraded-windowing
abi87 Dec 11, 2023
2f59a4a
fixed scheduling reset
abi87 Dec 11, 2023
c528a1a
re-exported Proposers
abi87 Dec 11, 2023
4107482
avoid reinstantiating sampler at each round
abi87 Dec 11, 2023
96c898d
nit
StephenButtolph Dec 12, 2023
2e80f13
nit
StephenButtolph Dec 12, 2023
c62ac15
Merge branch 'dev' into proposervm-upgraded-windowing
abi87 Dec 12, 2023
d750e3c
some more fixes
abi87 Dec 12, 2023
c463433
Merge branch 'dev' into proposervm-upgraded-windowing
abi87 Dec 12, 2023
d468c9a
Merge branch 'dev' into proposervm-upgraded-windowing
abi87 Dec 12, 2023
ff47d3b
fix building time logic
StephenButtolph Dec 12, 2023
86adaed
nit
StephenButtolph Dec 12, 2023
37ca692
Merge branch 'dev' into proposervm-upgraded-windowing
abi87 Dec 13, 2023
da7b307
added UT
abi87 Dec 13, 2023
d7f14ed
added UT
abi87 Dec 13, 2023
f5ac69a
MinDelayForProposer rework
abi87 Dec 13, 2023
341a371
extended UTs
abi87 Dec 13, 2023
104603a
nits
abi87 Dec 13, 2023
6d8509a
reworked MinDelayForProposer
abi87 Dec 13, 2023
a737b00
fixed min delay
abi87 Dec 13, 2023
c627168
Merge branch 'dev' into proposervm-upgraded-windowing
abi87 Dec 13, 2023
1d58037
Merge branch 'dev' into proposervm-upgraded-windowing
abi87 Dec 14, 2023
76ad042
Merge branch 'dev' into proposervm-upgraded-windowing
abi87 Dec 14, 2023
1e539b8
nit
abi87 Dec 14, 2023
5075ab5
Merge branch 'dev' into proposervm-upgraded-windowing
abi87 Dec 14, 2023
fe45d23
improved comments
abi87 Dec 14, 2023
d7847c9
added test case for edge of look ahead window
abi87 Dec 14, 2023
48812cd
Merge branch 'proposervm-upgraded-windowing' of github.com:ava-labs/a…
abi87 Dec 14, 2023
0bad92c
extended look ahead window
abi87 Dec 14, 2023
1f8bf7f
MinDelayForProposer rework
abi87 Dec 14, 2023
302e8ac
some more MinDelayForProposer changes
abi87 Dec 14, 2023
3d7e1ff
appease linter
abi87 Dec 14, 2023
971db23
changed ExpectedProposer interface
abi87 Dec 14, 2023
c451ff1
simplified test
abi87 Dec 14, 2023
5007103
nit
abi87 Dec 14, 2023
b18bc5b
nit
StephenButtolph Dec 14, 2023
d0840da
nit
StephenButtolph Dec 14, 2023
4d7776f
nit
StephenButtolph Dec 14, 2023
e299aab
nits
StephenButtolph Dec 15, 2023
a239d61
expand tests
StephenButtolph Dec 15, 2023
80ee67d
nit
StephenButtolph Dec 15, 2023
d1690b9
nit
StephenButtolph Dec 15, 2023
c2813a8
nit
StephenButtolph Dec 15, 2023
527768c
nit
StephenButtolph Dec 15, 2023
78c449a
more tests
StephenButtolph Dec 15, 2023
b37f0b0
nit
StephenButtolph Dec 15, 2023
35f44bd
Add distribution test
StephenButtolph Dec 15, 2023
a0a174f
cleanup tests
StephenButtolph Dec 15, 2023
d8d807f
nit
StephenButtolph Dec 15, 2023
867f122
nit
StephenButtolph Dec 15, 2023
01bd6c5
rework code flow
StephenButtolph Dec 15, 2023
3ecd893
nit
StephenButtolph Dec 15, 2023
d1c4a7a
nit
StephenButtolph Dec 16, 2023
9dd9499
nit
StephenButtolph Dec 16, 2023
e6b7c1e
nit improve test
StephenButtolph Dec 16, 2023
87abdb7
Merge branch 'dev' into proposervm-upgraded-windowing
StephenButtolph Dec 16, 2023
6cfd985
add todo
StephenButtolph Dec 16, 2023
89ac205
Merge branch 'proposervm-upgraded-windowing' of github.com:ava-labs/a…
StephenButtolph Dec 16, 2023
ef5715e
Add benchmarks
StephenButtolph Dec 16, 2023
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: 2 additions & 0 deletions chains/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,7 @@ func (m *manager) createAvalancheChain(
vmWrappedInsideProposerVM,
proposervm.Config{
ActivationTime: m.ApricotPhase4Time,
DurangoTime: version.GetDurangoTime(m.NetworkID),
MinimumPChainHeight: m.ApricotPhase4MinPChainHeight,
MinBlkDelay: minBlockDelay,
NumHistoricalBlocks: numHistoricalBlocks,
Expand Down Expand Up @@ -1116,6 +1117,7 @@ func (m *manager) createSnowmanChain(
vm,
proposervm.Config{
ActivationTime: m.ApricotPhase4Time,
DurangoTime: version.GetDurangoTime(m.NetworkID),
MinimumPChainHeight: m.ApricotPhase4MinPChainHeight,
MinBlkDelay: minBlockDelay,
NumHistoricalBlocks: numHistoricalBlocks,
Expand Down
1 change: 1 addition & 0 deletions scripts/mocks.mockgen.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ github.com/ava-labs/avalanchego/vms/platformvm/txs/builder=Builder=vms/platformv
github.com/ava-labs/avalanchego/vms/platformvm/txs/mempool=Mempool=vms/platformvm/txs/mempool/mock_mempool.go
github.com/ava-labs/avalanchego/vms/platformvm/utxo=Verifier=vms/platformvm/utxo/mock_verifier.go
github.com/ava-labs/avalanchego/vms/proposervm/proposer=Windower=vms/proposervm/proposer/mock_windower.go
github.com/ava-labs/avalanchego/vms/proposervm/scheduler=Scheduler=vms/proposervm/scheduler/mock_scheduler.go
github.com/ava-labs/avalanchego/vms/proposervm/state=State=vms/proposervm/state/mock_state.go
github.com/ava-labs/avalanchego/vms/proposervm=PostForkBlock=vms/proposervm/mock_post_fork_block.go
github.com/ava-labs/avalanchego/vms/registry=VMGetter=vms/registry/mock_vm_getter.go
Expand Down
2 changes: 1 addition & 1 deletion snow/validators/test_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var (
var _ State = (*TestState)(nil)

type TestState struct {
T *testing.T
T testing.TB

CantGetMinimumHeight,
CantGetCurrentHeight,
Expand Down
20 changes: 20 additions & 0 deletions utils/sampler/rand_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"github.com/stretchr/testify/require"

"github.com/thepudds/fzgen/fuzzer"

"gonum.org/v1/gonum/mathext/prng"
)

type testSource struct {
Expand Down Expand Up @@ -208,3 +210,21 @@ func FuzzRNG(f *testing.F) {
require.Len(stdSource.nums, len(source.nums))
})
}

func BenchmarkSeed32(b *testing.B) {
source := prng.NewMT19937()

b.ResetTimer()
for i := 0; i < b.N; i++ {
source.Seed(0)
}
}

func BenchmarkSeed64(b *testing.B) {
source := prng.NewMT19937_64()

b.ResetTimer()
for i := 0; i < b.N; i++ {
source.Seed(0)
}
}
55 changes: 40 additions & 15 deletions vms/proposervm/batched_vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ import (
"github.com/ava-labs/avalanchego/snow/validators"
"github.com/ava-labs/avalanchego/utils/math"
"github.com/ava-labs/avalanchego/utils/timer/mockable"
"github.com/ava-labs/avalanchego/vms/proposervm/proposer"
)

func TestCoreVMNotRemote(t *testing.T) {
// if coreVM is not remote VM, a specific error is returned
require := require.New(t)
_, _, proVM, _, _ := initTestProposerVM(t, time.Time{}, 0) // enable ProBlks
var (
activationTime = time.Unix(0, 0)
durangoTime = activationTime
)
_, _, proVM, _, _ := initTestProposerVM(t, activationTime, durangoTime, 0)
defer func() {
require.NoError(proVM.Shutdown(context.Background()))
}()
Expand All @@ -54,7 +57,11 @@ func TestCoreVMNotRemote(t *testing.T) {

func TestGetAncestorsPreForkOnly(t *testing.T) {
require := require.New(t)
coreVM, proRemoteVM, coreGenBlk := initTestRemoteProposerVM(t, mockable.MaxTime) // disable ProBlks
var (
activationTime = mockable.MaxTime
durangoTime = activationTime
)
coreVM, proRemoteVM, coreGenBlk := initTestRemoteProposerVM(t, activationTime, durangoTime)
defer func() {
require.NoError(proRemoteVM.Shutdown(context.Background()))
}()
Expand Down Expand Up @@ -200,7 +207,11 @@ func TestGetAncestorsPreForkOnly(t *testing.T) {

func TestGetAncestorsPostForkOnly(t *testing.T) {
require := require.New(t)
coreVM, proRemoteVM, coreGenBlk := initTestRemoteProposerVM(t, time.Time{}) // enable ProBlks
var (
activationTime = time.Unix(0, 0)
durangoTime = activationTime
)
coreVM, proRemoteVM, coreGenBlk := initTestRemoteProposerVM(t, activationTime, durangoTime)
defer func() {
require.NoError(proRemoteVM.Shutdown(context.Background()))
}()
Expand All @@ -224,7 +235,7 @@ func TestGetAncestorsPostForkOnly(t *testing.T) {
// prepare build of next block
require.NoError(builtBlk1.Verify(context.Background()))
require.NoError(proRemoteVM.SetPreference(context.Background(), builtBlk1.ID()))
proRemoteVM.Set(proRemoteVM.Time().Add(proposer.MaxBuildDelay))
require.NoError(waitForProposerWindow(proRemoteVM, builtBlk1, 0))

coreBlk2 := &snowman.TestBlock{
TestDecidable: choices.TestDecidable{
Expand All @@ -244,7 +255,7 @@ func TestGetAncestorsPostForkOnly(t *testing.T) {
// prepare build of next block
require.NoError(builtBlk2.Verify(context.Background()))
require.NoError(proRemoteVM.SetPreference(context.Background(), builtBlk2.ID()))
proRemoteVM.Set(proRemoteVM.Time().Add(proposer.MaxBuildDelay))
require.NoError(waitForProposerWindow(proRemoteVM, builtBlk2, 0))

coreBlk3 := &snowman.TestBlock{
TestDecidable: choices.TestDecidable{
Expand Down Expand Up @@ -355,10 +366,12 @@ func TestGetAncestorsAtSnomanPlusPlusFork(t *testing.T) {
preForkTime = currentTime.Add(5 * time.Minute)
forkTime = currentTime.Add(10 * time.Minute)
postForkTime = currentTime.Add(15 * time.Minute)

durangoTime = forkTime
)

// enable ProBlks in next future
coreVM, proRemoteVM, coreGenBlk := initTestRemoteProposerVM(t, forkTime)
coreVM, proRemoteVM, coreGenBlk := initTestRemoteProposerVM(t, forkTime, durangoTime)
defer func() {
require.NoError(proRemoteVM.Shutdown(context.Background()))
}()
Expand Down Expand Up @@ -442,7 +455,7 @@ func TestGetAncestorsAtSnomanPlusPlusFork(t *testing.T) {
// prepare build of next block
require.NoError(builtBlk3.Verify(context.Background()))
require.NoError(proRemoteVM.SetPreference(context.Background(), builtBlk3.ID()))
proRemoteVM.Set(proRemoteVM.Time().Add(proposer.MaxBuildDelay))
require.NoError(waitForProposerWindow(proRemoteVM, builtBlk3, builtBlk3.(*postForkBlock).PChainHeight()))

coreBlk4 := &snowman.TestBlock{
TestDecidable: choices.TestDecidable{
Expand Down Expand Up @@ -556,7 +569,11 @@ func TestGetAncestorsAtSnomanPlusPlusFork(t *testing.T) {

func TestBatchedParseBlockPreForkOnly(t *testing.T) {
require := require.New(t)
coreVM, proRemoteVM, coreGenBlk := initTestRemoteProposerVM(t, mockable.MaxTime) // disable ProBlks
var (
activationTime = mockable.MaxTime
durangoTime = activationTime
)
coreVM, proRemoteVM, coreGenBlk := initTestRemoteProposerVM(t, activationTime, durangoTime)
defer func() {
require.NoError(proRemoteVM.Shutdown(context.Background()))
}()
Expand Down Expand Up @@ -674,7 +691,11 @@ func TestBatchedParseBlockPreForkOnly(t *testing.T) {

func TestBatchedParseBlockPostForkOnly(t *testing.T) {
require := require.New(t)
coreVM, proRemoteVM, coreGenBlk := initTestRemoteProposerVM(t, time.Time{}) // enable ProBlks
var (
activationTime = time.Unix(0, 0)
durangoTime = activationTime
)
coreVM, proRemoteVM, coreGenBlk := initTestRemoteProposerVM(t, activationTime, durangoTime)
defer func() {
require.NoError(proRemoteVM.Shutdown(context.Background()))
}()
Expand All @@ -698,7 +719,7 @@ func TestBatchedParseBlockPostForkOnly(t *testing.T) {
// prepare build of next block
require.NoError(builtBlk1.Verify(context.Background()))
require.NoError(proRemoteVM.SetPreference(context.Background(), builtBlk1.ID()))
proRemoteVM.Set(proRemoteVM.Time().Add(proposer.MaxBuildDelay))
require.NoError(waitForProposerWindow(proRemoteVM, builtBlk1, 0))

coreBlk2 := &snowman.TestBlock{
TestDecidable: choices.TestDecidable{
Expand All @@ -718,7 +739,7 @@ func TestBatchedParseBlockPostForkOnly(t *testing.T) {
// prepare build of next block
require.NoError(builtBlk2.Verify(context.Background()))
require.NoError(proRemoteVM.SetPreference(context.Background(), builtBlk2.ID()))
proRemoteVM.Set(proRemoteVM.Time().Add(proposer.MaxBuildDelay))
require.NoError(waitForProposerWindow(proRemoteVM, builtBlk2, builtBlk2.(*postForkBlock).PChainHeight()))

coreBlk3 := &snowman.TestBlock{
TestDecidable: choices.TestDecidable{
Expand Down Expand Up @@ -786,10 +807,12 @@ func TestBatchedParseBlockAtSnomanPlusPlusFork(t *testing.T) {
preForkTime = currentTime.Add(5 * time.Minute)
forkTime = currentTime.Add(10 * time.Minute)
postForkTime = currentTime.Add(15 * time.Minute)

durangoTime = forkTime
)

// enable ProBlks in next future
coreVM, proRemoteVM, coreGenBlk := initTestRemoteProposerVM(t, forkTime)
coreVM, proRemoteVM, coreGenBlk := initTestRemoteProposerVM(t, forkTime, durangoTime)
defer func() {
require.NoError(proRemoteVM.Shutdown(context.Background()))
}()
Expand Down Expand Up @@ -873,7 +896,7 @@ func TestBatchedParseBlockAtSnomanPlusPlusFork(t *testing.T) {
// prepare build of next block
require.NoError(builtBlk3.Verify(context.Background()))
require.NoError(proRemoteVM.SetPreference(context.Background(), builtBlk3.ID()))
proRemoteVM.Set(proRemoteVM.Time().Add(proposer.MaxBuildDelay))
require.NoError(waitForProposerWindow(proRemoteVM, builtBlk3, builtBlk3.(*postForkBlock).PChainHeight()))

coreBlk4 := &snowman.TestBlock{
TestDecidable: choices.TestDecidable{
Expand Down Expand Up @@ -949,7 +972,8 @@ type TestRemoteProposerVM struct {

func initTestRemoteProposerVM(
t *testing.T,
activationTime time.Time,
activationTime,
durangoTime time.Time,
) (
TestRemoteProposerVM,
*VM,
Expand Down Expand Up @@ -1015,6 +1039,7 @@ func initTestRemoteProposerVM(
coreVM,
Config{
ActivationTime: activationTime,
DurangoTime: durangoTime,
MinimumPChainHeight: 0,
MinBlkDelay: DefaultMinBlockDelay,
NumHistoricalBlocks: DefaultNumHistoricalBlocks,
Expand Down
Loading
Loading