Skip to content
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

vm: remove isTruthy and isFalsy #2248

Merged
merged 2 commits into from
Aug 30, 2022
Merged

Conversation

gabrocheleau
Copy link
Contributor

@gabrocheleau gabrocheleau commented Aug 30, 2022

Extracts the vm package changes from #2233

@codecov
Copy link

codecov bot commented Aug 30, 2022

Codecov Report

Merging #2248 (5e51a02) into master (52d5961) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

Flag Coverage Δ
block 92.77% <ø> (ø)
blockchain 88.39% <ø> (ø)
client 87.05% <ø> (ø)
common 98.09% <ø> (ø)
devp2p 92.33% <ø> (+0.08%) ⬆️
ethash ∅ <ø> (∅)
evm 79.11% <ø> (ø)
rlp ∅ <ø> (?)
statemanager 88.16% <ø> (ø)
trie 89.43% <ø> (ø)
tx 97.98% <ø> (ø)
util 92.33% <ø> (ø)
vm 85.31% <100.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@@ -53,8 +45,8 @@ export async function runBlock(this: VM, opts: RunBlockOpts): Promise<RunBlockRe

if (
this._hardforkByBlockNumber ||
isTruthy(this._hardforkByTTD) ||
isTruthy(opts.hardforkByTTD)
this._hardforkByTTD !== undefined ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In vm.ts this field is marked as optional, but it looks to me that it is always being set? I think we can improve here by making that field non-optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried making this.hardforkByTTD non-optional (which ends up removing that if altogether) but ended up with a couple failing API tests. I've created an issue for it in case we want to investigate that further (#2260)

Copy link
Member

@holgerd77 holgerd77 Aug 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No no, just to add here: there are a lot of development use cases where this is not wanted (that HFs align with the block numbers in regard to a certain chain configuration). So these hardforkBy* options should always be present and available to set.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type of hardforkByTTD is undefined | bigint, and with optional I meant that it should be of type bigint (so it should never be undefined), but this ruins the logic of setting the hardforks (I realized this when checking #2260). I'm not sure what you mean "should always be available to set", if you want to set the hardforkByBlockNumber from false to true or vice-versa you have to either hack it in, or you have to create a new VM since it is readonly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plainly meant this should remain an option (in the case this would be in question). 🙂

Copy link
Member

@jochem-brouwer jochem-brouwer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One possible minor improvement

Copy link
Contributor

@acolytec3 acolytec3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gabrocheleau gabrocheleau merged commit 15790b3 into master Aug 30, 2022
@gabrocheleau gabrocheleau deleted the vm/remove-isTruthy-isFalsy-2 branch August 31, 2022 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants