Skip to content

Commit

Permalink
wip with store stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
colindickson committed Dec 20, 2023
1 parent b1390d5 commit e32f58f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
6 changes: 4 additions & 2 deletions wasm/bench/substreams_tiny_go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ type blockStat struct {
}

func mapBlock(block *pb.Block, readStore *ReadStore) error {
//readStore.GetAt(0, []byte("key_123"))

rocketAddress := strings.ToLower("ae78736Cd615f374D3085123A210448E74Fc6393")

approvalTopic := strings.ToLower("8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925")
Expand Down Expand Up @@ -121,7 +123,7 @@ func Println(s string) {
println(unsafe.Pointer(&d[0]), uint32(len(d)))
}

//go:wasmimport store get_at
//go:wasmimport state get_at
//go:noescape
func get_at(storeIndex uint32, ordinal uint64, keyPtr unsafe.Pointer, keyLen uint32, outputPtr unsafe.Pointer) int32

Expand Down Expand Up @@ -151,7 +153,7 @@ func NewWriteStore(storeIdx uint32) *WriteStore {
return &WriteStore{}
}

//go:wasmimport store set
//go:wasmimport state set
//go:noescape
func set(ordinal uint64, keyPtr unsafe.Pointer, keyLen uint32, valuePtr unsafe.Pointer, valueLen uint32)

Expand Down
Binary file modified wasm/bench/substreams_tiny_go/main.wasm
Binary file not shown.
6 changes: 5 additions & 1 deletion wasm/wasi/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ func newModule(ctx context.Context, wasmCode []byte, wasmCodeType string, regist
if err != nil {
return nil, err
}
hostModules = append(hostModules, loggerModule)
stateModule, err := sfwaz.AddHostFunctions(ctx, runtime, "state", sfwaz.StateFuncs)
if err != nil {
return nil, err
}
hostModules = append(hostModules, loggerModule, stateModule)

//startFunc := "main"
//switch wasmCodeType {
Expand Down
2 changes: 1 addition & 1 deletion wasm/wazero/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func newModule(ctx context.Context, wasmCode []byte, wasmCodeType string, regist
if err != nil {
return nil, err
}
stateModule, err := AddHostFunctions(ctx, runtime, "state", stateFuncs)
stateModule, err := AddHostFunctions(ctx, runtime, "state", StateFuncs)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion wasm/wazero/state_hostmod.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type funcs struct {
f api.GoModuleFunction
}

var stateFuncs = []funcs{
var StateFuncs = []funcs{
{
"set",
[]parm{i64, i32, i32, i32, i32},
Expand Down

0 comments on commit e32f58f

Please sign in to comment.