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

Remove CreateStaticHandlers from VM interface #2589

Merged
merged 5 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/admin/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ func (a *Admin) LoadVMs(r *http.Request, _ *struct{}, reply *LoadVMsReply) error
defer a.lock.Unlock()

ctx := r.Context()
loadedVMs, failedVMs, err := a.VMRegistry.ReloadWithReadLock(ctx)
loadedVMs, failedVMs, err := a.VMRegistry.Reload(ctx)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions api/admin/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestLoadVMsSuccess(t *testing.T) {
id2: alias2[1:],
}

resources.mockVMRegistry.EXPECT().ReloadWithReadLock(gomock.Any()).Times(1).Return(newVMs, failedVMs, nil)
resources.mockVMRegistry.EXPECT().Reload(gomock.Any()).Times(1).Return(newVMs, failedVMs, nil)
resources.mockVMManager.EXPECT().Aliases(id1).Times(1).Return(alias1, nil)
resources.mockVMManager.EXPECT().Aliases(id2).Times(1).Return(alias2, nil)

Expand All @@ -81,7 +81,7 @@ func TestLoadVMsReloadFails(t *testing.T) {
resources := initLoadVMsTest(t)

// Reload fails
resources.mockVMRegistry.EXPECT().ReloadWithReadLock(gomock.Any()).Times(1).Return(nil, nil, errTest)
resources.mockVMRegistry.EXPECT().Reload(gomock.Any()).Times(1).Return(nil, nil, errTest)

reply := LoadVMsReply{}
err := resources.admin.LoadVMs(&http.Request{}, nil, &reply)
Expand All @@ -103,7 +103,7 @@ func TestLoadVMsGetAliasesFails(t *testing.T) {
// every vm is at least aliased to itself.
alias1 := []string{id1.String(), "vm1-alias-1", "vm1-alias-2"}

resources.mockVMRegistry.EXPECT().ReloadWithReadLock(gomock.Any()).Times(1).Return(newVMs, failedVMs, nil)
resources.mockVMRegistry.EXPECT().Reload(gomock.Any()).Times(1).Return(newVMs, failedVMs, nil)
resources.mockVMManager.EXPECT().Aliases(id1).Times(1).Return(alias1, nil)
resources.mockVMManager.EXPECT().Aliases(id2).Times(1).Return(nil, errTest)

Expand Down
15 changes: 4 additions & 11 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -1172,13 +1172,6 @@ func (n *Node) initVMs() error {
vdrs = validators.NewManager()
}

vmRegisterer := registry.NewVMRegisterer(registry.VMRegistererConfig{
APIServer: n.APIServer,
Log: n.Log,
VMFactoryLog: n.VMFactoryLog,
VMManager: n.VMManager,
})

durangoTime := version.GetDurangoTime(n.Config.NetworkID)
if err := txs.InitCodec(durangoTime); err != nil {
return err
Expand All @@ -1192,7 +1185,7 @@ func (n *Node) initVMs() error {

// Register the VMs that Avalanche supports
err := utils.Err(
vmRegisterer.Register(context.TODO(), constants.PlatformVMID, &platformvm.Factory{
n.VMManager.RegisterFactory(context.TODO(), constants.PlatformVMID, &platformvm.Factory{
Config: platformconfig.Config{
Chains: n.chainManager,
Validators: vdrs,
Expand Down Expand Up @@ -1225,14 +1218,14 @@ func (n *Node) initVMs() error {
UseCurrentHeight: n.Config.UseCurrentHeight,
},
}),
vmRegisterer.Register(context.TODO(), constants.AVMID, &avm.Factory{
n.VMManager.RegisterFactory(context.TODO(), constants.AVMID, &avm.Factory{
Config: avmconfig.Config{
TxFee: n.Config.TxFee,
CreateAssetTxFee: n.Config.CreateAssetTxFee,
DurangoTime: durangoTime,
},
}),
vmRegisterer.Register(context.TODO(), constants.EVMID, &coreth.Factory{}),
n.VMManager.RegisterFactory(context.TODO(), constants.EVMID, &coreth.Factory{}),
n.VMManager.RegisterFactory(context.TODO(), secp256k1fx.ID, &secp256k1fx.Factory{}),
n.VMManager.RegisterFactory(context.TODO(), nftfx.ID, &nftfx.Factory{}),
n.VMManager.RegisterFactory(context.TODO(), propertyfx.ID, &propertyfx.Factory{}),
Expand All @@ -1253,7 +1246,7 @@ func (n *Node) initVMs() error {
CPUTracker: n.resourceManager,
RuntimeTracker: n.runtimeManager,
}),
VMRegisterer: vmRegisterer,
VMManager: n.VMManager,
})

// register any vms that need to be installed as plugins from disk
Expand Down