Skip to content

Commit

Permalink
feature: add haber fork config in deployment script (#202)
Browse files Browse the repository at this point in the history
Co-authored-by: Owen <[email protected]>
  • Loading branch information
redhdx and owen-reorg authored May 30, 2024
1 parent 7b9db84 commit 3f74a4b
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 12 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ require (
rsc.io/tmplfunc v0.0.3 // indirect
)

replace github.com/ethereum/go-ethereum v1.13.8 => github.com/bnb-chain/op-geth v0.4.1-0.20240514082730-f8d1c9e18803
replace github.com/ethereum/go-ethereum v1.13.8 => github.com/bnb-chain/op-geth v0.4.1

replace github.com/cometbft/cometbft => github.com/bnb-chain/greenfield-cometbft v1.0.0

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ github.com/bits-and-blooms/bitset v1.10.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6
github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c=
github.com/bnb-chain/greenfield-cometbft v1.0.0 h1:0r6hOJWD/+es0gxP/exKuN/krgXAr3LCn5/XlcgDWr8=
github.com/bnb-chain/greenfield-cometbft v1.0.0/go.mod h1:f35mk/r5ab6yvzlqEWZt68LfUje68sYgMpVlt2CUYMk=
github.com/bnb-chain/op-geth v0.4.1-0.20240514082730-f8d1c9e18803 h1:DBJAzHTOzLoRQ04tr22dHjSLW/QclnGsOzp1wo6WoBs=
github.com/bnb-chain/op-geth v0.4.1-0.20240514082730-f8d1c9e18803/go.mod h1:dkpInaOz3WeP/5lgdL0BOA6mjexUj30tPQU81H1yEHQ=
github.com/bnb-chain/op-geth v0.4.1 h1:rnVDtFWHhg0RBSndIBeh6M9cNOPzbW8XfshWY6jWIUQ=
github.com/bnb-chain/op-geth v0.4.1/go.mod h1:dkpInaOz3WeP/5lgdL0BOA6mjexUj30tPQU81H1yEHQ=
github.com/boltdb/bolt v1.3.1 h1:JQmyP4ZBrce+ZQu0dY660FMfatumYDLun9hBCUVIkF4=
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g=
Expand Down
14 changes: 14 additions & 0 deletions op-chain-ops/genesis/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ type DeployConfig struct {
// SnowTimeOffset is the number of seconds after genesis block that snow hard fork activates.
// Set it to 0 to activate at genesis. Nil to disable snow fork.
SnowTimeOffset *hexutil.Uint64 `json:"snowTimeOffset,omitempty"`
// HaberTimeOffset is the number of seconds after genesis block that haber hard fork activates.
// Set it to 0 to activate at genesis. Nil to disable haber fork.
HaberTimeOffset *hexutil.Uint64 `json:"haberTimeOffset,omitempty"`
// RequiredProtocolVersion indicates the protocol version that
// nodes are required to adopt, to stay in sync with the network.
RequiredProtocolVersion params.ProtocolVersion `json:"requiredProtocolVersion"`
Expand Down Expand Up @@ -567,6 +570,17 @@ func (d *DeployConfig) SnowTime(genesisTime uint64) *uint64 {
return &v
}

func (d *DeployConfig) HaberTime(genesisTime uint64) *uint64 {
if d.HaberTimeOffset == nil {
return nil
}
v := uint64(0)
if offset := *d.HaberTimeOffset; offset > 0 {
v = genesisTime + uint64(offset)
}
return &v
}

// RollupConfig converts a DeployConfig to a rollup.Config
func (d *DeployConfig) RollupConfig(l1StartBlock *types.Block, l2GenesisBlockHash common.Hash, l2GenesisBlockNumber uint64) (*rollup.Config, error) {
if d.OptimismPortalProxy == (common.Address{}) {
Expand Down
1 change: 1 addition & 0 deletions op-chain-ops/genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func NewL2Genesis(config *DeployConfig, block *types.Block) (*core.Genesis, erro
EcotoneTime: config.EcotoneTime(block.Time()),
InteropTime: config.InteropTime(block.Time()),
Fermat: config.Fermat,
HaberTime: config.HaberTime(block.Time()),
Optimism: &params.OptimismConfig{
EIP1559Denominator: eip1559Denom,
EIP1559Elasticity: eip1559Elasticity,
Expand Down
5 changes: 2 additions & 3 deletions op-node/withdrawals/proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient/gethclient"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie"
)
Expand Down Expand Up @@ -59,7 +58,7 @@ func VerifyAccountProof(root common.Hash, address common.Address, account types.
}
}

func VerifyStorageProof(root common.Hash, proof gethclient.StorageResult) error {
func VerifyStorageProof(root common.Hash, proof common.StorageResult) error {
secureKey := crypto.Keccak256(common.FromHex(proof.Key))
db := GenerateProofDB(proof.Proof)
value, err := trie.VerifyProof(root, secureKey, db)
Expand All @@ -75,7 +74,7 @@ func VerifyStorageProof(root common.Hash, proof gethclient.StorageResult) error
}
}

func VerifyProof(stateRoot common.Hash, proof *gethclient.AccountResult) error {
func VerifyProof(stateRoot common.Hash, proof *common.AccountResult) error {
err := VerifyAccountProof(
stateRoot,
proof.Address,
Expand Down
10 changes: 4 additions & 6 deletions op-node/withdrawals/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,20 @@ import (
"fmt"
"math/big"

"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-bindings/bindingspreview"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient/gethclient"

"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-bindings/bindingspreview"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
)

var MessagePassedTopic = crypto.Keccak256Hash([]byte("MessagePassed(uint256,address,address,uint256,uint256,bytes,bytes32)"))

type ProofClient interface {
GetProof(context.Context, common.Address, []string, *big.Int) (*gethclient.AccountResult, error)
GetProof(context.Context, common.Address, []string, *big.Int) (*common.AccountResult, error)
}

type ReceiptClient interface {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ config=$(cat << EOL
"preimageOracleChallengePeriod": 86400,
"fermat": 0,
"snowTimeOffset": "0x0",
"haberTimeOffset": "0x0",
"fundDevAccounts": true,
"proofMaturityDelaySeconds": 12,
"disputeGameFinalityDelaySeconds": 6,
Expand Down

0 comments on commit 3f74a4b

Please sign in to comment.