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

fix: remove ineffective witness assignment #463

Open
wants to merge 1 commit into
base: kaustinen-with-shapella
Choose a base branch
from

Conversation

gballet
Copy link
Owner

@gballet gballet commented Jul 19, 2024

I noticed that there was an ineffectual witness creation, as well as a misplaced check for the existence of the witness, I am removing them for cleanup - they clash with some changes introduced by FILL_COST

@gballet gballet requested a review from jsign July 19, 2024 11:15
Comment on lines -140 to -142
if txCtx.Accesses == nil && chainConfig.IsPrague(blockCtx.BlockNumber, blockCtx.Time) {
evm.Accesses = evm.StateDB.(*state.StateDB).NewAccessWitness()
}
Copy link
Owner Author

Choose a reason for hiding this comment

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

this stuff is recreated in applyTransaction and isn't needed before, so this is a redundant creation.

Copy link
Collaborator

@jsign jsign Jul 22, 2024

Choose a reason for hiding this comment

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

I've checked all references to NewEVM and there're many places that call this method that aren't applyTransaction.

I feel it would be much safer to maybe move that initialization inside NewEVMTxContext(...)? I'm not sure why it makes sense to initialize one of its attributes outside the ctor creating these kind of situations.

Also noted that that referenced line doesn't do the chainConfig.IsPrague(blockCtx.BlockNumber, blockCtx.Time) style check that we did here. I guess that's just creating a little extra garbage for block ranges that the witness doesn't apply, but just mentioning.

If we're always fine with doing it ignoring the right fork (as done today in applyTransaction), then moving it to NewEVMTxContext is possible since that method doesn't have block num.

Copy link
Collaborator

@jsign jsign left a comment

Choose a reason for hiding this comment

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

LGMT, but left some comments if we can simplify further.

s.witness = s.NewAccessWitness()
panic("witness wasn't initialized")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I had the feeling this removed logic was intentionally trying to lazily initialize in some cases.

Thing is that if we remove this, we could panic "for a while" but eventually this method will have to change to returning *AccessWitnes, error. (Or avoid the if check?)

Copy link
Owner Author

Choose a reason for hiding this comment

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

yes the if check should not be necessary, I am just setting the panic to catch a rebase issue. I'll add a TODO here.

Comment on lines -140 to -142
if txCtx.Accesses == nil && chainConfig.IsPrague(blockCtx.BlockNumber, blockCtx.Time) {
evm.Accesses = evm.StateDB.(*state.StateDB).NewAccessWitness()
}
Copy link
Collaborator

@jsign jsign Jul 22, 2024

Choose a reason for hiding this comment

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

I've checked all references to NewEVM and there're many places that call this method that aren't applyTransaction.

I feel it would be much safer to maybe move that initialization inside NewEVMTxContext(...)? I'm not sure why it makes sense to initialize one of its attributes outside the ctor creating these kind of situations.

Also noted that that referenced line doesn't do the chainConfig.IsPrague(blockCtx.BlockNumber, blockCtx.Time) style check that we did here. I guess that's just creating a little extra garbage for block ranges that the witness doesn't apply, but just mentioning.

If we're always fine with doing it ignoring the right fork (as done today in applyTransaction), then moving it to NewEVMTxContext is possible since that method doesn't have block num.

@@ -192,7 +192,7 @@ func (s *StateDB) NewAccessWitness() *AccessWitness {

func (s *StateDB) Witness() *AccessWitness {
if s.witness == nil {
s.witness = s.NewAccessWitness()
panic("witness wasn't initialized")
Copy link
Owner Author

Choose a reason for hiding this comment

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

Suggested change
panic("witness wasn't initialized")
// TODO this is meant to catch rebase errors, replace with error return when stabilized
panic("witness wasn't initialized")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants