Commit 4a82612b authored by Roberto Bayardo's avatar Roberto Bayardo Committed by GitHub

Updates to work with upstream geth v1.14.12 changes (#13002)

* all: update to op-geth with upstream v1.14.12 changes.

* go.mod: bump go-ethereum dependency to 1.14.12

* go mod tidy

* go.mod: update op-geth and scr

---------
Co-authored-by: default avatarRoberto Bayardo <roberto.bayardo@coinbase.com>
Co-authored-by: default avatarprotolambda <proto@protolambda.com>
Co-authored-by: default avatarSebastian Stammler <seb@oplabs.co>
parent 6f0d98c5
......@@ -217,7 +217,6 @@ require (
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/status-im/keycard-go v0.2.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/supranational/blst v0.3.13 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a // indirect
......@@ -251,9 +250,9 @@ require (
rsc.io/tmplfunc v0.0.3 // indirect
)
replace github.com/ethereum/go-ethereum => github.com/ethereum-optimism/op-geth v1.101411.5-rc.2
replace github.com/ethereum/go-ethereum => github.com/ethereum-optimism/op-geth v1.101412.0-rc.1
//replace github.com/ethereum/go-ethereum => ../go-ethereum
//replace github.com/ethereum/go-ethereum => ../op-geth
// replace github.com/ethereum-optimism/superchain-registry/superchain => ../superchain-registry/superchain
......
......@@ -190,8 +190,8 @@ github.com/elastic/gosigar v0.14.3 h1:xwkKwPia+hSfg9GqrCUKYdId102m9qTJIIr7egmK/u
github.com/elastic/gosigar v0.14.3/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs=
github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3 h1:RWHKLhCrQThMfch+QJ1Z8veEq5ZO3DfIhZ7xgRP9WTc=
github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3/go.mod h1:QziizLAiF0KqyLdNJYD7O5cpDlaFMNZzlxYNcWsJUxs=
github.com/ethereum-optimism/op-geth v1.101411.5-rc.2 h1:BZVp8LEVzeJOX+Uanie7h1ly23yPe8+pVjGEmzrOjc0=
github.com/ethereum-optimism/op-geth v1.101411.5-rc.2/go.mod h1:rq9bjyaTP534guwZ7qdfNTliXFcCjO7buoWW7x97tCE=
github.com/ethereum-optimism/op-geth v1.101412.0-rc.1 h1:Un6Cnr4QkQx+s/Rp1iWvsBD+lIE1xZd8RKIKxGmChTk=
github.com/ethereum-optimism/op-geth v1.101412.0-rc.1/go.mod h1:lRTd6c45e98fA9Cm0c8SrtqiSNYtxUBBZo3ofJbQh5I=
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20250115145553-996c7aba6565 h1:jhMVWUohS71nsNg8Q8d7DatiGpPocvUNGr/zP8a+79A=
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20250115145553-996c7aba6565/go.mod h1:9feO8jcL5OZ1tvRjEfNAHz4Aggvd6373l+ZxmZZAyZs=
github.com/ethereum/c-kzg-4844 v1.0.0 h1:0X1LBXxaEtYD9xsyj9B9ctQEZIpnvVDeoBx8aHEwTNA=
......@@ -780,8 +780,6 @@ github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA=
github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
......
......@@ -17,7 +17,6 @@ import (
"github.com/mattn/go-isatty"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient"
......@@ -48,9 +47,10 @@ func CalcBaseFee(parent eth.BlockInfo, elasticity uint64, canyonActive bool) *bi
num.Mul(num, parent.BaseFee())
num.Div(num, denom.SetUint64(parentGasTarget))
num.Div(num, denom.SetUint64(denomUint))
baseFeeDelta := math.BigMax(num, common.Big1)
return num.Add(parent.BaseFee(), baseFeeDelta)
if num.Cmp(common.Big1) < 0 {
num.Set(common.Big1)
}
return num.Add(num, parent.BaseFee())
} else {
// Otherwise if the parent block used less gas than its target, the baseFee should decrease.
// max(0, parentBaseFee * gasUsedDelta / parentGasTarget / baseFeeChangeDenominator)
......@@ -58,9 +58,11 @@ func CalcBaseFee(parent eth.BlockInfo, elasticity uint64, canyonActive bool) *bi
num.Mul(num, parent.BaseFee())
num.Div(num, denom.SetUint64(parentGasTarget))
num.Div(num, denom.SetUint64(denomUint))
baseFee := num.Sub(parent.BaseFee(), num)
return math.BigMax(baseFee, common.Big0)
num.Sub(parent.BaseFee(), num)
if num.Cmp(common.Big0) < 0 {
return common.Big0
}
return num
}
}
......
......@@ -42,36 +42,35 @@ func NewL2Genesis(config *DeployConfig, l1StartHeader *types.Header) (*core.Gene
l1StartTime := l1StartHeader.Time
optimismChainConfig := params.ChainConfig{
ChainID: new(big.Int).SetUint64(config.L2ChainID),
HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil,
DAOForkSupport: false,
EIP150Block: big.NewInt(0),
EIP155Block: big.NewInt(0),
EIP158Block: big.NewInt(0),
ByzantiumBlock: big.NewInt(0),
ConstantinopleBlock: big.NewInt(0),
PetersburgBlock: big.NewInt(0),
IstanbulBlock: big.NewInt(0),
MuirGlacierBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
ArrowGlacierBlock: big.NewInt(0),
GrayGlacierBlock: big.NewInt(0),
MergeNetsplitBlock: big.NewInt(0),
TerminalTotalDifficulty: big.NewInt(0),
TerminalTotalDifficultyPassed: true,
BedrockBlock: new(big.Int).SetUint64(uint64(config.L2GenesisBlockNumber)),
RegolithTime: config.RegolithTime(l1StartTime),
CanyonTime: config.CanyonTime(l1StartTime),
ShanghaiTime: config.CanyonTime(l1StartTime),
CancunTime: config.EcotoneTime(l1StartTime),
EcotoneTime: config.EcotoneTime(l1StartTime),
FjordTime: config.FjordTime(l1StartTime),
GraniteTime: config.GraniteTime(l1StartTime),
HoloceneTime: config.HoloceneTime(l1StartTime),
IsthmusTime: config.IsthmusTime(l1StartTime),
InteropTime: config.InteropTime(l1StartTime),
ChainID: new(big.Int).SetUint64(config.L2ChainID),
HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil,
DAOForkSupport: false,
EIP150Block: big.NewInt(0),
EIP155Block: big.NewInt(0),
EIP158Block: big.NewInt(0),
ByzantiumBlock: big.NewInt(0),
ConstantinopleBlock: big.NewInt(0),
PetersburgBlock: big.NewInt(0),
IstanbulBlock: big.NewInt(0),
MuirGlacierBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
ArrowGlacierBlock: big.NewInt(0),
GrayGlacierBlock: big.NewInt(0),
MergeNetsplitBlock: big.NewInt(0),
TerminalTotalDifficulty: big.NewInt(0),
BedrockBlock: new(big.Int).SetUint64(uint64(config.L2GenesisBlockNumber)),
RegolithTime: config.RegolithTime(l1StartTime),
CanyonTime: config.CanyonTime(l1StartTime),
ShanghaiTime: config.CanyonTime(l1StartTime),
CancunTime: config.EcotoneTime(l1StartTime),
EcotoneTime: config.EcotoneTime(l1StartTime),
FjordTime: config.FjordTime(l1StartTime),
GraniteTime: config.GraniteTime(l1StartTime),
HoloceneTime: config.HoloceneTime(l1StartTime),
IsthmusTime: config.IsthmusTime(l1StartTime),
InteropTime: config.InteropTime(l1StartTime),
Optimism: &params.OptimismConfig{
EIP1559Denominator: eip1559Denom,
EIP1559Elasticity: eip1559Elasticity,
......@@ -144,9 +143,8 @@ func NewL1Genesis(config *DeployConfig) (*core.Genesis, error) {
ShanghaiTime: u64ptr(0),
CancunTime: u64ptr(0),
// To enable post-Merge consensus at genesis
MergeNetsplitBlock: big.NewInt(0),
TerminalTotalDifficulty: big.NewInt(0),
TerminalTotalDifficultyPassed: true,
MergeNetsplitBlock: big.NewInt(0),
TerminalTotalDifficulty: big.NewInt(0),
}
gasLimit := config.L1GenesisBlockGasLimit
......
......@@ -109,10 +109,10 @@ func (f *ForkDB) TrieDB() *triedb.Database {
IsVerkle: false,
HashDB: nil,
PathDB: &pathdb.Config{
StateHistory: 0,
CleanCacheSize: 0,
DirtyCacheSize: 0,
ReadOnly: true,
StateHistory: 0,
CleanCacheSize: 0,
WriteBufferSize: 0,
ReadOnly: true,
},
})
return tdb
......
......@@ -250,12 +250,12 @@ func (fst *ForkableState) CreateContract(address common.Address) {
fst.stateFor(address).CreateContract(address)
}
func (fst *ForkableState) SubBalance(address common.Address, u *uint256.Int, reason tracing.BalanceChangeReason) {
fst.stateFor(address).SubBalance(address, u, reason)
func (fst *ForkableState) SubBalance(address common.Address, u *uint256.Int, reason tracing.BalanceChangeReason) uint256.Int {
return fst.stateFor(address).SubBalance(address, u, reason)
}
func (fst *ForkableState) AddBalance(address common.Address, u *uint256.Int, reason tracing.BalanceChangeReason) {
fst.stateFor(address).AddBalance(address, u, reason)
func (fst *ForkableState) AddBalance(address common.Address, u *uint256.Int, reason tracing.BalanceChangeReason) uint256.Int {
return fst.stateFor(address).AddBalance(address, u, reason)
}
func (fst *ForkableState) GetBalance(address common.Address) *uint256.Int {
......@@ -306,8 +306,8 @@ func (fst *ForkableState) GetState(address common.Address, k common.Hash) common
return fst.stateFor(address).GetState(address, k)
}
func (fst *ForkableState) SetState(address common.Address, k common.Hash, v common.Hash) {
fst.stateFor(address).SetState(address, k, v)
func (fst *ForkableState) SetState(address common.Address, k common.Hash, v common.Hash) common.Hash {
return fst.stateFor(address).SetState(address, k, v)
}
func (fst *ForkableState) GetStorageRoot(addr common.Address) common.Hash {
......@@ -322,16 +322,16 @@ func (fst *ForkableState) SetTransientState(addr common.Address, key, value comm
fst.stateFor(addr).SetTransientState(addr, key, value)
}
func (fst *ForkableState) SelfDestruct(address common.Address) {
fst.stateFor(address).SelfDestruct(address)
func (fst *ForkableState) SelfDestruct(address common.Address) uint256.Int {
return fst.stateFor(address).SelfDestruct(address)
}
func (fst *ForkableState) HasSelfDestructed(address common.Address) bool {
return fst.stateFor(address).HasSelfDestructed(address)
}
func (fst *ForkableState) Selfdestruct6780(address common.Address) {
fst.stateFor(address).Selfdestruct6780(address)
func (fst *ForkableState) SelfDestruct6780(address common.Address) (uint256.Int, bool) {
return fst.stateFor(address).SelfDestruct6780(address)
}
func (fst *ForkableState) Exist(address common.Address) bool {
......
......@@ -209,12 +209,11 @@ func NewHost(
GrayGlacierBlock: big.NewInt(0),
MergeNetsplitBlock: big.NewInt(0),
// Ethereum forks in proof-of-stake era.
TerminalTotalDifficulty: big.NewInt(1),
TerminalTotalDifficultyPassed: true,
ShanghaiTime: new(uint64),
CancunTime: new(uint64),
PragueTime: nil,
VerkleTime: nil,
TerminalTotalDifficulty: big.NewInt(1),
ShanghaiTime: new(uint64),
CancunTime: new(uint64),
PragueTime: nil,
VerkleTime: nil,
// OP-Stack forks are disabled, since we use this for L1.
BedrockBlock: nil,
RegolithTime: nil,
......
......@@ -74,6 +74,10 @@ func (o *OracleKeyValueStore) Delete(key []byte) error {
panic("not supported")
}
func (o *OracleKeyValueStore) DeleteRange(start, end []byte) error {
panic("not supported")
}
func (o *OracleKeyValueStore) Stat() (string, error) {
panic("not supported")
}
......
......@@ -301,7 +301,7 @@ func (ea *L2EngineAPI) NewPayloadV1(ctx context.Context, payload *eth.ExecutionP
return &eth.PayloadStatusV1{Status: eth.ExecutionInvalid}, engine.InvalidParams.With(errors.New("withdrawals not supported in V1"))
}
return ea.newPayload(ctx, payload, nil, nil)
return ea.newPayload(ctx, payload, nil, nil, nil)
}
func (ea *L2EngineAPI) NewPayloadV2(ctx context.Context, payload *eth.ExecutionPayload) (*eth.PayloadStatusV1, error) {
......@@ -313,7 +313,7 @@ func (ea *L2EngineAPI) NewPayloadV2(ctx context.Context, payload *eth.ExecutionP
return &eth.PayloadStatusV1{Status: eth.ExecutionInvalid}, engine.InvalidParams.With(errors.New("non-nil withdrawals pre-shanghai"))
}
return ea.newPayload(ctx, payload, nil, nil)
return ea.newPayload(ctx, payload, nil, nil, nil)
}
// Ported from: https://github.com/ethereum-optimism/op-geth/blob/c50337a60a1309a0f1dca3bf33ed1bb38c46cdd7/eth/catalyst/api.go#L486C1-L507
......@@ -342,7 +342,7 @@ func (ea *L2EngineAPI) NewPayloadV3(ctx context.Context, params *eth.ExecutionPa
}
}
return ea.newPayload(ctx, params, versionedHashes, beaconRoot)
return ea.newPayload(ctx, params, versionedHashes, beaconRoot, nil)
}
func (ea *L2EngineAPI) getPayload(_ context.Context, payloadId eth.PayloadID) (*eth.ExecutionPayloadEnvelope, error) {
......@@ -479,7 +479,7 @@ func toGethWithdrawals(payload *eth.ExecutionPayload) []*types.Withdrawal {
return result
}
func (ea *L2EngineAPI) newPayload(_ context.Context, payload *eth.ExecutionPayload, hashes []common.Hash, root *common.Hash) (*eth.PayloadStatusV1, error) {
func (ea *L2EngineAPI) newPayload(_ context.Context, payload *eth.ExecutionPayload, hashes []common.Hash, root *common.Hash, requests [][]byte) (*eth.PayloadStatusV1, error) {
ea.log.Trace("L2Engine API request received", "method", "ExecutePayload", "number", payload.BlockNumber, "hash", payload.BlockHash)
txs := make([][]byte, len(payload.Transactions))
for i, tx := range payload.Transactions {
......@@ -503,7 +503,7 @@ func (ea *L2EngineAPI) newPayload(_ context.Context, payload *eth.ExecutionPaylo
Withdrawals: toGethWithdrawals(payload),
ExcessBlobGas: (*uint64)(payload.ExcessBlobGas),
BlobGasUsed: (*uint64)(payload.BlobGasUsed),
}, hashes, root, ea.backend.Config())
}, hashes, root, requests, ea.backend.Config())
if err != nil {
log.Debug("Invalid NewPayload params", "params", payload, "error", err)
return &eth.PayloadStatusV1{Status: eth.ExecutionInvalidBlockHash}, nil
......
......@@ -84,6 +84,7 @@ func newStubBackend(t *testing.T) *stubCachingBackend {
func createGenesis() *core.Genesis {
config := *params.MergedTestChainConfig
config.PragueTime = nil
var zero uint64
// activate recent OP-stack forks
config.RegolithTime = &zero
......
......@@ -31,6 +31,10 @@ func (p DB) Delete(key []byte) error {
return nil
}
func (p *DB) DeleteRange(start, end []byte) error {
panic("not supported")
}
func (p DB) Stat() (string, error) {
panic("not supported")
}
......
......@@ -23,6 +23,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/ethdb/leveldb"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie"
......@@ -43,18 +44,14 @@ type Cheater struct {
func OpenGethRawDB(dataDirPath string, readOnly bool) (ethdb.Database, error) {
// don't use readonly mode in actual DB, it doesn't work with Geth.
db, err := rawdb.Open(rawdb.OpenOptions{
Type: "leveldb",
Directory: dataDirPath,
AncientsDirectory: filepath.Join(dataDirPath, "ancient"),
Namespace: "",
Cache: 2048,
Handles: 500,
ReadOnly: readOnly,
})
kvs, err := leveldb.New(dataDirPath, 2048, 500, "", readOnly)
if err != nil {
return nil, fmt.Errorf("failed to open leveldb: %w", err)
}
db, err := rawdb.NewDatabaseWithFreezer(kvs, filepath.Join(dataDirPath, "ancient"), "", readOnly)
if err != nil {
return nil, fmt.Errorf("failed to open db with freezer: %w", err)
}
return db, nil
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment