Skip to content

Build nimbus evmc shared library and fix issue to enable loading#3050

Merged
bhartnett merged 3 commits intomasterfrom
build-nimbus-evmc-lib
Feb 10, 2025
Merged

Build nimbus evmc shared library and fix issue to enable loading#3050
bhartnett merged 3 commits intomasterfrom
build-nimbus-evmc-lib

Conversation

@bhartnett
Copy link
Copy Markdown
Contributor

@bhartnett bhartnett commented Feb 6, 2025

Using the evmc-vmtester tool which is a part of the evmone project to verify and test if the Nimbus EVM can be used as a standalone EVMC VM.

Before this change:

$ ./evmc-vmtester /home/user/development/status-im/nimbus-eth1/libnimbusevm.so
EVMC VM Tester 12.0.0
Testing /home/user/development/status-im/nimbus-eth1/build/libnimbusevm.so
Segmentation fault (core dumped)

After this change:

$ ./evmc-vmtester /home/user/development/status-im/nimbus-eth1/build/libnimbusevm.so
EVMC VM Tester 12.0.0
Testing /home/user/development/status-im/nimbus-eth1/build/libnimbusevm.so

[==========] Running 10 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 10 tests from evmc_vm_test
[ RUN      ] evmc_vm_test.abi_version_match
[       OK ] evmc_vm_test.abi_version_match (0 ms)
[ RUN      ] evmc_vm_test.name
[       OK ] evmc_vm_test.name (0 ms)
[ RUN      ] evmc_vm_test.version
[       OK ] evmc_vm_test.version (0 ms)
[ RUN      ] evmc_vm_test.capabilities
[       OK ] evmc_vm_test.capabilities (0 ms)
[ RUN      ] evmc_vm_test.execute_call
Segmentation fault (core dumped)

Execute call is still failing for other reasons but this gets us closer.


# 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.}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to enabled loading by the evmc-vmtester tool.

Comment thread nimbus/transaction/evmc_vm_glue.nim Outdated
vm[].destroy = evmcDestroy
vm[].execute = evmcExecute
vm[].get_capabilities = evmcGetCapabilities
vm[].set_option = evmcSetOption
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using manual memory alloc and dealloc to fix segfault caused by using ref in shared library.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iirc accessing field of a ptr object no need to use [] deref. Nim automatically produce correct code, no?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean using usual dot.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you are right. Thanks, I'll update.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw, I sometimes put an explicit [] to remind the reader to consider nil when refactoring the code..

@bhartnett bhartnett merged commit f033a40 into master Feb 10, 2025
@bhartnett bhartnett deleted the build-nimbus-evmc-lib branch February 10, 2025 02:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants