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

Fix duplicated bootstrapper engine termination #2334

Merged
merged 51 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
0128eaa
Hardcode stopVertexID to avoid bootstrapping
StephenButtolph Nov 9, 2023
3bf262a
Simplify get server creation
StephenButtolph Nov 9, 2023
c88fb51
Merged
StephenButtolph Nov 9, 2023
587204e
nit
StephenButtolph Nov 9, 2023
15cd71a
wip
StephenButtolph Nov 9, 2023
50ee5aa
address nits
StephenButtolph Nov 10, 2023
f4d3809
address nits
StephenButtolph Nov 10, 2023
79763e7
nit
StephenButtolph Nov 10, 2023
495846a
nit
StephenButtolph Nov 10, 2023
190d58f
Merge branch 'dev' into simplify-get-server-creation
StephenButtolph Nov 10, 2023
e87d831
merged
StephenButtolph Nov 10, 2023
92baae2
cleanup tests
StephenButtolph Nov 10, 2023
7ac0792
add todo
StephenButtolph Nov 10, 2023
fb975a4
Move Halter into snowman bootstrapper
StephenButtolph Nov 10, 2023
08e2bf0
Remove confusing embedded functions
StephenButtolph Nov 13, 2023
f6b8c60
wip
StephenButtolph Nov 13, 2023
d0cdbf9
Remove bootstrapping retry config
StephenButtolph Nov 14, 2023
b3fbe68
merged
StephenButtolph Nov 14, 2023
8f521cd
Address nits
StephenButtolph Nov 14, 2023
2b920aa
link explorer
StephenButtolph Nov 14, 2023
14637a2
Merge branch 'simplify-avalanche-bootstrapping' into remove-common-bo…
StephenButtolph Nov 14, 2023
8034b65
merged
StephenButtolph Nov 16, 2023
a3f0eed
fix platformvm test
StephenButtolph Nov 16, 2023
08fcf30
fix sm tests
StephenButtolph Nov 16, 2023
f53e022
nit
StephenButtolph Nov 16, 2023
4f3feb6
reduce diff
StephenButtolph Nov 16, 2023
35bcff2
reduce diff
StephenButtolph Nov 16, 2023
3647ace
reduce diff
StephenButtolph Nov 16, 2023
1794608
Merge branch 'dev' into remove-bootstrapping-retry-config
StephenButtolph Nov 16, 2023
47fafb9
Merge branch 'dev' into remove-bootstrapping-retry-config
StephenButtolph Nov 17, 2023
3ced6ce
merged
StephenButtolph Nov 17, 2023
7c7f473
revert migration
StephenButtolph Nov 17, 2023
150b524
wip
StephenButtolph Nov 17, 2023
f6acfb7
wip
StephenButtolph Nov 17, 2023
93f51c3
merged
StephenButtolph Nov 17, 2023
3ae5f7d
reduce diff
StephenButtolph Nov 17, 2023
5706b03
nit
StephenButtolph Nov 17, 2023
d58b503
nit
StephenButtolph Nov 17, 2023
cd65f73
nit
StephenButtolph Nov 17, 2023
12684ff
nit
StephenButtolph Nov 17, 2023
51e2948
nit
StephenButtolph Nov 17, 2023
6c48d01
cleanup
StephenButtolph Nov 17, 2023
b7aa48b
reorder nits
StephenButtolph Nov 17, 2023
17d9e9d
nit
StephenButtolph Nov 17, 2023
d2bc3ba
nit
StephenButtolph Nov 17, 2023
58351f6
Add regression test for duplicated bootstrapper engine termination
StephenButtolph Nov 17, 2023
8b9140d
merged
StephenButtolph Nov 29, 2023
5c1d617
fix
joshua-kim Dec 1, 2023
7bb1ad6
Merge branch 'dev' into duplicate-bootstrapper-termination
joshua-kim Dec 1, 2023
3038a50
nit
joshua-kim Dec 1, 2023
991545b
Merge branch 'dev' into duplicate-bootstrapper-termination
StephenButtolph Dec 4, 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
1 change: 1 addition & 0 deletions snow/engine/snowman/bootstrap/bootstrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@ func (b *Bootstrapper) Timeout(ctx context.Context) error {
func (b *Bootstrapper) restartBootstrapping(ctx context.Context) error {
b.Ctx.Log.Debug("Checking for new frontiers")
b.restarted = true
b.outstandingRequests = bimap.New[common.Request, ids.ID]()
return b.startBootstrapping(ctx)
}

Expand Down
121 changes: 121 additions & 0 deletions snow/engine/snowman/bootstrap/bootstrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1423,3 +1423,124 @@ func TestBootstrapNoParseOnNew(t *testing.T) {
)
require.NoError(err)
}

func TestBootstrapperReceiveStaleAncestorsMessage(t *testing.T) {
require := require.New(t)

config, peerID, sender, vm := newConfig(t)

var (
blkID0 = ids.GenerateTestID()
blkBytes0 = utils.RandomBytes(1024)
blk0 = &snowman.TestBlock{
TestDecidable: choices.TestDecidable{
IDV: blkID0,
StatusV: choices.Accepted,
},
HeightV: 0,
BytesV: blkBytes0,
}

blkID1 = ids.GenerateTestID()
blkBytes1 = utils.RandomBytes(1024)
blk1 = &snowman.TestBlock{
TestDecidable: choices.TestDecidable{
IDV: blkID1,
StatusV: choices.Processing,
},
ParentV: blk0.IDV,
HeightV: blk0.HeightV + 1,
BytesV: blkBytes1,
}

blkID2 = ids.GenerateTestID()
blkBytes2 = utils.RandomBytes(1024)
blk2 = &snowman.TestBlock{
TestDecidable: choices.TestDecidable{
IDV: blkID2,
StatusV: choices.Processing,
},
ParentV: blk1.IDV,
HeightV: blk1.HeightV + 1,
BytesV: blkBytes2,
}
)

vm.LastAcceptedF = func(context.Context) (ids.ID, error) {
return blk0.ID(), nil
}
vm.GetBlockF = func(_ context.Context, blkID ids.ID) (snowman.Block, error) {
require.Equal(blkID0, blkID)
return blk0, nil
}
bs, err := New(
config,
func(context.Context, uint32) error {
config.Ctx.State.Set(snow.EngineState{
Type: p2p.EngineType_ENGINE_TYPE_SNOWMAN,
State: snow.NormalOp,
})
return nil
},
)
require.NoError(err)

vm.CantSetState = false
require.NoError(bs.Start(context.Background(), 0))

vm.GetBlockF = func(_ context.Context, blkID ids.ID) (snowman.Block, error) {
switch blkID {
case blkID0:
return blk0, nil
case blkID1:
if blk1.StatusV == choices.Accepted {
return blk1, nil
}
return nil, database.ErrNotFound
case blkID2:
if blk2.StatusV == choices.Accepted {
return blk2, nil
}
return nil, database.ErrNotFound
default:
require.FailNow(database.ErrNotFound.Error())
return nil, database.ErrNotFound
}
}
vm.ParseBlockF = func(_ context.Context, blkBytes []byte) (snowman.Block, error) {
switch {
case bytes.Equal(blkBytes, blkBytes0):
return blk0, nil
case bytes.Equal(blkBytes, blkBytes1):
return blk1, nil
case bytes.Equal(blkBytes, blkBytes2):
return blk2, nil
default:
require.FailNow(errUnknownBlock.Error())
return nil, errUnknownBlock
}
}

requestIDs := map[ids.ID]uint32{}
sender.SendGetAncestorsF = func(_ context.Context, vdr ids.NodeID, reqID uint32, blkID ids.ID) {
require.Equal(peerID, vdr)
requestIDs[blkID] = reqID
}

require.NoError(bs.startSyncing(context.Background(), []ids.ID{blkID1, blkID2})) // should request blk2 and blk1

reqIDBlk1, ok := requestIDs[blkID1]
require.True(ok)
reqIDBlk2, ok := requestIDs[blkID2]
require.True(ok)

require.NoError(bs.Ancestors(context.Background(), peerID, reqIDBlk2, [][]byte{blkBytes2, blkBytes1}))

require.Equal(snow.Bootstrapping, config.Ctx.State.Get().State)
require.Equal(choices.Accepted, blk0.Status())
require.Equal(choices.Accepted, blk1.Status())
require.Equal(choices.Accepted, blk2.Status())

require.NoError(bs.Ancestors(context.Background(), peerID, reqIDBlk1, [][]byte{blkBytes1}))
require.Equal(snow.Bootstrapping, config.Ctx.State.Get().State)
}
Loading