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

VM -> Tree Shaking: Decouple runBlock(), runTx() and buildBlock() #3522

Closed
holgerd77 opened this issue Jul 19, 2024 · 2 comments
Closed

VM -> Tree Shaking: Decouple runBlock(), runTx() and buildBlock() #3522

holgerd77 opened this issue Jul 19, 2024 · 2 comments

Comments

@holgerd77
Copy link
Member

holgerd77 commented Jul 19, 2024

Part of #3446

In the VM there are these three central methods runBlock(), runTx() and buildBlock() which have separate files on their own (like runBlock.ts and are already build for taking in the VM as an object (export async function runBlock(this: VM, opts: RunBlockOpts): Promise<RunBlockResult>). These functions are then bound in the vm.ts file to the VM object with code like this:

async runBlock(opts: RunBlockOpts): Promise<RunBlockResult> {
  return runBlock.bind(this)(opts)
}

This basically does nothing useful except effectively chop off tree shaking and we can easily improve the situation by removing those bindings and switch calling into these like this without loosing any comfort:

vm.runBlock(opts: RunBlockOpts) // old
runBlock(vm, opts) // new

(I would have a tendency to keep the simple names)

In fact these methods are very much functional/procedural by nature (so just: wrapping some flow around some objects (EVM, StateManager, Blockchain) and not so much about "doing manipulations on the VM object" (what is a "VM" anyway?), so this might generally even be the more fitting design. But that just as a side note.

Bundle for this part looks like this:

grafik

With the decoupling the respectively not-used parts (so if one is e.g. only calling into runTx() this will be: runTx(), buildBlock() and even the requests stuff (used in runBlock() and buildBlock()) will go away.

@holgerd77
Copy link
Member Author

Note: we can generally further think about where we are with VM (was e.g. wondering in between if we still need/want a VM class at all?), but I would suggest to first round start with this work, since it's pretty simple and already brings us along for some significant part of the way.

@scorbajio
Copy link
Contributor

Addressed by #3530.

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

No branches or pull requests

3 participants