Skip to content

[Fjord] Add FastLZ compression into L1CostFunc #9053

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

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ require (
rsc.io/tmplfunc v0.0.3 // indirect
)

replace github.com/ethereum/go-ethereum => github.com/ethereum-optimism/op-geth v1.101305.3-rc.5
replace github.com/ethereum/go-ethereum => github.com/mdehoog/op-geth v0.0.0-20240202212424-715a526d1d14

//replace github.com/ethereum-optimism/superchain-registry/superchain => ../superchain-registry/superchain
//replace github.com/ethereum/go-ethereum v1.13.5 => ../go-ethereum
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ github.com/elastic/gosigar v0.14.2 h1:Dg80n8cr90OZ7x+bAax/QjoW/XqTI11RmA79ZwIm9/
github.com/elastic/gosigar v0.14.2/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.101305.3-rc.5 h1:ZDsZt9TWPTV8pCAklbk2IDxPbh23P6ZvaIeurGt/tL0=
github.com/ethereum-optimism/op-geth v1.101305.3-rc.5/go.mod h1:4i/arCdcrEzkmLO5XNMYo8s8eyhmKILxsLxz0PNwJwk=
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240131175747-1300b1825140 h1:F2Q+Gj4+W67CKZpVR+MEDL+EiIpgbx6VtwtdsPR4mbQ=
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240131175747-1300b1825140/go.mod h1:7xh2awFQqsiZxFrHKTgEd+InVfDRrkKVUIuK8SAFHp0=
github.com/ethereum/c-kzg-4844 v0.4.0 h1:3MS1s4JtA868KpJxroZoepdV0ZKBp3u/O5HcZ7R3nlY=
Expand Down Expand Up @@ -540,6 +538,8 @@ github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg=
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k=
github.com/mdehoog/op-geth v0.0.0-20240202212424-715a526d1d14 h1:TgbC39kkO1bXzXvlCYdF8S0Zf7i3tNnqEKPrcD0Dc9Y=
github.com/mdehoog/op-geth v0.0.0-20240202212424-715a526d1d14/go.mod h1:4i/arCdcrEzkmLO5XNMYo8s8eyhmKILxsLxz0PNwJwk=
github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4=
github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI=
github.com/miekg/dns v1.1.56 h1:5imZaSeoRNvpM9SzWNhEcP9QliKiz20/dA2QabIGVnE=
Expand Down
149 changes: 147 additions & 2 deletions op-bindings/bindings/gaspriceoracle.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions op-bindings/bindings/gaspriceoracle_more.go

Large diffs are not rendered by default.

118 changes: 116 additions & 2 deletions op-bindings/bindings/l1block.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions op-bindings/bindings/l1block_more.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 63 additions & 0 deletions op-e2e/gas_price_oracle_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package op_e2e

import (
"io/fs"
"math/big"
"os"
"path/filepath"
"testing"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/stretchr/testify/assert"

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

func TestGasPriceOracle(t *testing.T) {
backend := backends.NewSimulatedBackend(map[common.Address]core.GenesisAccount{
predeploys.GasPriceOracleAddr: {
Code: common.FromHex(bindings.GasPriceOracleDeployedBin),
Balance: big.NewInt(0),
Storage: map[common.Hash]common.Hash{
common.HexToHash("0x0"): common.HexToHash("0x0101"), // isEcotone = true, isFjord = true
},
},
predeploys.L1BlockAddr: {
Code: common.FromHex(bindings.L1BlockDeployedBin),
Balance: big.NewInt(0),
},
}, math.MaxUint64)

caller, err := bindings.NewGasPriceOracleCaller(predeploys.GasPriceOracleAddr, backend)
assert.NoError(t, err)

atLeastOnce := false
err = filepath.WalkDir("../specs", func(path string, d fs.DirEntry, err error) error {
if d.IsDir() {
return nil
}
b, err := os.ReadFile(path)
if err != nil {
return err
}

used, err := caller.GetL1GasUsed(&bind.CallOpts{}, b)
if err != nil {
return err
}

expected := (types.FlzCompressLen(b) + 68) * 16
assert.Equal(t, used.Uint64(), uint64(expected), path)

atLeastOnce = true
return nil
})
assert.NoError(t, err)
assert.True(t, atLeastOnce)
}
5 changes: 3 additions & 2 deletions op-node/chaincfg/chains_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"math/big"
"testing"

"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-service/eth"
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/require"

"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-service/eth"
)

// TestGetRollupConfig tests that the configs sourced from the superchain-registry match
Expand Down
8 changes: 8 additions & 0 deletions op-node/rollup/derive/attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ func (ba *FetchingAttributesBuilder) PreparePayloadAttributes(ctx context.Contex
}
}

if ba.rollupCfg.IsFjordActivationBlock(nextL2Time) {
fjord, err := FjordNetworkUpgradeTransactions()
if err != nil {
return nil, NewCriticalError(fmt.Errorf("failed to build fjord network upgrade txs: %w", err))
}
upgradeTxs = append(upgradeTxs, fjord...)
}

l1InfoTx, err := L1InfoDepositBytes(ba.rollupCfg, sysConfig, seqNumber, l1Info, nextL2Time)
if err != nil {
return nil, NewCriticalError(fmt.Errorf("failed to create l1InfoTx: %w", err))
Expand Down
16 changes: 15 additions & 1 deletion op-node/rollup/derive/engine_consolidate.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,21 @@ func logL1InfoTxns(rollupCfg *rollup.Config, l log.Logger, l2Number, l2Timestamp
"unsafe_l1_time", unsafeInfo.Time, "unsafe_seq_num", unsafeInfo.SequenceNumber,
"unsafe_l1_basefee", unsafeInfo.BaseFee, "unsafe_batcher_addr", unsafeInfo.BatcherAddr,
)
if bytes.HasPrefix(safeTxValue.Data(), types.EcotoneL1AttributesSelector) {
if bytes.HasPrefix(safeTxValue.Data(), types.FjordL1AttributesSelector) {
l.Error("L1 Info transaction differs",
"safe_l1_blob_basefee", safeInfo.BlobBaseFee,
"safe_l1_basefee_scalar", safeInfo.BaseFeeScalar,
"safe_l1_blob_basefee_scalar", safeInfo.BlobBaseFeeScalar,
"safe_cost_intercept", safeInfo.CostIntercept,
"safe_cost_fastlz_coef", safeInfo.CostFastLZCoef,
"safe_cost_txsize_coef", safeInfo.CostTxSizeCoef,
"unsafe_l1_blob_basefee", unsafeInfo.BlobBaseFee,
"unsafe_l1_basefee_scalar", unsafeInfo.BaseFeeScalar,
"unsafe_l1_blob_basefee_scalar", unsafeInfo.BlobBaseFeeScalar,
"unsafe_cost_intercept", unsafeInfo.CostIntercept,
"unsafe_cost_fastlz_coef", unsafeInfo.CostFastLZCoef,
"unsafe_cost_txsize_coef", unsafeInfo.CostTxSizeCoef)
} else if bytes.HasPrefix(safeTxValue.Data(), types.EcotoneL1AttributesSelector) {
l.Error("L1 Info transaction differs",
"safe_l1_blob_basefee", safeInfo.BlobBaseFee,
"safe_l1_basefee_scalar", safeInfo.BaseFeeScalar,
Expand Down
10 changes: 10 additions & 0 deletions op-node/rollup/derive/fjord_upgrade_transactions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package derive

import (
"github.com/ethereum/go-ethereum/common/hexutil"
)

func FjordNetworkUpgradeTransactions() ([]hexutil.Bytes, error) {
// TODO
return []hexutil.Bytes{}, nil
}
Loading