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 panic issue when ExcessDataGas is nil #37

Merged
merged 1 commit into from
Oct 14, 2022

Conversation

roberto-bayardo
Copy link
Collaborator

@roberto-bayardo roberto-bayardo commented Oct 13, 2022

This issue may arise when the current block is a Sharding-enabled block but the parent is not.

if st.evm.ChainConfig().IsSharding(st.evm.Context.BlockNumber) {
if st.evm.Context.ExcessDataGas == nil {
// this edge-case will happen when the parent block is pre EIP-4844
st.evm.Context.ExcessDataGas = new(big.Int)
Copy link
Collaborator

Choose a reason for hiding this comment

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

seems awkward to update the State Context inside buyGas. Could we move this initialization elsewhere, perhaps when the context is created?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I considered making it always non-nil in NewEVMBlockContext but wasn't sure if I should make the MaxFeePerDataGas field be handled differently than BaseFee, which is left as nil when unspecified. I can't really think of any reasons why checking for nil ExcessDataGas would be important/informative though so perhaps that is the best place for it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated to always set to non-nil in NewEVMBlockContext.

@roberto-bayardo roberto-bayardo force-pushed the excess-data-gas-fix branch 2 times, most recently from 2dfedc8 to a0a36aa Compare October 14, 2022 14:52
core/evm.go Outdated
@@ -44,7 +44,7 @@ func NewEVMBlockContext(header *types.Header, excessDataGas *big.Int, chain Chai
beneficiary common.Address
baseFee *big.Int
random *common.Hash
edg *big.Int
edg *big.Int = new(big.Int)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's add a comment here explaining the edge case we're covering.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done!

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