Skip to content

Commit

Permalink
- add Holocene parameter validation to op-program engine
Browse files Browse the repository at this point in the history
- updates for latest op-geth tag
  • Loading branch information
Roberto Bayardo committed Oct 21, 2024
1 parent 02a63d9 commit 7deea46
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ require (
rsc.io/tmplfunc v0.0.3 // indirect
)

replace github.com/ethereum/go-ethereum v1.14.11 => github.com/ethereum-optimism/op-geth v1.101411.1-rc.1
replace github.com/ethereum/go-ethereum v1.14.11 => github.com/ethereum-optimism/op-geth v1.101411.1-rc.2

//replace github.com/ethereum/go-ethereum => ../op-geth

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,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.1-rc.1 h1:HhvjQQIY73Rhkf3CtcNLuL87A7z/us78ft4m84BuZes=
github.com/ethereum-optimism/op-geth v1.101411.1-rc.1/go.mod h1:7S4pp8KHBmEmKkRjL1BPOc6jY9hW+64YeMUjR3RVLw4=
github.com/ethereum-optimism/op-geth v1.101411.1-rc.2 h1:nOeSTzcFWUCvJO1MJ5AyI26dqR1F7vYgz2jNNKuEtoE=
github.com/ethereum-optimism/op-geth v1.101411.1-rc.2/go.mod h1:7S4pp8KHBmEmKkRjL1BPOc6jY9hW+64YeMUjR3RVLw4=
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240910145426-b3905c89e8ac h1:hCIrLuOPV3FJfMDvXeOhCC3uQNvFoMIIlkT2mN2cfeg=
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240910145426-b3905c89e8ac/go.mod h1:XaVXL9jg8BcyOeugECgIUGa9Y3DjYJj71RHmb5qon6M=
github.com/ethereum/c-kzg-4844 v1.0.0 h1:0X1LBXxaEtYD9xsyj9B9ctQEZIpnvVDeoBx8aHEwTNA=
Expand Down
2 changes: 1 addition & 1 deletion op-node/rollup/derive/payload_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func PayloadToSystemConfig(rollupCfg *rollup.Config, payload *eth.ExecutionPaylo
return eth.SystemConfig{}, err
}
d, e := eip1559.DecodeHoloceneExtraData(payload.ExtraData)
copy(r.EIP1559Params[:], eip1559.EncodeHolocene1559Params(uint32(d), uint32(e)))
copy(r.EIP1559Params[:], eip1559.EncodeHolocene1559Params(d, e))
}
return r, nil
}
3 changes: 1 addition & 2 deletions op-program/client/l2/engineapi/block_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,12 @@ func NewBlockProcessorFromPayloadAttributes(provider BlockDataProvider, parent c
ParentBeaconRoot: attrs.ParentBeaconBlockRoot,
}
if attrs.EIP1559Params != nil {
// Do we need to check if holocene is active?
d, e := eip1559.DecodeHolocene1559Params(attrs.EIP1559Params[:])
if d == 0 {
d = provider.Config().BaseFeeChangeDenominator(header.Time)
e = provider.Config().ElasticityMultiplier()
}
header.Extra = eip1559.EncodeHoloceneExtraData(uint32(d), uint32(e))
header.Extra = eip1559.EncodeHoloceneExtraData(d, e)
}

return NewBlockProcessorFromHeader(provider, header)
Expand Down
21 changes: 19 additions & 2 deletions op-program/client/l2/engineapi/l2_engine_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/ethereum/go-ethereum/beacon/engine"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/consensus/misc/eip1559"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/stateless"
"github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -260,15 +261,24 @@ func (ea *L2EngineAPI) ForkchoiceUpdatedV3(ctx context.Context, state *eth.Forkc
// Ported from: https://github.com/ethereum-optimism/op-geth/blob/c50337a60a1309a0f1dca3bf33ed1bb38c46cdd7/eth/catalyst/api.go#L206-L218
func (ea *L2EngineAPI) verifyPayloadAttributes(attr *eth.PayloadAttributes) error {
c := ea.config()
t := uint64(attr.Timestamp)

// Verify withdrawals attribute for Shanghai.
if err := checkAttribute(c.IsShanghai, attr.Withdrawals != nil, c.LondonBlock, uint64(attr.Timestamp)); err != nil {
if err := checkAttribute(c.IsShanghai, attr.Withdrawals != nil, c.LondonBlock, t); err != nil {
return fmt.Errorf("invalid withdrawals: %w", err)
}
// Verify beacon root attribute for Cancun.
if err := checkAttribute(c.IsCancun, attr.ParentBeaconBlockRoot != nil, c.LondonBlock, uint64(attr.Timestamp)); err != nil {
if err := checkAttribute(c.IsCancun, attr.ParentBeaconBlockRoot != nil, c.LondonBlock, t); err != nil {
return fmt.Errorf("invalid parent beacon block root: %w", err)
}
// Verify EIP-1559 params for Holocene.
if c.IsHolocene(t) {
if err := eip1559.ValidateHolocene1559Params(attr.EIP1559Params[:]); err != nil {
return fmt.Errorf("invalid Holocene params: %w", err)
}
} else if attr.EIP1559Params != nil {
return errors.New("got Holocene params though fork not active")
}

return nil
}
Expand Down Expand Up @@ -322,6 +332,13 @@ func (ea *L2EngineAPI) NewPayloadV3(ctx context.Context, params *eth.ExecutionPa
return &eth.PayloadStatusV1{Status: eth.ExecutionInvalid}, engine.UnsupportedFork.With(errors.New("newPayloadV3 called pre-cancun"))
}

// Payload must have eip-1559 params in ExtraData after Holocene
if ea.config().IsHolocene(uint64(params.Timestamp)) {
if err := eip1559.ValidateHoloceneExtraData(params.ExtraData); err != nil {
return &eth.PayloadStatusV1{Status: eth.ExecutionInvalid}, engine.UnsupportedFork.With(errors.New("invalid holocene extraData post-holoocene"))
}
}

return ea.newPayload(ctx, params, versionedHashes, beaconRoot)
}

Expand Down

0 comments on commit 7deea46

Please sign in to comment.