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

Only update ArbOS version after recreating header after internal tx #1712

Merged
merged 1 commit into from
Jun 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 7 additions & 27 deletions arbos/block_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (info *L1Info) L1BlockNumber() uint64 {
return info.l1BlockNumber
}

func createNewHeader(prevHeader *types.Header, l1info *L1Info, state *arbosState.ArbosState, chainConfig *params.ChainConfig, updateHeaderWithInfo bool) *types.Header {
func createNewHeader(prevHeader *types.Header, l1info *L1Info, state *arbosState.ArbosState, chainConfig *params.ChainConfig) *types.Header {
l2Pricing := state.L2PricingState()
baseFee, err := l2Pricing.BaseFeeWei()
state.Restrict(err)
Expand Down Expand Up @@ -96,30 +96,6 @@ func createNewHeader(prevHeader *types.Header, l1info *L1Info, state *arbosState
Nonce: [8]byte{}, // Filled in later; post-merge Ethereum will require this to be zero
BaseFee: baseFee,
}

if updateHeaderWithInfo {
var sendRoot common.Hash
var sendCount uint64
var nextL1BlockNumber uint64
var arbosVersion uint64

if blockNumber.Uint64() == chainConfig.ArbitrumChainParams.GenesisBlockNum {
arbosVersion = chainConfig.ArbitrumChainParams.InitialArbOSVersion
} else {
acc := state.SendMerkleAccumulator()
sendRoot, _ = acc.Root()
sendCount, _ = acc.Size()
nextL1BlockNumber, _ = state.Blockhashes().L1BlockNumber()
arbosVersion = state.ArbOSVersion()
}
arbitrumHeader := types.HeaderInfo{
SendRoot: sendRoot,
SendCount: sendCount,
L1BlockNumber: nextL1BlockNumber,
ArbOSFormatVersion: arbosVersion,
}
arbitrumHeader.UpdateHeaderWithInfo(header)
}
return header
}

Expand Down Expand Up @@ -213,7 +189,7 @@ func ProduceBlockAdvanced(
l1Timestamp: l1Header.Timestamp,
}

header := createNewHeader(lastBlockHeader, l1Info, state, chainConfig, false)
header := createNewHeader(lastBlockHeader, l1Info, state, chainConfig)
signer := types.MakeSigner(chainConfig, header.Number)
// Note: blockGasLeft will diverge from the actual gas left during execution in the event of invalid txs,
// but it's only used as block-local representation limiting the amount of work done in a block.
Expand Down Expand Up @@ -349,11 +325,15 @@ func ProduceBlockAdvanced(
})()

if tx.Type() == types.ArbitrumInternalTxType {
// ArbOS might have upgraded to a new version, so we need to refresh our state
state, err = arbosState.OpenSystemArbosState(statedb, nil, true)
if err != nil {
return nil, nil, err
}
header = createNewHeader(lastBlockHeader, l1Info, state, chainConfig, true)
// Update the ArbOS version in the header (if it changed)
extraInfo := types.DeserializeHeaderExtraInformation(header)
extraInfo.ArbOSFormatVersion = state.ArbOSVersion()
extraInfo.UpdateHeaderWithInfo(header)
}

// append the err, even if it is nil
Expand Down