mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-02-28 20:00:43 +00:00
Build nimbus evmc shared library and fix issue to enable loading (#3050)
This commit is contained in:
parent
67b8dd7fdc
commit
f033a40482
20
Makefile
20
Makefile
@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2018-2024 Status Research & Development GmbH. Licensed under
|
# Copyright (c) 2018-2025 Status Research & Development GmbH. Licensed under
|
||||||
# either of:
|
# either of:
|
||||||
# - Apache License, version 2.0
|
# - Apache License, version 2.0
|
||||||
# - MIT license
|
# - MIT license
|
||||||
@ -83,14 +83,14 @@ FLUFFY_TOOLS_DIRS := \
|
|||||||
FLUFFY_TOOLS_CSV := $(subst $(SPACE),$(COMMA),$(FLUFFY_TOOLS))
|
FLUFFY_TOOLS_CSV := $(subst $(SPACE),$(COMMA),$(FLUFFY_TOOLS))
|
||||||
|
|
||||||
# Namespaced variables to avoid conflicts with other makefiles
|
# Namespaced variables to avoid conflicts with other makefiles
|
||||||
VERIF_PROXY_OS = $(shell $(CC) -dumpmachine)
|
OS_PLATFORM = $(shell $(CC) -dumpmachine)
|
||||||
ifneq (, $(findstring darwin, $(VERIF_PROXY_OS)))
|
ifneq (, $(findstring darwin, $(OS_PLATFORM)))
|
||||||
VERIF_PROXY_SHAREDLIBEXT = dylib
|
SHAREDLIBEXT = dylib
|
||||||
else
|
else
|
||||||
ifneq (, $(findstring mingw, $(VERIF_PROXY_OS))$(findstring cygwin, $(VERIF_PROXY_OS))$(findstring msys, $(VERIF_PROXY_OS)))
|
ifneq (, $(findstring mingw, $(OS_PLATFORM))$(findstring cygwin, $(OS_PLATFORM))$(findstring msys, $(OS_PLATFORM)))
|
||||||
VERIF_PROXY_SHAREDLIBEXT = dll
|
SHAREDLIBEXT = dll
|
||||||
else
|
else
|
||||||
VERIF_PROXY_SHAREDLIBEXT = so
|
SHAREDLIBEXT = so
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -333,7 +333,7 @@ nimbus-verified-proxy-test: | build deps rocksdb
|
|||||||
libverifproxy: | build deps rocksdb
|
libverifproxy: | build deps rocksdb
|
||||||
+ echo -e $(BUILD_MSG) "build/$@" && \
|
+ echo -e $(BUILD_MSG) "build/$@" && \
|
||||||
$(ENV_SCRIPT) nim --version && \
|
$(ENV_SCRIPT) nim --version && \
|
||||||
$(ENV_SCRIPT) nim c --app:lib -d:"libp2p_pki_schemes=secp256k1" --noMain:on --threads:on --nimcache:nimcache/libverifproxy -o:$(VERIF_PROXY_OUT_PATH)/$@.$(VERIF_PROXY_SHAREDLIBEXT) $(NIM_PARAMS) nimbus_verified_proxy/libverifproxy/verifproxy.nim
|
$(ENV_SCRIPT) nim c --app:lib -d:"libp2p_pki_schemes=secp256k1" --noMain:on --threads:on --nimcache:nimcache/libverifproxy -o:$(VERIF_PROXY_OUT_PATH)/$@.$(SHAREDLIBEXT) $(NIM_PARAMS) nimbus_verified_proxy/libverifproxy/verifproxy.nim
|
||||||
cp nimbus_verified_proxy/libverifproxy/verifproxy.h $(VERIF_PROXY_OUT_PATH)/
|
cp nimbus_verified_proxy/libverifproxy/verifproxy.h $(VERIF_PROXY_OUT_PATH)/
|
||||||
echo -e $(BUILD_END_MSG) "build/$@"
|
echo -e $(BUILD_END_MSG) "build/$@"
|
||||||
|
|
||||||
@ -357,6 +357,10 @@ evmstate_test: | build deps evmstate
|
|||||||
txparse: | build deps
|
txparse: | build deps
|
||||||
$(ENV_SCRIPT) nim c $(NIM_PARAMS) "tools/txparse/$@.nim"
|
$(ENV_SCRIPT) nim c $(NIM_PARAMS) "tools/txparse/$@.nim"
|
||||||
|
|
||||||
|
# builds the nimbus evmc shared library
|
||||||
|
libnimbusevm: | build deps
|
||||||
|
$(ENV_SCRIPT) nim c $(NIM_PARAMS) -d:evmc_enabled --app:lib --noMain -o:build/libnimbusevm/$@.$(SHAREDLIBEXT) nimbus/transaction/evmc_vm_glue.nim
|
||||||
|
|
||||||
# usual cleaning
|
# usual cleaning
|
||||||
clean: | clean-common
|
clean: | clean-common
|
||||||
rm -rf build/{nimbus,nimbus_execution_client,fluffy,libverifproxy,nimbus_verified_proxy,$(TOOLS_CSV),$(FLUFFY_TOOLS_CSV),all_tests,test_kvstore_rocksdb,test_rpc,all_fluffy_tests,all_history_network_custom_chain_tests,test_portal_testnet,utp_test_app,utp_test,*.dSYM}
|
rm -rf build/{nimbus,nimbus_execution_client,fluffy,libverifproxy,nimbus_verified_proxy,$(TOOLS_CSV),$(FLUFFY_TOOLS_CSV),all_tests,test_kvstore_rocksdb,test_rpc,all_fluffy_tests,all_history_network_custom_chain_tests,test_portal_testnet,utp_test_app,utp_test,*.dSYM}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Nimbus - Dynamic loader for EVM modules as shared libraries / DLLs
|
# Nimbus - Dynamic loader for EVM modules as shared libraries / DLLs
|
||||||
#
|
#
|
||||||
# Copyright (c) 2019-2024 Status Research & Development GmbH
|
# Copyright (c) 2019-2025 Status Research & Development GmbH
|
||||||
# Licensed under either of
|
# Licensed under either of
|
||||||
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
|
||||||
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
|
||||||
@ -14,9 +14,9 @@ import
|
|||||||
evmc/evmc, ../config
|
evmc/evmc, ../config
|
||||||
|
|
||||||
# The built-in Nimbus EVM, via imported C function.
|
# The built-in Nimbus EVM, via imported C function.
|
||||||
proc evmc_create_nimbus_evm(): ptr evmc_vm {.cdecl, importc, raises: [], gcsafe.}
|
proc evmc_create_nimbusevm(): ptr evmc_vm {.cdecl, importc, raises: [], gcsafe.}
|
||||||
|
|
||||||
# Import this module to link in the definition of `evmc_create_nimbus_evm`.
|
# Import this module to link in the definition of `evmc_create_nimbusevm`.
|
||||||
# Nim thinks the module is unused because the function is only called via
|
# Nim thinks the module is unused because the function is only called via
|
||||||
# `.exportc` -> `.importc`.
|
# `.exportc` -> `.importc`.
|
||||||
{.warning[UnusedImport]: off.}:
|
{.warning[UnusedImport]: off.}:
|
||||||
@ -36,7 +36,7 @@ proc evmcLoadVMGetCreateFn(): (evmc_create_vm_name_fn, string) =
|
|||||||
|
|
||||||
# Use built-in EVM if no other is specified.
|
# Use built-in EVM if no other is specified.
|
||||||
if path.len == 0:
|
if path.len == 0:
|
||||||
return (evmc_create_nimbus_evm, "built-in")
|
return (evmc_create_nimbusevm, "built-in")
|
||||||
|
|
||||||
# The steps below match the EVMC Loader documentation, copied here:
|
# The steps below match the EVMC Loader documentation, copied here:
|
||||||
#
|
#
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Nimbus - Binary compatibility on the VM side of the EVMC API interface
|
# Nimbus - Binary compatibility on the VM side of the EVMC API interface
|
||||||
#
|
#
|
||||||
# Copyright (c) 2019-2024 Status Research & Development GmbH
|
# Copyright (c) 2019-2025 Status Research & Development GmbH
|
||||||
# Licensed under either of
|
# Licensed under either of
|
||||||
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
|
||||||
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
|
||||||
@ -82,24 +82,24 @@ proc evmcSetOption(vm: ptr evmc_vm, name, value: cstring): evmc_set_option_resul
|
|||||||
return EVMC_SET_OPTION_INVALID_NAME
|
return EVMC_SET_OPTION_INVALID_NAME
|
||||||
|
|
||||||
proc evmcDestroy(vm: ptr evmc_vm) {.cdecl.} =
|
proc evmcDestroy(vm: ptr evmc_vm) {.cdecl.} =
|
||||||
GC_unref(cast[ref evmc_vm](vm))
|
dealloc(vm)
|
||||||
|
|
||||||
proc evmc_create_nimbus_evm(): ptr evmc_vm {.cdecl, exportc.} =
|
proc evmc_create_nimbusevm*(): ptr evmc_vm {.cdecl, exportc, dynlib.} =
|
||||||
## Entry point to the Nimbus EVM, using an EVMC compatible interface.
|
## Entry point to the Nimbus EVM, using an EVMC compatible interface.
|
||||||
## This is an exported C function. EVMC specifies the function must
|
## This is an exported C function. EVMC specifies the function must
|
||||||
## have this name format when exported from a shared library.
|
## have this name format when exported from a shared library.
|
||||||
let vm = (ref evmc_vm)(
|
|
||||||
abi_version: EVMC_ABI_VERSION,
|
let vm = cast[ptr evmc_vm](alloc(sizeof(evmc_vm)))
|
||||||
name: evmcName,
|
|
||||||
version: evmcVersion,
|
vm.abi_version = EVMC_ABI_VERSION
|
||||||
destroy: evmcDestroy,
|
vm.name = evmcName
|
||||||
execute: evmcExecute,
|
vm.version = evmcVersion
|
||||||
get_capabilities: evmcGetCapabilities,
|
vm.destroy = evmcDestroy
|
||||||
set_option: evmcSetOption
|
vm.execute = evmcExecute
|
||||||
)
|
vm.get_capabilities = evmcGetCapabilities
|
||||||
# Keep an extra reference on this, until `evmcDestroy` is called.
|
vm.set_option = evmcSetOption
|
||||||
GC_ref(vm)
|
|
||||||
return cast[ptr evmc_vm](vm)
|
return vm
|
||||||
|
|
||||||
# This code assumes fields, methods and types of ABI version 12, and must be
|
# This code assumes fields, methods and types of ABI version 12, and must be
|
||||||
# checked for compatibility if the `import evmc/evmc` major version is updated.
|
# checked for compatibility if the `import evmc/evmc` major version is updated.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user