Skip to content
New issue

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

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

Already on GitHub? # to your account

Expose getActiveOpcodes to the VM object #2363

Closed
thevaizman opened this issue Oct 17, 2022 · 3 comments
Closed

Expose getActiveOpcodes to the VM object #2363

thevaizman opened this issue Oct 17, 2022 · 3 comments

Comments

@thevaizman
Copy link

Before v6, which separated the vm and evm packages, one could instantiate a vm object and use: vm.getActiveOpcodes ot get the list of available opcodes.
Now that these 2 packages had been separated, the getActiveOpcodes function is no longer available in the context of a vm object, but only if you instantiate a separate evm object and access it via that object.

This creates an awkward situation for us, where we would instantiate both vm and evm objects, but the evm object will only be used for accessing the getActiveOpcodes.

See this comment for reference.

@jochem-brouwer
Copy link
Member

If you create a VM without any arguments, then it will by default instantiate the EVM. You can access the method by casting it: (<any>vm.evm).getActiveOpcodes(). We could however add this method as optional to the interface, so you can do; vm.evm.getActiveOpcodes!(). Would that work?

@thevaizman
Copy link
Author

thevaizman commented Oct 17, 2022

Thanks for bringing this to my attention, I didn't know the casting trick would work.
Having said that, I do feel that adding this function to the interface would be the more natural way to go with.

@holgerd77
Copy link
Member

We've added directly in the release PR here ac16d71, will close.

Tested manually by building the EVM and then running:

import { VM } from '@ethereumjs/vm'
let vm = await VM.create({})
vm.evm.getActiveOpcodes!()

Works as expected.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants