Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
ad38229
This commit removes the toEngine channel pattern from all VMs and add…
yacovm Apr 16, 2025
671be9a
Address code review comments
yacovm Jun 25, 2025
285cf35
Return error and change name
yacovm Jun 25, 2025
d4e4b5c
Migrate XSVM to new API format
StephenButtolph Jun 30, 2025
fbd2cde
comment nits
StephenButtolph Jun 30, 2025
e139bab
Migrate AVM to new API format
StephenButtolph Jun 30, 2025
690abcf
Address code review comments II
yacovm Jun 26, 2025
152b126
Fix some concurrency bugs
yacovm Jun 27, 2025
f86cc8c
Add tests
StephenButtolph Jun 30, 2025
c9b6541
reduce diff
StephenButtolph Jun 30, 2025
de3cee3
fix reduce diff
StephenButtolph Jun 30, 2025
9b3c565
undo revert
StephenButtolph Jun 30, 2025
55f5ed5
Migrate PlatformVM to new API format
StephenButtolph Jun 30, 2025
92610b4
Fix test flake TestSubscriptionProxy/close
yacovm Jun 30, 2025
6f89bbf
Reintroduce log
StephenButtolph Jun 30, 2025
a44dac5
Migrate ProposerVM to new API format
StephenButtolph Jun 30, 2025
1c66cd3
check state prior to looking for the block
StephenButtolph Jun 30, 2025
b6d8346
cleanup mock
StephenButtolph Jun 30, 2025
5e79f76
document
StephenButtolph Jun 30, 2025
26a0828
Wait for preference to change when notifying
yacovm Jul 1, 2025
fa866e3
fix data race in cond_test.go
yacovm Jul 2, 2025
66e1b47
lint issues
yacovm Jul 3, 2025
0745024
RIP subscription proxy and simplesubscriber
yacovm Jul 3, 2025
4f40414
Add some logs, hopefully we won't need them
yacovm Jul 3, 2025
5021ccb
Close NF when shutdown
yacovm Jul 3, 2025
0fe7328
Implement VM optional methods
yacovm Jul 3, 2025
c9b974d
Synchronize goroutine values in UT via channels
yacovm Jul 3, 2025
b3cb49a
Address code review comments about tests
yacovm Jul 3, 2025
08294e7
Address code review comments
yacovm Jul 3, 2025
de0e09d
Notify() uses context
yacovm Jul 3, 2025
690a89c
Use parent context to close NotificationForwarder
yacovm Jul 3, 2025
33e9e2c
Start NotificationForwarder upon creation
yacovm Jul 3, 2025
41a2450
Complete tests for ChangeNotifier
yacovm Jul 6, 2025
083434b
Move notifier to engine/snowman/block
yacovm Jul 6, 2025
22d6152
Move notification forwarder initialization into handler
yacovm Jul 7, 2025
3338f36
Rename PreferenceOrStateChanged to CheckForEvent
yacovm Jul 7, 2025
b19d0e1
Address code review comments on notifier and handler
yacovm Jul 7, 2025
8331647
Lint and fixc compilation error
yacovm Jul 7, 2025
963b5bd
Change logging level for unexpected message to INFO
yacovm Jul 7, 2025
8d76a16
Address code review comments
yacovm Jul 7, 2025
a5b0de2
Do not wake-up notifier if preference has been set to its previous one
yacovm Jul 7, 2025
3100f7d
Pick up latest coreth version
yacovm Jul 7, 2025
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
34 changes: 23 additions & 11 deletions chains/linearizable_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package chains

import (
"context"
"sync"

"github.com/ava-labs/avalanchego/database"
"github.com/ava-labs/avalanchego/ids"
Expand All @@ -28,26 +29,38 @@ type initializeOnLinearizeVM struct {
vmToInitialize common.VM
vmToLinearize *linearizeOnInitializeVM

ctx *snow.Context
db database.Database
genesisBytes []byte
upgradeBytes []byte
configBytes []byte
toEngine chan<- common.Message
fxs []*common.Fx
appSender common.AppSender
ctx *snow.Context
db database.Database
genesisBytes []byte
upgradeBytes []byte
configBytes []byte
fxs []*common.Fx
appSender common.AppSender
waitForLinearize chan struct{}
linearizeOnce sync.Once
}

func (vm *initializeOnLinearizeVM) WaitForEvent(ctx context.Context) (common.Message, error) {
select {
case <-vm.waitForLinearize:
return vm.vmToInitialize.WaitForEvent(ctx)
case <-ctx.Done():
return 0, ctx.Err()
}
}

func (vm *initializeOnLinearizeVM) Linearize(ctx context.Context, stopVertexID ids.ID) error {
vm.vmToLinearize.stopVertexID = stopVertexID
defer vm.linearizeOnce.Do(func() {
close(vm.waitForLinearize)
})
return vm.vmToInitialize.Initialize(
ctx,
vm.ctx,
vm.db,
vm.genesisBytes,
vm.upgradeBytes,
vm.configBytes,
vm.toEngine,
vm.fxs,
vm.appSender,
)
Expand All @@ -74,9 +87,8 @@ func (vm *linearizeOnInitializeVM) Initialize(
_ []byte,
_ []byte,
_ []byte,
toEngine chan<- common.Message,
_ []*common.Fx,
_ common.AppSender,
) error {
return vm.Linearize(ctx, vm.stopVertexID, toEngine)
return vm.Linearize(ctx, vm.stopVertexID)
}
33 changes: 18 additions & 15 deletions chains/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -727,10 +727,6 @@ func (m *manager) createAvalancheChain(
},
)

// The channel through which a VM may send messages to the consensus engine
// VM uses this channel to notify engine that a block is ready to be made
msgChan := make(chan common.Message, defaultChannelSize)

// The only difference between using avalancheMessageSender and
// snowmanMessageSender here is where the metrics will be placed. Because we
// end up using this sender after the linearization, we pass in
Expand All @@ -742,7 +738,6 @@ func (m *manager) createAvalancheChain(
genesisData,
chainConfig.Upgrade,
chainConfig.Config,
msgChan,
fxs,
snowmanMessageSender,
)
Expand Down Expand Up @@ -811,19 +806,25 @@ func (m *manager) createAvalancheChain(
vmWrappingProposerVM = tracedvm.NewBlockVM(vmWrappingProposerVM, "proposervm", m.Tracer)
}

cn := &block.ChangeNotifier{
ChainVM: vmWrappingProposerVM,
}

vmWrappingProposerVM = cn

// Note: linearizableVM is the VM that the Avalanche engines should be
// using.
linearizableVM := &initializeOnLinearizeVM{
DAGVM: dagVM,
vmToInitialize: vmWrappingProposerVM,
vmToLinearize: untracedVMWrappedInsideProposerVM,
waitForLinearize: make(chan struct{}),
DAGVM: dagVM,
vmToInitialize: vmWrappingProposerVM,
vmToLinearize: untracedVMWrappedInsideProposerVM,

ctx: ctx.Context,
db: vmDB,
genesisBytes: genesisData,
upgradeBytes: chainConfig.Upgrade,
configBytes: chainConfig.Config,
toEngine: msgChan,
fxs: fxs,
appSender: snowmanMessageSender,
}
Expand Down Expand Up @@ -885,8 +886,9 @@ func (m *manager) createAvalancheChain(
// Asynchronously passes messages from the network to the consensus engine
h, err := handler.New(
ctx,
cn,
linearizableVM.WaitForEvent,
vdrs,
msgChan,
m.FrontierPollFrequency,
m.ConsensusAppConcurrency,
m.ResourceTracker,
Expand Down Expand Up @@ -1202,9 +1204,10 @@ func (m *manager) createSnowmanChain(
vm = tracedvm.NewBlockVM(vm, "proposervm", m.Tracer)
}

// The channel through which a VM may send messages to the consensus engine
// VM uses this channel to notify engine that a block is ready to be made
msgChan := make(chan common.Message, defaultChannelSize)
cn := &block.ChangeNotifier{
ChainVM: vm,
}
vm = cn

if err := vm.Initialize(
context.TODO(),
Expand All @@ -1213,7 +1216,6 @@ func (m *manager) createSnowmanChain(
genesisData,
chainConfig.Upgrade,
chainConfig.Config,
msgChan,
fxs,
messageSender,
); err != nil {
Expand Down Expand Up @@ -1277,8 +1279,9 @@ func (m *manager) createSnowmanChain(
// Asynchronously passes messages from the network to the consensus engine
h, err := handler.New(
ctx,
cn,
vm.WaitForEvent,
vdrs,
msgChan,
m.FrontierPollFrequency,
m.ConsensusAppConcurrency,
m.ResourceTracker,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/DataDog/zstd v1.5.2
github.com/StephenButtolph/canoto v0.17.1
github.com/antithesishq/antithesis-sdk-go v0.3.8
github.com/ava-labs/coreth v0.15.2-rc.0.0.20250620163936-0058a7ec6d9d
github.com/ava-labs/coreth v0.15.3-0.20250707191145-055af77d543b
github.com/ava-labs/ledger-avalanche/go v0.0.0-20241009183145-e6f90a8a1a60
github.com/ava-labs/libevm v1.13.14-0.3.0.rc.1
github.com/btcsuite/btcd/btcutil v1.1.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ github.com/antithesishq/antithesis-sdk-go v0.3.8/go.mod h1:IUpT2DPAKh6i/YhSbt6Gl
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/ava-labs/coreth v0.15.2-rc.0.0.20250620163936-0058a7ec6d9d h1:nZA7nEhlf2uWM1doZz4WFiMkZVZ0iH+c3IebokIO1sk=
github.com/ava-labs/coreth v0.15.2-rc.0.0.20250620163936-0058a7ec6d9d/go.mod h1:Mk5g2ZI9lEbxA67qikOtUrq71Yr389B34S+Ddsa51K4=
github.com/ava-labs/coreth v0.15.3-0.20250707191145-055af77d543b h1:+Dmp2AiyY+A9eTyDFkElYtM3ZxJe8bSxAjTAePVoHB8=
github.com/ava-labs/coreth v0.15.3-0.20250707191145-055af77d543b/go.mod h1:uRMiwnKMtGac3Oftq9/tULLjtgjChe5zoRjQhvhePaw=
github.com/ava-labs/ledger-avalanche/go v0.0.0-20241009183145-e6f90a8a1a60 h1:EL66gtXOAwR/4KYBjOV03LTWgkEXvLePribLlJNu4g0=
github.com/ava-labs/ledger-avalanche/go v0.0.0-20241009183145-e6f90a8a1a60/go.mod h1:/7qKobTfbzBu7eSTVaXMTr56yTYk4j2Px6/8G+idxHo=
github.com/ava-labs/libevm v1.13.14-0.3.0.rc.1 h1:vBMYo+Iazw0rGTr+cwjkBdh5eadLPlv4ywI4lKye3CA=
Expand Down
2 changes: 1 addition & 1 deletion node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ import (
databasefactory "github.com/ava-labs/avalanchego/database/factory"
avmconfig "github.com/ava-labs/avalanchego/vms/avm/config"
platformconfig "github.com/ava-labs/avalanchego/vms/platformvm/config"
coreth "github.com/ava-labs/coreth/plugin/evm"
coreth "github.com/ava-labs/coreth/plugin/factory"
)

const (
Expand Down
21 changes: 0 additions & 21 deletions proto/messenger/messenger.proto

This file was deleted.

Loading
Loading