Closed holgerd77 closed 2 years ago
@gabrocheleau π
(hehe, just "live-viewed" your assignment π)
Note that in the VM the current EEI export (accessed by the Beta 1 releases) is also not working properly, I had to use to following weird code adoption from the current EVM README example to get things working:
import Common, { Chain, Hardfork } from '@ethereumjs/common'
import Blockchain from '@ethereumjs/blockchain'
import { EEI } from '@ethereumjs/vm'
import EVM from '@ethereumjs/evm'
import { DefaultStateManager } from '@ethereumjs/statemanager'
// Note: in a future release there will be an EEI default implementation
// which will ease standalone initialization
const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.London })
const blockchain = await Blockchain.create({ common })
const stateManager = new DefaultStateManager({ common })
const eei = new EEI.default(stateManager, common, blockchain)
const evm = new EVM({
common,
blockchain,
eei,
})
This should be checked if this can be moved "back to normal" once default export has been removed (this current *
based export * as EEI from './eei/eei'
in VM seems generally unnecessary and error prone to me for single-class/item-exports (e.g. here: just EEI
and nothing else), think a direct reference without using *
should in these cases generally be preferred).
We have decided to remove selected (the most prominent ones) default exports from our libraries, since we are not yet doing an ESM build of our libraries along the v6 breaking release switch and at the same time Node.js/JavaScript/CommonJS users have issues with default exports and we have old issues like https://github.com/ethereumjs/ethereumjs-monorepo/issues/978 where people were complaining about the topic.
Affected imports will then change like this:
becomes:
I guess the Common export is already the most prevalent one and the one with the most complaints. π
While a search on
export default
in the monorepo packages gives ~50 entries most of these are from tests, not exposed on the API level, rarely used functionality, so we do not need to update the majority of this but rather a very selected set with some level of flexibility.Here is a list of exports I think we should likely update.
For sure (attention: opinionated, feel free to comment if you thing something doesn't make sense)
common/src/index.tds
:Common
(as default)client/lib/client.ts
:EthereumClient
(doesn't hurt I guess and might make an eventual future programatic usage easier)ethash/src/index.ts
:Ethash
rlp/src/index.ts
:RLP
EVM
src (particularly the EVM, attention, two locations! (reexport inindex.ts
))pc1
,...pca
(but if preferred we can also just use more verbose longer names, e.g. going along with the file names)Cache
,Blockchain
(as default inindex.ts
)Cache
andDefaultStateManager
src
(all tx implementations + Tx Factory)EEI
,VM
(as default inindex.ts
)Would be nice:
block/src/from-rpc.ts
:blockFromRpc()
block/src/header-from-rpc.ts
:headerFromRpc()
(actually maybe unify both methods in a singlerpc.ts
file and re-export both methods fromindex.ts
)(ok, would very much make sense to take just these two would-be-nice candidates in as well π)