Skip to content

Commit

Permalink
Merge branch 'proposervm-build-heuristic' into update-versions-v1.10.16
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenButtolph authored Nov 22, 2023
2 parents b0fabea + 3c67fb0 commit f667b6d
Show file tree
Hide file tree
Showing 12 changed files with 345 additions and 75 deletions.
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.MaxBuildDelay))

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.MaxBuildDelay))

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.MaxBuildDelay))

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.MaxBuildDelay))

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.MaxBuildDelay))

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.MaxBuildDelay))

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

0 comments on commit f667b6d

Please sign in to comment.