-
Notifications
You must be signed in to change notification settings - Fork 49
chore: remove homestead + update eth dependencies #69
chore: remove homestead + update eth dependencies #69
Conversation
Fixing homestead bug where homestead rules are used on blocks before the fork.
Removing semi-colon
I personally like this more than #68, thanks! I'd however wait until ethereumjs/ethereumjs-tx#130 makes it into the next release, and then merge here with the latest ethereumjs-tx. |
Okay, let me know if there's anything else I can do :) |
@micahriggan Sorry that this takes so long, we'll do a tx release soon. |
@micahriggan thanks for submitting this PR! We already released a new |
@alcuadrado updated to 2.1.0 |
…chore/update-eth-dependencies
…chore/update-eth-dependencies
…n/ethereumjs-block into chore/update-eth-dependencies
@alcuadrado Can you go on with a review here? |
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 @micahriggan!
index.js
Outdated
for (i = 0; i < rawTransactions.length; i++) { | ||
var tx = new Tx(rawTransactions[i]) | ||
tx._homestead = true | ||
var tx = new Tx(rawTransactions[i], opts) |
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.
I think this is too dangerous to just pass on the opts
dictionary since this can have unwanted side effects, e.g. if an options key is named the same on the two libraries (along future changes e.g.). Can you directly pass the instantiated Common
object, so { common: this._common}
?
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.
Oops, I missed this. It's a very good point
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.
I did that initially in this commit, but ran into issues with the tests.
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.
Ok, we have to figure this out.
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.
If you know the solution to
Error: Method called with neither a hardfork set nor provided by param at Common._chooseHardfork (/Users/micah/dev/ethereumjs-block/node_modules/ethereumjs-common/dist/index.js:114:23)
Then I can switch to using that.
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.
I figured this out. The problem is that if no Common
object is provided, a new one is created without a hardfork
param, and this results in an error.
In order to fix this, the else branch of the if
that sets this._common
should be something like:
let chain = opts.chain ? opts.chain : 'mainnet'
const tmpCommon = new Common(chain)
const blockNumber = 123 // TODO: How do we get the block number here?
let hardfork = opts.hardfork ? opts.hardfork : tmpCommon.activeHardfork(blockNumber)
this._common = new Common(chain, hardfork)
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 reminds me of my initial fix, https://github.com/ethereumjs/ethereumjs-block/pull/68/files
Seems like we'll need the common hardfork to be set after this.header
85c8a59
to
ec4fe7f
Compare
So I tried with this using the last hardfork, and that doesn't fix the original issue, so it will need to be based off of the height. Edit: Should be good now |
ec4fe7f
to
15228fc
Compare
This should work :) Thanks a lot @micahriggan ! Can you re-review it @holgerd77 ? Something I noticed is that in the current code the |
@@ -65,15 +65,16 @@ var Block = module.exports = function (data, opts) { | |||
rawUncleHeaders = data.uncleHeaders || [] | |||
} | |||
|
|||
const height = new BN(this.header.number).toNumber() | |||
const hardfork = this._common.activeHardfork(height) | |||
this._common.setHardfork(hardfork) |
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.
Hmm, this can't be the solution yet, now we have got inconsistent hardfork setting logic in block and header which can eventually end up in differing common objects.
Not sure, maybe we need to pass options to header
explicitly and use the eventually altered _common
object directly or something. Or a unified util
function used both by block
and header
- eventually from a separate util.js
file or something getting for the logic of creating or taking the common object, so that this is unified?
Just some ideas, but we have to make sure that on 100% both end up with the same Common
state.
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.
I see what you mean. I'll mess around with it and see if I can get them to be synchronized
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.
I tried making the BlockHeader's common object set the fork, then making block just inherit the common object from the header, but 15k tests fail if you do that. I don't really know enough to understand why.
9e7e9f8
to
e7aaf77
Compare
I kept working on this as part of the TS migration, and I found many edge-cases mostly due to Things like, what happens if you initialize a block with transactions on petersburg, and then change the block number to one pre-eip155? Also, can you really share the common between a block an its uncles? they may belong to a different HF. I tried updating the TBH, I'm a little lost about what to do. |
I also tried overwriting the |
@alcuadrado seems like this intended update (of @micahriggan I am just seeing that the commit history of this work is getting too extensive/intransparent anyhow to be directly merged and would need squashing and reorganizing. @alcuadrado @micahriggan Would it generally be a way that we extract the @alcuadrado while working on this you can eventually already open separate issues on refactoring ideas/necessities and we tackle these separately afterwards working towards a more consistent solution which doesn't feel "hacky"? Does this make sense? I have the impression we are trying to solve too many things at once otherwise eventually. |
Yes, absolutely. Unfortunately, I believe that this is not only affecting this library, but it's a general issue shared by all the libraries. My understanding is that it comes from:
We have been discussing this with @s1na for some time in other issues.
I'm not convinced that this is worth it or even a positive thing. It will fix some edge-cases, but opening the door to/ignoring others. I think the current state of the proposal keeps the previous behavior, which in most cases work. I'm not 100% sure about this, as it's a pretty complex situation.
I'll take some time to recollect what was previously discussed, and open an issue in the organization repo. |
This change was incorporated in #72 Thanks for this PR @micahriggan ! |
closes #68
closes #67