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

chore: remove vmkeeper.maxcycles #2993

Merged
merged 4 commits into from
Oct 22, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions contribs/gnodev/pkg/dev/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,9 +565,8 @@ func newNodeConfig(tmc *tmcfg.Config, chainid string, appstate gnoland.GnoGenesi
}

return &gnoland.InMemoryNodeConfig{
PrivValidator: pv,
TMConfig: tmc,
Genesis: genesis,
GenesisMaxVMCycles: 100_000_000,
PrivValidator: pv,
TMConfig: tmc,
Genesis: genesis,
}
}
3 changes: 1 addition & 2 deletions gno.land/pkg/gnoland/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ type AppOptions struct {
DB dbm.DB // required
Logger *slog.Logger // required
EventSwitch events.EventSwitch // required
MaxCycles int64 // hard limit for cycles in GnoVM
InitChainerConfig // options related to InitChainer
}

Expand Down Expand Up @@ -88,7 +87,7 @@ func NewAppWithOptions(cfg *AppOptions) (abci.Application, error) {
// Construct keepers.
acctKpr := auth.NewAccountKeeper(mainKey, ProtoGnoAccount)
bankKpr := bank.NewBankKeeper(acctKpr)
vmk := vm.NewVMKeeper(baseKey, mainKey, acctKpr, bankKpr, cfg.MaxCycles)
vmk := vm.NewVMKeeper(baseKey, mainKey, acctKpr, bankKpr)

// Set InitChainer
icc := cfg.InitChainerConfig
Expand Down
10 changes: 4 additions & 6 deletions gno.land/pkg/gnoland/node_inmemory.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ import (
)

type InMemoryNodeConfig struct {
PrivValidator bft.PrivValidator // identity of the validator
Genesis *bft.GenesisDoc
TMConfig *tmcfg.Config
GenesisMaxVMCycles int64
DB *memdb.MemDB // will be initialized if nil
PrivValidator bft.PrivValidator // identity of the validator
Genesis *bft.GenesisDoc
TMConfig *tmcfg.Config
DB *memdb.MemDB // will be initialized if nil

// If StdlibDir not set, then it's filepath.Join(TMConfig.RootDir, "gnovm", "stdlibs")
InitChainerConfig
Expand Down Expand Up @@ -106,7 +105,6 @@ func NewInMemoryNode(logger *slog.Logger, cfg *InMemoryNodeConfig) (*node.Node,
// Initialize the application with the provided options
gnoApp, err := NewAppWithOptions(&AppOptions{
Logger: logger,
MaxCycles: cfg.GenesisMaxVMCycles,
DB: cfg.DB,
EventSwitch: evsw,
InitChainerConfig: cfg.InitChainerConfig,
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion gno.land/pkg/sdk/vm/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func _setupTestEnv(cacheStdlibs bool) testEnv {
ctx := sdk.NewContext(sdk.RunTxModeDeliver, ms, &bft.Header{ChainID: "test-chain-id"}, log.NewNoopLogger())
acck := authm.NewAccountKeeper(iavlCapKey, std.ProtoBaseAccount)
bank := bankm.NewBankKeeper(acck)
vmk := NewVMKeeper(baseCapKey, iavlCapKey, acck, bank, 100_000_000)
vmk := NewVMKeeper(baseCapKey, iavlCapKey, acck, bank)

mcw := ms.MultiCacheWrap()
vmk.Initialize(log.NewNoopLogger(), mcw)
Expand Down
103 changes: 46 additions & 57 deletions gno.land/pkg/sdk/vm/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@

// cached, the DeliverTx persistent state.
gnoStore gno.Store

maxCycles int64 // max allowed cylces on VM executions
}

// NewVMKeeper returns a new VMKeeper.
Expand All @@ -72,15 +70,13 @@
iavlKey store.StoreKey,
acck auth.AccountKeeper,
bank bank.BankKeeper,
maxCycles int64,
) *VMKeeper {
// TODO: create an Options struct to avoid too many constructor parameters
vmk := &VMKeeper{
baseKey: baseKey,
iavlKey: iavlKey,
acck: acck,
bank: bank,
maxCycles: maxCycles,
baseKey: baseKey,
iavlKey: iavlKey,
acck: acck,
bank: bank,
}
return vmk
}
Expand Down Expand Up @@ -267,13 +263,12 @@

m := gno.NewMachineWithOptions(
gno.MachineOptions{
PkgPath: "",
Output: os.Stdout, // XXX
Store: store,
Context: msgCtx,
Alloc: store.GetAllocator(),
MaxCycles: vm.maxCycles,
GasMeter: ctx.GasMeter(),
PkgPath: "",
Output: os.Stdout, // XXX
Store: store,
Context: msgCtx,
Alloc: store.GetAllocator(),
GasMeter: ctx.GasMeter(),

Check warning on line 271 in gno.land/pkg/sdk/vm/keeper.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/sdk/vm/keeper.go#L266-L271

Added lines #L266 - L271 were not covered by tests
})
defer m.Release()

Expand Down Expand Up @@ -368,13 +363,12 @@
// Parse and run the files, construct *PV.
m2 := gno.NewMachineWithOptions(
gno.MachineOptions{
PkgPath: "",
Output: os.Stdout, // XXX
Store: gnostore,
Alloc: gnostore.GetAllocator(),
Context: msgCtx,
MaxCycles: vm.maxCycles,
GasMeter: ctx.GasMeter(),
PkgPath: "",
Output: os.Stdout, // XXX
Store: gnostore,
Alloc: gnostore.GetAllocator(),
Context: msgCtx,
GasMeter: ctx.GasMeter(),
})
defer m2.Release()
defer func() {
Expand Down Expand Up @@ -469,13 +463,12 @@
// Construct machine and evaluate.
m := gno.NewMachineWithOptions(
gno.MachineOptions{
PkgPath: "",
Output: os.Stdout, // XXX
Store: gnostore,
Context: msgCtx,
Alloc: gnostore.GetAllocator(),
MaxCycles: vm.maxCycles,
GasMeter: ctx.GasMeter(),
PkgPath: "",
Output: os.Stdout, // XXX
Store: gnostore,
Context: msgCtx,
Alloc: gnostore.GetAllocator(),
GasMeter: ctx.GasMeter(),
})
defer m.Release()
m.SetActivePackage(mpv)
Expand Down Expand Up @@ -569,13 +562,12 @@
buf := new(bytes.Buffer)
m := gno.NewMachineWithOptions(
gno.MachineOptions{
PkgPath: "",
Output: buf,
Store: gnostore,
Alloc: gnostore.GetAllocator(),
Context: msgCtx,
MaxCycles: vm.maxCycles,
GasMeter: ctx.GasMeter(),
PkgPath: "",
Output: buf,
Store: gnostore,
Alloc: gnostore.GetAllocator(),
Context: msgCtx,
GasMeter: ctx.GasMeter(),
})
// XXX MsgRun does not have pkgPath. How do we find it on chain?
defer m.Release()
Expand All @@ -596,13 +588,12 @@

m2 := gno.NewMachineWithOptions(
gno.MachineOptions{
PkgPath: "",
Output: buf,
Store: gnostore,
Alloc: gnostore.GetAllocator(),
Context: msgCtx,
MaxCycles: vm.maxCycles,
GasMeter: ctx.GasMeter(),
PkgPath: "",
Output: buf,
Store: gnostore,
Alloc: gnostore.GetAllocator(),
Context: msgCtx,
GasMeter: ctx.GasMeter(),
})
defer m2.Release()
m2.SetActivePackage(pv)
Expand Down Expand Up @@ -728,13 +719,12 @@
}
m := gno.NewMachineWithOptions(
gno.MachineOptions{
PkgPath: pkgPath,
Output: os.Stdout, // XXX
Store: gnostore,
Context: msgCtx,
Alloc: alloc,
MaxCycles: vm.maxCycles,
GasMeter: ctx.GasMeter(),
PkgPath: pkgPath,
Output: os.Stdout, // XXX
Store: gnostore,
Context: msgCtx,
Alloc: alloc,
GasMeter: ctx.GasMeter(),

Check warning on line 727 in gno.land/pkg/sdk/vm/keeper.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/sdk/vm/keeper.go#L722-L727

Added lines #L722 - L727 were not covered by tests
})
defer m.Release()
defer func() {
Expand Down Expand Up @@ -795,13 +785,12 @@
}
m := gno.NewMachineWithOptions(
gno.MachineOptions{
PkgPath: pkgPath,
Output: os.Stdout, // XXX
Store: gnostore,
Context: msgCtx,
Alloc: alloc,
MaxCycles: vm.maxCycles,
GasMeter: ctx.GasMeter(),
PkgPath: pkgPath,
Output: os.Stdout, // XXX
Store: gnostore,
Context: msgCtx,
Alloc: alloc,
GasMeter: ctx.GasMeter(),

Check warning on line 793 in gno.land/pkg/sdk/vm/keeper.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/sdk/vm/keeper.go#L788-L793

Added lines #L788 - L793 were not covered by tests
})
defer m.Release()
defer func() {
Expand Down
Loading