machinefi / w3bstream-examples

14 stars 2 forks source link

Cannot deploy walk2earn.wasm in the w3bstream node #4

Open tw0l1 opened 1 year ago

tw0l1 commented 1 year ago

Hello All,

I wanted to play around with walk2earn example so I deployed my own local w3bstream node and compiled the walk2earn binary. But when I try to deploy it in the w3bstream project I get the following error related to incompatible ws_call_contract function definition.

a:panic: incompatible import type for env::ws_call_contract Caused by: function types incompatible: expected func of type (i32, i32, i32, i32) -> (i32), found func of type (i32, i32, i32, i32, i32) -> (i32); calltrace:goroutine 628 [running]: runtime/debug.Stack() /usr/local/go/src/runtime/debug/stack.go:24 +0x65 github.com/machinefi/w3bstream/pkg/depends/kit/sqlx.Task.Run.func1() /w3bstream/pkg/depends/kit/sqlx/tx_task.go:17 +0x7a panic({0x18cb780, 0xc0004c2490}) /usr/local/go/src/runtime/panic.go:884 +0x212 github.com/machinefi/w3bstream/pkg/modules/vm.NewInstance({0x1b23840, 0xc0005d6150}, {0xc0002948e0, 0x1e}, 0xc0001190f0?) /w3bstream/pkg/modules/vm/instance_new.go:25 +0x1fa github.com/machinefi/w3bstream/pkg/modules/deploy.CreateInstance.func4({0x1b28100?, 0xc00038bf00?}) /w3bstream/pkg/modules/deploy/deploy.go:66 +0x38 github.com/machinefi/w3bstream/pkg/depends/kit/sqlx.Task.Run(0x1b22ff0?, {0x1b28100?, 0xc00038bf00?}) /w3bstream/pkg/depends/kit/sqlx/tx_task.go:20 +0x72 github.com/machinefi/w3bstream/pkg/depends/kit/sqlx.(Tasks).Do(0xc000564d88) /w3bstream/pkg/depends/kit/sqlx/tx_task.go:61 +0x20a github.com/machinefi/w3bstream/pkg/modules/deploy.CreateInstance({0x1b23840, 0xc0005a3a10}, 0xc0003afbb8) /w3bstream/pkg/modules/deploy/deploy.go:68 +0x5a5 github.com/machinefi/w3bstream/cmd/srv-applet-mgr/apis/deploy.(CreateInstance).Output(0xc0003afbb0, {0x1b23840, 0xc0005a3410}) /w3bstream/cmd/srv-applet-mgr/apis/deploy/pos.go:28 +0xa9 github.com/machinefi/w3bstream/pkg/depends/kit/httptransport.(*RouteHandler).ServeHTTP(0xc00069b770, {0x1b20ff0, 0xc0000ae280}, 0xc0006f7800) /w3bstream/pkg/depends/kit/httptransport/route_handler.go:86 +0x7f6 ...

w3bstream deploy yaml: .. w3bapp: image: ${WS_BACKEND_IMAGE:-ghcr.io/machinefi/w3bstream:v1.0.0} ..
w3bstream-studio: image: ${WS_STUDIO_IMAGE:-ghcr.io/machinefi/w3bstream-studio:v1.0.2}

Is the example outdated?

Best regards, Tomek

Liuhaai commented 1 year ago

@tw0l1 there has been a pr of the walk2earn demo.

tw0l1 commented 1 year ago

Thanks for information @Liuhaai :) There is however one problem with duplicate alloc symbol during compilation. Removing the alloc from src/lib.rs resolves the problem

= note: rust-lld: error: duplicate symbol: alloc

defined in /home/w3bstream-examples/walk2earn/w3bstream/target/wasm32-wasi/release/deps/walk2earn.walk2earn.9076bcba-cgu.3.rcgu.o defined in /home/w3bstream-examples/walk2earn/w3bstream/target/wasm32-wasi/release/deps/libws_sdk-a66c45df327303e9.rlib(ws_sdk-a66c45df327303e9.ws_sdk.7e5e9268-cgu.10.rcgu.o)

Liuhaai commented 1 year ago

Thanks for information @Liuhaai :) There is however one problem with duplicate alloc symbol during compilation. Removing the alloc from src/lib.rs resolves the problem

= note: rust-lld: error: duplicate symbol: alloc >>> defined in /home/w3bstream-examples/walk2earn/w3bstream/target/wasm32-wasi/release/deps/walk2earn.walk2earn.9076bcba-cgu.3.rcgu.o >>> defined in /home/w3bstream-examples/walk2earn/w3bstream/target/wasm32-wasi/release/deps/libws_sdk-a66c45df327303e9.rlib(ws_sdk-a66c45df327303e9.ws_sdk.7e5e9268-cgu.10.rcgu.o)

Thx for the feedback. More rust examples are available here