Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

bhartnett
Copy link
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.

@@ -14,9 +14,9 @@ import
evmc/evmc, ../config

# 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
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.

vm[].destroy = evmcDestroy
vm[].execute = evmcExecute
vm[].get_capabilities = evmcGetCapabilities
vm[].set_option = evmcSetOption
Copy link
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
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
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
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
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..

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