-
Notifications
You must be signed in to change notification settings - Fork 43
This library is too restrictive for testing networks #54
Comments
Definitely makes sense - also to directly integrate here into the My first thinking was: does this really help that the library throws when e.g. instantiating with a non-defined chainId or name and my first intuition was: why not instantiate with some default settings (e.g. just take the On a second thought I got more doubts and think this does diminish the library security, e.g. if someone has a typo in Third thought, just as a suggestion for discussion: another option
Does this make sense? Another idea? Did I forget anything? |
Side note: there is actually the possibility to just pass a completely custom configuration json file right now (see README section), seems to be not a practicable solution to this problem though since this is too costly for most use cases in this context. |
@alcuadrado Think we should tackle this relatively quickly, this is likely a serious limitation for using projects, now especially on the tx library. Do you have any thoughts on my comments? One thing also to consider: this atm also completely disallows chains which are not yet defined within the library. This is another strong reason for tackling this. From the other side we can ease the problem by adding at least basic configs for missing chains. Is there anywhere some up-to-date list with used chain ids? |
Yep, this is a very inconvenient change there. On 2.0 the tx lib is effectively unusable with test chains. This is an extremely serious regression and actively impedes dev flows. As for your original issue: Why not simply use a well-known record of chains? For example, one could use |
Dropping this here for reference: https://github.com/ethereum-lists/chains Maybe we start conservatively with adding. 😛 |
@alcuadrado after digging into the code a bit, I would cautiously support a new Seems to be the most flexible solution for me. What do you think? Side note: was alternatively thinking of just name |
I think I came up with a better solution. We can create a new static method that makes using the current constructor easier. I'm not convinced about its name, but it would work something like this: static createFromStandardChain(
standardChain: string | number,
customChainParams: Partial<Chain>,
hardfork?: string | null,
supportedHardforks?: Array<string>,
): Common {
const standardChainParams = Common.getChainParams(standardChain)
return new Common(
{
...standardChainParams,
...customChainParams,
},
hardfork,
supportedHardforks,
)
} This way customizing just parts of the chain params can be as easy as: const myChainParams = {name: "my-chain", chainId: 1337, networkId: 1337};
const common = Common.createFromStandardChain("mainnet", myChainParamas, "constantinople") I think @Aralun any feedback on these proposals? |
@alcuadrado Looks way better than what I had in mind yes. As an alternative name, I'm thinking about Plus, it solves @holgerd77's point of silently entering wrong configurations as the current constructor behaviour is preserved. Overall looks very good to me =) |
I went ahead and implemented it in #55. I named the factory method |
@alcuadrado yes, that's really an elegant solution and a significantly better pattern than my proposal, great! |
I'm planning to upgrade
ethereumjs-tx
in Buidler, and found that it may not be possible to do that if I want to enableEIP155
.The problem is that testing networks normally use non-standard chain ids (e.g. Ganache). If I want to sign a tx locally, I should do something like:
But this results in this error:
Taking a look at
setChain
I noticed that it's impossible to use a non-standard chain id.The only workaround I see is by extending this class or creating a new one altogether, but it doesn't feel right for users to have to do this.
I'd LOVE to have an option to create a chain with the same params than a standard one, except for the genesis state and the chain id.
The text was updated successfully, but these errors were encountered: