tangle-network / tangle

Modular restaking infrastructure for developers, restakers, and operators.
https://www.tangle.tools/
GNU General Public License v3.0
51 stars 24 forks source link

[TASK] Fix Substrate Benchmarking framework so we can benchmark tangle #779

Closed shekohex closed 6 days ago

shekohex commented 1 week ago

Currently the benchmarking workflow is broken, not working, does not compile at all, even if after fighting with the compiler and fixing all the issues and make it compiles, it does not run and returns the following error:

./target/release/tangle benchmark pallet --chain benchmark --pallet pallet_services --extrinsic '*' --steps 50 --repeat 20 --output ./pallets/services/src/weights.rs --template ./.maintain/frame-weights-template.hbs

Output:

2024-10-02 18:10:17 Using the chain spec instead of the runtime to generate the genesis state is deprecated. Please remove the `--chain`/`--dev`/`--local` argument, point `--runtime` to your runtime blob and set `--genesis-builder=runtime`. This warning may become a hard error any time after December 2024.
2024-10-02 18:10:18 [0] 💸 generated 8 npos voters, 8 from validators and 0 nominators
2024-10-02 18:10:18 [0] 💸 generated 8 npos targets
2024-10-02 18:10:18 Loading WASM from genesis state
Error: Input("Could not call runtime API to Did not find the benchmarking metadata. This could mean that you either did not build the node correctly with the `--features runtime-benchmarks` flag, or the chain spec that you are using was not created by a node that was compiled with the flag: Other error happened while constructing the runtime: runtime requires function imports which are not present on the host: 'env:ext_ext_evm_event_version_1', 'env:ext_ext_step_event_filter_version_1', 'env:ext_ext_call_list_new_version_2', 'env:ext_ext_gasometer_event_version_1', 'env:ext_ext_runtime_event_version_1'")
2024-10-02 18:10:18 Cannot create a runtime error=Other("runtime requires function imports which are not present on the host: 'env:ext_ext_evm_event_version_1', 'env:ext_ext_step_event_filter_version_1', 'env:ext_ext_call_list_new_version_2', 'env:ext_ext_gasometer_event_version_1', 'env:ext_ext_runtime_event_version_1'")
shekohex commented 1 week ago

So it looks like it is missing some host functions for some reason: runtime requires function imports which are not present on the host: 'env:ext_ext_call_list_new_version_2', 'env:ext_ext_step_event_filter_version_1', 'env:ext_ext_gasometer_event_version_1', 'env:ext_ext_runtime_event_version_1', 'env:ext_ext_evm_event_version_1'"

And it looks like these functions comes from https://github.com/webb-tools/tangle/blob/7c12d9ef9b922cdd30118ab55c00b959dcd8d2db/primitives/ext/src/lib.rs#L36-L85

even though they are registered as you can see here: https://github.com/webb-tools/tangle/blob/7c12d9ef9b922cdd30118ab55c00b959dcd8d2db/node/src/service.rs#L79-L81

It still complains that it is missing from the runtime!

shekohex commented 1 week ago

It looks like we have to define the HostFunctions here too: https://github.com/webb-tools/tangle/blob/7c12d9ef9b922cdd30118ab55c00b959dcd8d2db/node/src/command.rs#L238

That actually made it works.