Skip to content

Commit c712437

Browse files
authored
Remove Stale References of the toEngine Channel (#4101)
1 parent ab60689 commit c712437

File tree

5 files changed

+4
-16
lines changed

5 files changed

+4
-16
lines changed

chains/linearizable_vm.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ func (vm *initializeOnLinearizeVM) Linearize(ctx context.Context, stopVertexID i
6767
}
6868

6969
// linearizeOnInitializeVM transforms the proposervm's call to Initialize into a
70-
// call to Linearize. This enables the proposervm to provide its toEngine
71-
// channel to the VM that is being linearized.
70+
// call to Linearize.
7271
type linearizeOnInitializeVM struct {
7372
vertex.LinearizableVMWithEngine
7473
stopVertexID ids.ID

snow/engine/common/vm.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ type VM interface {
4242
// system, `genesisBytes` would probably contain a genesis
4343
// transaction that gives coins to some accounts, and this
4444
// transaction would be in the genesis block.
45-
// [toEngine]: The channel used to send messages to the consensus engine.
4645
// [fxs]: Feature extensions that attach to this VM.
4746
Initialize(
4847
ctx context.Context,

vms/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ The Snowman VM needs to implement the following functions used by the consensus
3030

3131
Build block allows the VM to propose a new block to be added to consensus.
3232

33-
The VM can send messages to the consensus engine through a `toEngine` channel that is passed in when the VM is initialized. This channel allows the VM to send the consensus engine a message when it is ready to build a block. For example, if the VM receives some transactions via gossip or from an API, then it will signal that it is ready to build a block by sending a `PendingTxs` message to the consensus engine. The PendingTxs message signals to the consensus engine that it should call `BuildBlock()` so that the block can be added to consensus.
33+
The VM gets notified of when to build a block after `vm.WaitForEvent()` returns with a `PendingTxs` message.
3434

3535
The major caveat to this is the Snowman VMs are wrapped with [Snowman++](./proposervm/README.md). Snowman++ provides congestion control by using a soft leader, where a leader is designated as the proposer that should create a block at a given time. Snowman++ gracefully falls back to increase the number of validators that are allowed to propose a block to handle the case that the leader does not propose a block in a timely manner.
3636

@@ -113,7 +113,7 @@ Therefore, if the tree of blocks in consensus (with root L, the last accepted bl
113113
A B
114114
| / \
115115
C D G
116-
/ \
116+
/ \
117117
E F
118118
```
119119

vms/platformvm/block/executor/rejector.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package executor
66
import (
77
"go.uber.org/zap"
88

9-
"github.com/ava-labs/avalanchego/snow/engine/common"
109
"github.com/ava-labs/avalanchego/vms/platformvm/block"
1110
)
1211

@@ -17,7 +16,6 @@ var _ block.Visitor = (*rejector)(nil)
1716
// being shutdown.
1817
type rejector struct {
1918
*backend
20-
toEngine chan<- common.Message
2119
addTxsToMempool bool
2220
}
2321

@@ -88,10 +86,5 @@ func (r *rejector) rejectBlock(b block.Block, blockType string) error {
8886
return nil
8987
}
9088

91-
select {
92-
case r.toEngine <- common.PendingTxs:
93-
default:
94-
}
95-
9689
return nil
9790
}

vms/proposervm/vm_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2828,10 +2828,7 @@ func TestBootstrappingAheadOfPChainBuildBlockRegression(t *testing.T) {
28282828
return innerBlock3, nil
28292829
}
28302830

2831-
// Attempting to build a block now errors with an unexpected error. This
2832-
// results in dropping the build block request, which breaks the invariant
2833-
// that BuildBlock will be called at least once after sending a PendingTxs
2834-
// message on the ToEngine channel.
2831+
// Attempting to build a block now errors with an unexpected error.
28352832
_, err = proVM.BuildBlock(context.Background())
28362833
require.NoError(err)
28372834
}

0 commit comments

Comments
 (0)