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

fix: hardcode max vm cycles in keeper #1807

Merged
merged 7 commits into from
Mar 30, 2024
Merged
Changes from 6 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
12 changes: 11 additions & 1 deletion gno.land/pkg/sdk/vm/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
const (
maxAllocTx = 500 * 1000 * 1000
maxAllocQuery = 1500 * 1000 * 1000 // higher limit for queries

// maxVMCycles is the maximum number of cycles allowed while executing a single VM
// message. Ideally this should not be needed, as execution should halt when out of
// gas. The worst case scenario is that this value is used as a fallback.
maxVMCycles = 10_000_000
)

// vm.VMKeeperI defines a module interface that supports Gno
Expand Down Expand Up @@ -57,14 +62,19 @@
stdlibsDir string,
maxCycles int64,
) *VMKeeper {
cycles := maxCycles
if cycles <= 0 || cycles > maxVMCycles {
cycles = maxVMCycles

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

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/sdk/vm/keeper.go#L67

Added line #L67 was not covered by tests
}

// TODO: create an Options struct to avoid too many constructor parameters
vmk := &VMKeeper{
baseKey: baseKey,
iavlKey: iavlKey,
acck: acck,
bank: bank,
stdlibsDir: stdlibsDir,
maxCycles: maxCycles,
maxCycles: cycles,
}
return vmk
}
Expand Down
Loading