-
Notifications
You must be signed in to change notification settings - Fork 781
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
Remove nodejs import from trie.ts #3280
Conversation
Codecov ReportAttention:
Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more. |
fyi I posted a message in the previous PR: https://github.com/ethereumjs/ethereumjs-monorepo/pull/3231/files#r1487361314 |
@yann300 @scorbajio Ok, I'll put this back in a "WIP" state unless we have that solved. So if the main file (non type) import is also a problem, then we eventually have to roll back the whole feature (?). TBH this completely let's my head explode, that a web standard implementation in Node.js is then breaking web compatibility. 🤯 Is there really no way around that? I wrote at some other occasion when we implemented I guess that normally all browsers would need to do is to just ignore this specific import (since things are just meant to work any in the browser without this Node.js import). Hmm. Hmm. Hmm. |
(I tried but I was personally not able to dig something out by googling on this) |
@yann300 could you provide steps to reproduce the build error so we can look into possible solutions? |
@scorbajio Just an additional note: I am sure this can be solved on the build side, for us this is just not an option, we would cripple our browser compatibility with that. @yann300 maybe wait with going too deep here, we might just do a follow-up release removing the new functionality again. |
I had a look at |
you could clone https://github.com/ethereum/remix-project and EDIT: switch to the branch |
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.
LGTM, thanks for adressing so quickly!
Bye bye web streams API, it was nice with you. 😑
Have added a note to #3216 so that we do not forget about the code base and might be able to re-integrate along next breaking releases.
Will still wait a couple of days to see if more stuff drops in but otherwise we would do a fixing release round. Maybe next Thursday or so.
@holgerd77 @scorbajio thanks for the PR! do you have guys a planned date for getting a release which include this PR? |
@yann300 Hi there, yes, we plan to do releases early next week, want to bundle this with some other stuff (WASM kzg)! |
Just ran into this issue after upgrading ethereumjs libraries in tevm. Thanks for the fix! |
Let me know if you would like me to add a lint rule that checks for this issue |
Thanks for reporting, good to have this confirmed! 🙏 🙂 Releases on this (and some other stuff) are planned for next Tuesday (since relatively urgent). Ah, there is also the KZG -> WASM work in there (that will actually be the main feature, so from #3294), so @acolytec3 has done a WASM port of the @yann300 so guess for you guys this is relevant as well (?) |
Yeah, that might be helpful! We are generally aware of this though, this one was a somewhat special case, mental blocker on my side, I couldn't really imagine that using a WEB streams API would break browser compatibilty. 😂 |
@yann300 @roninjin10 Another quick question, since I "already have you here" 🙂 We are a bit drawn back and forth how to handle KZG in EVM and VM. Basically the thing is: post Cancun, 4844 related functionality becomes an integral part of the EVM/VM with the addition of the new 4844 point evaluation precompile. So that means that the KZG setup is basically necessary for all EVM/VM runs. This means that we now have a somewhat solid amount of boilerplate for EVM/VM initialization: import { createKZG } from 'kzg-wasm'
import { Common, Chain, Hardfork } from '@ethereumjs/common'
import { EVM } from '@ethereumjs/evm'
import { initKZG } from '@ethereumjs/util'
const main = async () => {
const kzg = await createKZG()
initKZG(kzg)
const common = new Common({
chain: Chain.Mainnet,
hardfork: Hardfork.Cancun,
customCrypto: { kzg: kzg },
})
const evm = new EVM({ common })
} We could (likely) avoid this by bundling the For higher level libraries like EVM/VM we are not so sure. What are you guys personal opinions (respectively team based policies) on that? Do you have some problem with bundled in WASM? As a side note it might be worth to mention that the WASM file we have here is somewhat large (~500KB). So this also has the effect that this definitely adds additional boilerplate to the EVM bundle. This is a general problem though, also if the manual self-installation option is used. Some feedback would be valuable! 🙏 |
Side note: we might be lucky and get some JS KZG library written in the next 1-3 months, so this might be generally a temporary situation with the boilerplate code (and this might be an argument to for now skip the deep WASM integration). |
Really? Even EVM runs that don't do any blob related things need it? Why is that? Wasm bundle size
Oh wow this is highly problematic. I'm definitely gonna need to have to find a workaround for dealing with that. What makes it so big and is there any potential to make it smaller? Definitely would prefer not bundling it in on this bundle size thing alone as it would hurt my ability to work around the large bundle hit Initialization code const kzg = await createKZG()
initKZG(kzg)
const common = new Common({
chain: Chain.Mainnet,
hardfork: Hardfork.Cancun,
customCrypto: { kzg: kzg },
})
const evm = new EVM({ common }) I think it's fine. From end user of tevm point of view all this gets abstracted into a From my point of view maintaining tevm, I actually currently am following a convention of always explicitly passing in every single parameter into VM, EVM, Blockchain, etc. E.g. below is how I initialize a VM. It's already pretty verbose intentionally const stateManager = createTevmStateManager(getStateManagerOpts())
const common = new TevmCommon({
chain: 1,
hardfork: options.hardfork ?? 'shanghai',
eips: /**@type number[]*/ (options.eips ?? [1559, 4895]),
})
const blockchain = await createBlockchain({ common })
const evm = createEvm({
common,
stateManager,
blockchain,
allowUnlimitedContractSize: options.allowUnlimitedContractSize ?? false,
customPrecompiles: options.customPrecompiles ?? [],
profiler: options.profiler ?? false,
})
const vm = await createVm({
stateManager,
evm,
blockchain,
common,
}) |
You should be able to run the EVM just fine, but if you haven't instantiated a KZG instance and try to execute the point evaluation precompile, you'll get an error about In terms of the size, I think it mainly comes down to the size of the trusted setup. I'm not an expert on compiling C to WASM, but I turned on all the optimizations that |
This is very nice. This means implementing some kind of lazy loading might be an option. Putting the KZG implementation on a backend server instead of browser bundle might also be an option. Will dig into it more next week.
This makes sense. I was lowkey hoping the wasm was compiled from golang in which case there would be a lot of room for improvement. Looking at the kzg-wasm code I'm happy to see it's initialized asyncronously. I opened this issue in the rustbn repo that is causing issues from awaiting in the top level of the module. |
Looks like the kzg committment file alone is about 437kb so definitely not much headroom to make it better https://github.com/ethereum/go-ethereum/blob/00905f7dc406cfb67f64cd74113777044fb886d8/crypto/kzg4844/trusted_setup.json |
With 7zip I was able to compress the 437kb file down to 210kb 7z a -mx=9 compressed-file.7z kzg.json
7-Zip [64] 17.05 : Copyright (c) 1999-2021 Igor Pavlov : 2017-08-28
p7zip Version 17.05 (locale=utf8,Utf16=on,HugeFiles=on,64 bits,10 CPUs LE)
Scanning the drive:
1 file, 447355 bytes (437 KiB)
Creating archive: compressed-file.7z
Items to compress: 1
Files read from disk: 1
Archive size: 214362 bytes (210 KiB)
Everything is Ok |
btw @acolytec3 @holgerd77 is there a telegram chat or a similar channel for Ethereumjs chat? Feel free to dm me if there is but you prefer to keep it private: https://twitter.com/FUCORY?ref_src=twsrc%5Egoogle%7Ctwcamp%5Eserp%7Ctwgr%5Eauthor |
You're welcome to jump on our discord for more real-time discussion - https://discord.gg/JCsNTaVw |
Ok, so we have settled to not bundle WASM KZG in as a direct dependency. |
This change fixes an import error that is coming up in webpack browser builds resulting from a nodejs-specific import being made in the trie package as a result of the readable-stream refactor done in #3231. See #3231 (comment).