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

[R4R] fix: add ProxyOwnerUpgradeTime to mantle upgrade config #88

Merged
merged 2 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *trie.Database, gen
config.BVMETHMintUpgradeTime = mantleUpgradeChainConfig.BVMETHMintUpgradeTime
config.MetaTxV2UpgradeTime = mantleUpgradeChainConfig.MetaTxV2UpgradeTime
config.MetaTxV3UpgradeTime = mantleUpgradeChainConfig.MetaTxV3UpgradeTime
config.ProxyOwnerUpgradeTime = mantleUpgradeChainConfig.ProxyOwnerUpgradeTime
}

if overrides != nil && overrides.OverrideShanghai != nil {
Expand Down
23 changes: 23 additions & 0 deletions core/mantle_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package core
import (
"math/big"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/params"
)

Expand All @@ -13,50 +14,72 @@ var (
BVMETHMintUpgradeTime: u64Ptr(0),
MetaTxV2UpgradeTime: u64Ptr(0),
MetaTxV3UpgradeTime: nil, //TODO set upgrade timestamp
ProxyOwnerUpgradeTime: nil, //TODO set upgrade timestamp
}
MantleSepoliaUpgradeConfig = MantleUpgradeChainConfig{
ChainID: params.MantleSepoliaChainId,
BaseFeeTime: u64Ptr(1_704_891_600),
BVMETHMintUpgradeTime: u64Ptr(1_720_594_800),
MetaTxV2UpgradeTime: u64Ptr(1_720_594_800),
MetaTxV3UpgradeTime: u64Ptr(1_720_594_800),
ProxyOwnerUpgradeTime: u64Ptr(0),
PinelliaC marked this conversation as resolved.
Show resolved Hide resolved
}
MantleSepoliaQA3UpgradeConfig = MantleUpgradeChainConfig{
ChainID: params.MantleSepoliaQA3ChainId,
BaseFeeTime: u64Ptr(0),
BVMETHMintUpgradeTime: u64Ptr(0),
MetaTxV2UpgradeTime: u64Ptr(0),
MetaTxV3UpgradeTime: u64Ptr(1_717_689_600),
ProxyOwnerUpgradeTime: u64Ptr(0),
}
MantleSepoliaQA9UpgradeConfig = MantleUpgradeChainConfig{
ChainID: params.MantleSepoliaQA9ChainId,
BaseFeeTime: u64Ptr(0),
BVMETHMintUpgradeTime: u64Ptr(0),
MetaTxV2UpgradeTime: u64Ptr(0),
MetaTxV3UpgradeTime: u64Ptr(1_716_962_400),
ProxyOwnerUpgradeTime: u64Ptr(0),
}
MantleLocalUpgradeConfig = MantleUpgradeChainConfig{
ChainID: params.MantleLocalChainId,
BaseFeeTime: u64Ptr(0),
BVMETHMintUpgradeTime: u64Ptr(0),
MetaTxV2UpgradeTime: u64Ptr(0),
MetaTxV3UpgradeTime: u64Ptr(0),
ProxyOwnerUpgradeTime: u64Ptr(0),
}
MantleDefaultUpgradeConfig = MantleUpgradeChainConfig{
BaseFeeTime: u64Ptr(0),
BVMETHMintUpgradeTime: u64Ptr(0),
MetaTxV2UpgradeTime: u64Ptr(0),
MetaTxV3UpgradeTime: nil,
ProxyOwnerUpgradeTime: nil,
}
)

// L2ProxyAdmin contract upgrade constants
var (
// L2ProxyAdminAddress is the address of the L2ProxyAdmin contract
// predeploy
L2ProxyAdminAddress = common.HexToAddress("0x4200000000000000000000000000000000000018")

// OwnerSlot refers to the storage slot in the L2ProxyAdmin contract that
// holds the owner of the contract
OwnerSlot = common.BigToHash(big.NewInt(0))

// NewProxyAdminOwnerAddress is the address that the L2ProxyAdmin contract
// will be transferred to
NewProxyAdminOwnerAddress = common.HexToHash("0x09734bB3980906Bb217305EA6Bd34256feEAB105")
)

PinelliaC marked this conversation as resolved.
Show resolved Hide resolved
type MantleUpgradeChainConfig struct {
ChainID *big.Int `json:"chainId"` // chainId identifies the current chain and is used for replay protection

BaseFeeTime *uint64 `json:"baseFeeTime"` // Mantle BaseFee switch time (nil = no fork, 0 = already on mantle baseFee)
BVMETHMintUpgradeTime *uint64 `json:"bvmETHMintUpgradeTime"` // BVM_ETH mint upgrade switch time (nil = no fork, 0 = already on)
MetaTxV2UpgradeTime *uint64 `json:"metaTxV2UpgradeTime"` // MetaTxV1UpgradeBlock identifies the current block height is using metaTx with MetaTxSignDataV2
MetaTxV3UpgradeTime *uint64 `json:"metaTxV3UpgradeTime"` // MetaTxV3UpgradeBlock identifies the current block height is ensuring sponsor and sender are not the same
ProxyOwnerUpgradeTime *uint64 `json:"proxyOwnerUpgradeTime"` // ProxyOwnerUpgradeBlock identifies the current block time is ensuring the L2ProxyAdmin contract owner is set to NewProxyAdminOwnerAddress
}

func GetUpgradeConfigForMantle(chainID *big.Int) *MantleUpgradeChainConfig {
Expand Down
5 changes: 5 additions & 0 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,11 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
snap := st.state.Snapshot()
// Will be reverted if failed

// Check if the owner of the L2ProxyAdmin contract needs to be upgraded
if st.evm.ChainConfig().IsProxyOwnerUpgrade(&st.evm.Context.Time) {
PinelliaC marked this conversation as resolved.
Show resolved Hide resolved
st.evm.StateDB.SetState(L2ProxyAdminAddress, OwnerSlot, NewProxyAdminOwnerAddress)
}

result, err := st.innerTransitionDb()
// Failed deposits must still be included. Unless we cannot produce the block at all due to the gas limit.
// On deposit failure, we rewind any state changes from after the minting, and increment the nonce.
Expand Down
8 changes: 8 additions & 0 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,9 @@ type ChainConfig struct {
MetaTxV2UpgradeTime *uint64 `json:"metaTxV2UpgradeTime,omitempty"` // MetaTxV2UpgradeTime switch time ( nil = no fork, 0 = already forked)
MetaTxV3UpgradeTime *uint64 `json:"metaTxV3UpgradeTime,omitempty"` // MetaTxV3UpgradeTime switch time ( nil = no fork, 0 = already forked)

// ProxyOwner upgrade config
ProxyOwnerUpgradeTime *uint64 `json:"proxyOwnerUpgradeTime,omitempty"` // ProxyOwnerUpgradeTime switch time ( nil = no fork, 0 = already forked)

// Fork scheduling was switched from blocks to timestamps here

ShanghaiTime *uint64 `json:"shanghaiTime,omitempty"` // Shanghai switch time (nil = no fork, 0 = already on shanghai)
Expand Down Expand Up @@ -699,6 +702,11 @@ func (c *ChainConfig) IsMetaTxV3(time uint64) bool {
return isTimestampForked(c.MetaTxV3UpgradeTime, time)
}

// IsProxyOwnerUpgrade returns whether time is either equal to the ProxyOwnerUpgrade fork time
func (c *ChainConfig) IsProxyOwnerUpgrade(time *uint64) bool {
return configTimestampEqual(c.ProxyOwnerUpgradeTime, time)
}

// IsArrowGlacier returns whether num is either equal to the Arrow Glacier (EIP-4345) fork block or greater.
func (c *ChainConfig) IsArrowGlacier(num *big.Int) bool {
return isBlockForked(c.ArrowGlacierBlock, num)
Expand Down