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

[vms/proposervm] Update Build Heuristic #2348

Merged
merged 23 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
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
20 changes: 10 additions & 10 deletions vms/proposervm/batched_vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,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.MaxDelay))
proRemoteVM.Set(proRemoteVM.Time().Add(proposer.MaxVerifyDelay))
patrick-ogrady marked this conversation as resolved.
Show resolved Hide resolved

coreBlk2 := &snowman.TestBlock{
TestDecidable: choices.TestDecidable{
Expand All @@ -235,7 +235,7 @@ func TestGetAncestorsPostForkOnly(t *testing.T) {
BytesV: []byte{2},
ParentV: coreBlk1.ID(),
HeightV: coreBlk1.Height() + 1,
TimestampV: coreBlk1.Timestamp().Add(proposer.MaxDelay),
TimestampV: coreBlk1.Timestamp().Add(proposer.MaxVerifyDelay),
}
coreVM.BuildBlockF = func(context.Context) (snowman.Block, error) {
return coreBlk2, nil
Expand All @@ -246,7 +246,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.MaxDelay))
proRemoteVM.Set(proRemoteVM.Time().Add(proposer.MaxVerifyDelay))

coreBlk3 := &snowman.TestBlock{
TestDecidable: choices.TestDecidable{
Expand Down Expand Up @@ -431,7 +431,7 @@ func TestGetAncestorsAtSnomanPlusPlusFork(t *testing.T) {
BytesV: []byte{3},
ParentV: coreBlk2.ID(),
HeightV: coreBlk2.Height() + 1,
TimestampV: postForkTime.Add(proposer.MaxDelay),
TimestampV: postForkTime.Add(proposer.MaxVerifyDelay),
}
coreVM.BuildBlockF = func(context.Context) (snowman.Block, error) {
return coreBlk3, nil
Expand All @@ -443,7 +443,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.MaxDelay))
proRemoteVM.Set(proRemoteVM.Time().Add(proposer.MaxVerifyDelay))

coreBlk4 := &snowman.TestBlock{
TestDecidable: choices.TestDecidable{
Expand Down Expand Up @@ -704,7 +704,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.MaxDelay))
proRemoteVM.Set(proRemoteVM.Time().Add(proposer.MaxVerifyDelay))

coreBlk2 := &snowman.TestBlock{
TestDecidable: choices.TestDecidable{
Expand All @@ -714,7 +714,7 @@ func TestBatchedParseBlockPostForkOnly(t *testing.T) {
BytesV: []byte{2},
ParentV: coreBlk1.ID(),
HeightV: coreBlk1.Height() + 1,
TimestampV: coreBlk1.Timestamp().Add(proposer.MaxDelay),
TimestampV: coreBlk1.Timestamp().Add(proposer.MaxVerifyDelay),
}
coreVM.BuildBlockF = func(context.Context) (snowman.Block, error) {
return coreBlk2, nil
Expand All @@ -725,7 +725,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.MaxDelay))
proRemoteVM.Set(proRemoteVM.Time().Add(proposer.MaxVerifyDelay))

coreBlk3 := &snowman.TestBlock{
TestDecidable: choices.TestDecidable{
Expand Down Expand Up @@ -867,7 +867,7 @@ func TestBatchedParseBlockAtSnomanPlusPlusFork(t *testing.T) {
BytesV: []byte{3},
ParentV: coreBlk2.ID(),
HeightV: coreBlk2.Height() + 1,
TimestampV: postForkTime.Add(proposer.MaxDelay),
TimestampV: postForkTime.Add(proposer.MaxVerifyDelay),
}
coreVM.BuildBlockF = func(context.Context) (snowman.Block, error) {
return coreBlk3, nil
Expand All @@ -879,7 +879,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.MaxDelay))
proRemoteVM.Set(proRemoteVM.Time().Add(proposer.MaxVerifyDelay))

coreBlk4 := &snowman.TestBlock{
TestDecidable: choices.TestDecidable{
Expand Down
10 changes: 5 additions & 5 deletions vms/proposervm/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (p *postForkCommonComponents) Verify(

childHeight := child.Height()
proposerID := child.Proposer()
minDelay, err := p.vm.Windower.Delay(ctx, childHeight, parentPChainHeight, proposerID)
minDelay, err := p.vm.Windower.Delay(ctx, childHeight, parentPChainHeight, proposerID, proposer.MaxVerifyWindows)
if err != nil {
return err
}
Expand All @@ -155,7 +155,7 @@ func (p *postForkCommonComponents) Verify(
}

// Verify the signature of the node
shouldHaveProposer := delay < proposer.MaxDelay
shouldHaveProposer := delay < proposer.MaxVerifyDelay
if err := child.SignedBlock.Verify(shouldHaveProposer, p.vm.ctx.ChainID); err != nil {
return err
}
Expand Down Expand Up @@ -203,10 +203,10 @@ func (p *postForkCommonComponents) buildChild(
}

delay := newTimestamp.Sub(parentTimestamp)
if delay < proposer.MaxDelay {
if delay < proposer.MaxBuildDelay {
parentHeight := p.innerBlk.Height()
proposerID := p.vm.ctx.NodeID
minDelay, err := p.vm.Windower.Delay(ctx, parentHeight+1, parentPChainHeight, proposerID)
minDelay, err := p.vm.Windower.Delay(ctx, parentHeight+1, parentPChainHeight, proposerID, proposer.MaxBuildWindows)
if err != nil {
p.vm.ctx.Log.Error("unexpected build block failure",
zap.String("reason", "failed to calculate required timestamp delay"),
Expand Down Expand Up @@ -249,7 +249,7 @@ func (p *postForkCommonComponents) buildChild(

// Build the child
var statelessChild block.SignedBlock
if delay >= proposer.MaxDelay {
if delay >= proposer.MaxVerifyDelay {
statelessChild, err = block.BuildUnsigned(
parentID,
newTimestamp,
Expand Down
Loading
Loading