Skip to content

Commit

Permalink
Merge branch 'master' into init-message-data-cost
Browse files Browse the repository at this point in the history
  • Loading branch information
PlasmaPower committed Jun 20, 2023
2 parents cec8928 + 4ce531a commit db7961d
Showing 1 changed file with 7 additions and 27 deletions.
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

0 comments on commit db7961d

Please sign in to comment.