Skip to content

Commit

Permalink
[x/programs] Set bulk memory support on debug mode (#599)
Browse files Browse the repository at this point in the history
* bulk mem support

* bulk mem support auto enabled

* set on true only

* comment rephrase

* remove dangling doc line

---------

Co-authored-by: Sam Batschelet <sam.batschelet@avalabs.org>
  • Loading branch information
samliok and hexfusion authored Nov 6, 2023
1 parent 80c1e5e commit 70bd5ae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 0 additions & 2 deletions x/programs/cmd/simulator/vm/actions/program_execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ func (t *ProgramExecute) Execute(
// TODO: get cfg from genesis
cfg, err := runtime.NewConfigBuilder().
WithDebugMode(true).
WithBulkMemory(true).
// only required for Wasi support exposed by testing only.
Build()
if err != nil {
return false, 1, utils.ErrBytes(err), nil, nil
Expand Down
14 changes: 10 additions & 4 deletions x/programs/runtime/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,21 @@ func (c *ConfigBuilder) WithDefaultCache(enabled bool) *ConfigBuilder {
}

// WithDebugMode enables debug mode which provides access to
// useful debugging information. This should not be set for a live
// system as it has both performance and security considerations.
// useful debugging information. If [enabled] is true we set
// EnableBulkMemory to support useful IO operations during debugging.
//
// Note: This requires Rust programs to be compiled with the Wasm to be
// compiled with the wasm32-wasi target.
// This should not be set for a live system as it has
// both performance and security considerations.
//
// Note: This requires Rust programs to be compiled with the wasm32-wasi target.
//
// Default is false.
func (c *ConfigBuilder) WithDebugMode(enabled bool) *ConfigBuilder {
c.EnableDebugMode = enabled
if enabled {
c.EnableBulkMemory = true
}

return c
}

Expand Down

0 comments on commit 70bd5ae

Please sign in to comment.