-
Notifications
You must be signed in to change notification settings - Fork 758
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
EVM/Monorepo: Verkle Decoupling #3462
EVM/Monorepo: Verkle Decoupling #3462
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more. |
@@ -272,9 +271,7 @@ export class Interpreter { | |||
const contract = this._runState.interpreter.getAddress() | |||
|
|||
if ( | |||
!(await ( | |||
this._runState.stateManager as StatelessVerkleStateManager |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This generally won't affect tree shaking. TypeScript types are always removed even if they are values or classes as long as they are used as a type as long as we use import type
syntax
@holgerd77 wierd rollup didn't work but since you are already using vitest using vite is likely the easiest. I added a bundle analyzer setup you can use in this pr #3463 |
…le-extended interface usage
…AccessWitness implementation in StateManager
…umjs/verkle dependency
1b27cd8
to
32ab354
Compare
…, remove async create constructor, move verkle-cryptography-wasm to dev dependenciew
…nstantiations, add verkle-cryptography-wasm to Client package.json
…@ethereumjs/verkle usages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactor looks superclean and modular. don't have insight into tree shaking however as of now, so for that will delegate to experts :)
This is still in the pre-tree-shaking era, so just removing dependencies so that they are not there. 😂 |
* @return The tree key as a Uint8Array. | ||
*/ | ||
|
||
export const getKey = (stem: Uint8Array, leaf: LeafType | Uint8Array) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor note on a few of these helpers. They were initially named quite minimally getKey
rather than getVerkleTreekey
because the "verkle" was obvious from it being imported from the verkle package. I feel like we should likely rename these helpers more explicitly as "verkle" since they are now exported in utils (getKey
could be so many things). We could perhaps do the same with VERSION_LEAF_KEY
=> VERKLE_VERSION_LEAF_KEY
…-interface-and-evm-dependency-removal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor note on a few of these helpers. They were initially named quite minimally
getKey
rather thangetVerkleTreekey
because the "verkle" was obvious from it being imported from the verkle package. I feel like we should likely rename these helpers more explicitly as "verkle" since they are now exported in utils (getKey
could be so many things). We could perhaps do the same withVERSION_LEAF_KEY
=>VERKLE_VERSION_LEAF_KEY
100% agree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! as noted on the call, we will leave the verkle namespacing updates to a future call in order not to interfere with pending verkle work
This PR works towards reducing the EVM bundle size by reducing the Verkle coupling.
The one direct casting to
StatelessVerkleStateManager
is removed by using theStateManager
interface here by adding the Verkle methods as optional methods there. I would generally like to expand on this since it reduces the direct coupling to the SVSM class.Additionally an interface
AccessWitness
is added (also toCommon
), which we can use instead of the direct import.And, third measure: constants and methods not depending on Verkle cryptography have been moved to a dedicated
verkle
module inUtil
. This should make sense as well and was necessary in the EVM case, since it allowed to remove the@ethereumjs/verkle
dependency completely.I would think the above measures should "do the job". I could not yet prove it though. When running the
esbuild
command from #3446 (comment) build size stayed unexpectedly on the 2.6 MB level (for EVM).Some googling brought up that
esbuild
just seems to not properly tree shake on unused imports from external modules, see e.g. evanw/esbuild#1794. 🤔I discovered the
--analyze=verbose
flag along (full command:npm run build && esbuild --bundle 10EVM.mjs --outfile=out1.mjs --analyze=verbose
) - generally useful - which helps to see where things are still drawn in:So this is for the
@ethereumjs/verkle
dependency, which should not be there anymore, and which brought me to googling for theesbuild
issue.I then started thinking about using another bundler (so: if
esbuild
might generally not deliver valid tree shaking results) tryingrollup
with the following:This gives a bunch of other warning and (at least) one error (where things break).
Not fully sure if it's worth to resume on that path (or try e.g. another bundler).
Maybe our tree shaking & bundling expert @roninjin10 can have a comment! 🙂
rollup --format=cjs --file=out1.mjs --plugin=node-resolve -- 10EVM.mjs