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

Merge op-geth v1.101411.2-rc.2 #20

Merged
merged 22 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
7b56c73
update fork.yaml to cover Holocene eip-1559 parameter configurability…
roberto-bayardo Oct 23, 2024
c6b531b
Avoid add l1Cost twice when GasFeeCap is nil (#391)
zhiqiangxu Oct 27, 2024
5c98784
export a function to estimate the l1 batch size of a transaction (#416)
roberto-bayardo Oct 28, 2024
11064f6
clarify that the estimated l1 size is scaled up by 1e6 (#418)
roberto-bayardo Oct 29, 2024
6d4a826
core/types: transaction conditional KnownAccounts fix && HexOrDecimal…
hamdiallam Oct 25, 2024
a52bc72
Merge pull request #414 from ethereum-optimism/transactionCondition.h…
hamdiallam Oct 29, 2024
7c55f13
skip state db op when NoBaseFee is true (#417)
zhiqiangxu Oct 30, 2024
4539f2d
Add ability to bound the max l1 data size (#421)
roberto-bayardo Oct 30, 2024
969069e
add unscaled version of EstimatedL1Size and rename EstimatedDASize (#…
roberto-bayardo Oct 31, 2024
48cf9ac
interop: sequencer executing message check support (#372)
protolambda Oct 31, 2024
007538b
interop: Ingress Filtering for Interop Enabled Mempool
axelKingsley Oct 29, 2024
7806b1d
cleanup tests
axelKingsley Nov 1, 2024
1617aeb
fix compile
axelKingsley Nov 5, 2024
ecda465
correct chainCheck logic
axelKingsley Nov 5, 2024
262842b
Add Flag for Interop Mempool Filtering
axelKingsley Nov 5, 2024
d6a8b0b
Merge pull request #422 from ethereum-optimism/interop-mempool-filter
axelKingsley Nov 5, 2024
0891f5a
miner: add tcount incorrectly (#419)
islishude Nov 6, 2024
1e60ba8
miner/payload_builder_test.go: fix name of payload building test (#423)
roberto-bayardo Nov 7, 2024
647c346
Prepare Holocene devnet & testnet release (#429)
sebastianst Nov 13, 2024
ba9e8ec
Update superchain-registry to include metal-sepolia
sebastianst Nov 19, 2024
3dd9b02
Merge pull request #431 from ethereum-optimism/seb/holocene-sepolia-m…
tynes Nov 19, 2024
58ef82d
Merge tag 'v1.101411.2-rc.2' into merge-latest
blockchaindevsh Nov 19, 2024
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
15 changes: 10 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ orbs:
gcp-cli: circleci/[email protected]
slack: circleci/[email protected]

parameters:
go_version:
type: string
default: 1.22.7 # update CI Go version here

commands:
gcp-oidc-authenticate:
description: "Authenticate with GCP using a CircleCI OIDC token."
Expand Down Expand Up @@ -134,7 +139,7 @@ jobs:

build-geth:
docker:
- image: cimg/go:1.21
- image: cimg/go:<<pipeline.parameters.go_version>>
resource_class: xlarge
steps:
- checkout
Expand All @@ -143,30 +148,30 @@ jobs:
unit-test:
resource_class: xlarge
docker:
- image: cimg/go:1.21
- image: cimg/go:<<pipeline.parameters.go_version>>
steps:
- checkout
- run:
command: go run build/ci.go test
lint-geth:
resource_class: medium
docker:
- image: cimg/go:1.21
- image: cimg/go:<<pipeline.parameters.go_version>>
steps:
- checkout
- run:
command: go run build/ci.go lint
tidy-geth:
resource_class: small
docker:
- image: cimg/go:1.21
- image: cimg/go:<<pipeline.parameters.go_version>>
steps:
- checkout
- run:
command: go mod tidy && git diff --exit-code
check-releases:
docker:
- image: cimg/go:1.21
- image: cimg/go:<<pipeline.parameters.go_version>>
steps:
- checkout
- run:
Expand Down
2 changes: 2 additions & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ var (
utils.RollupSequencerTxConditionalCostRateLimitFlag,
utils.RollupHistoricalRPCFlag,
utils.RollupHistoricalRPCTimeoutFlag,
utils.RollupInteropRPCFlag,
utils.RollupInteropMempoolFilteringFlag,
utils.RollupDisableTxPoolGossipFlag,
utils.RollupComputePendingBlock,
utils.RollupHaltOnIncompatibleProtocolVersionFlag,
Expand Down
18 changes: 18 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,18 @@ var (
Category: flags.RollupCategory,
}

RollupInteropRPCFlag = &cli.StringFlag{
Name: "rollup.interoprpc",
Usage: "RPC endpoint for interop message verification (experimental).",
Category: flags.RollupCategory,
}

RollupInteropMempoolFilteringFlag = &cli.BoolFlag{
Name: "rollup.interopmempoolfiltering",
Usage: "If using interop, transactions are checked for interop validity before being added to the mempool (experimental).",
Category: flags.RollupCategory,
}

RollupDisableTxPoolGossipFlag = &cli.BoolFlag{
Name: "rollup.disabletxpoolgossip",
Usage: "Disable transaction pool gossip.",
Expand Down Expand Up @@ -1941,6 +1953,12 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
if ctx.IsSet(RollupHistoricalRPCTimeoutFlag.Name) {
cfg.RollupHistoricalRPCTimeout = ctx.Duration(RollupHistoricalRPCTimeoutFlag.Name)
}
if ctx.IsSet(RollupInteropRPCFlag.Name) {
cfg.InteropMessageRPC = ctx.String(RollupInteropRPCFlag.Name)
}
if ctx.IsSet(RollupInteropMempoolFilteringFlag.Name) {
cfg.InteropMempoolFiltering = ctx.Bool(RollupInteropMempoolFilteringFlag.Name)
}
cfg.RollupDisableTxPoolGossip = ctx.Bool(RollupDisableTxPoolGossipFlag.Name)
cfg.RollupDisableTxPoolAdmission = cfg.RollupSequencerHTTP != "" && !ctx.Bool(RollupEnableTxPoolAdmissionFlag.Name)
cfg.RollupHaltOnIncompatibleProtocolVersion = ctx.String(RollupHaltOnIncompatibleProtocolVersionFlag.Name)
Expand Down
4 changes: 4 additions & 0 deletions core/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ var (
// current network configuration.
ErrTxTypeNotSupported = types.ErrTxTypeNotSupported

// ErrTxFilteredOut indicates an ingress filter has rejected the transaction from
// being included in the pool.
ErrTxFilteredOut = errors.New("transaction filtered out")

// ErrTipAboveFeeCap is a sanity error to ensure no one is able to specify a
// transaction with a tip higher than the total fee cap.
ErrTipAboveFeeCap = errors.New("max priority fee per gas higher than max fee per gas")
Expand Down
11 changes: 11 additions & 0 deletions core/state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,21 @@ func MakeReceipt(evm *vm.EVM, result *ExecutionResult, statedb *state.StateDB, b
// for the transaction, gas used and an error if the transaction failed,
// indicating the block was invalid.
func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *common.Address, gp *GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *uint64, cfg vm.Config) (*types.Receipt, error) {
return ApplyTransactionExtended(config, bc, author, gp, statedb, header, tx, usedGas, cfg, nil)
}

type ApplyTransactionOpts struct {
PostValidation func(evm *vm.EVM, result *ExecutionResult) error
}

func ApplyTransactionExtended(config *params.ChainConfig, bc ChainContext, author *common.Address, gp *GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *uint64, cfg vm.Config, extraOpts *ApplyTransactionOpts) (*types.Receipt, error) {
msg, err := TransactionToMessage(tx, types.MakeSigner(config, header.Number, header.Time), header.BaseFee)
if err != nil {
return nil, err
}
if extraOpts != nil {
msg.PostValidation = extraOpts.PostValidation
}
// Create a new context to be used in the EVM environment
blockContext := NewEVMBlockContext(header, bc, author, config, statedb)
txContext := NewEVMTxContext(msg)
Expand Down
75 changes: 42 additions & 33 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ type Message struct {
IsDepositTx bool // IsDepositTx indicates the message is force-included and can persist a mint.
Mint *big.Int // Mint is the amount to mint before EVM processing, or nil if there is no minting.
RollupCostData types.RollupCostData // RollupCostData caches data to compute the fee we charge for data availability

PostValidation func(evm *vm.EVM, result *ExecutionResult) error
}

// TransactionToMessage converts a transaction into a Message.
Expand Down Expand Up @@ -440,11 +442,11 @@ func (st *StateTransition) buyGas() error {
if st.msg.GasFeeCap != nil {
balanceCheck.SetUint64(st.msg.GasLimit)
balanceCheck = balanceCheck.Mul(balanceCheck, st.msg.GasFeeCap)
if l1Cost != nil {
balanceCheck.Add(balanceCheck, l1Cost)
}
}
balanceCheck.Add(balanceCheck, st.msg.Value)
if l1Cost != nil {
balanceCheck.Add(balanceCheck, l1Cost)
}

if st.evm.ChainConfig().IsCancun(st.evm.Context.BlockNumber, st.evm.Context.Time) {
if blobGas := st.blobGasUsed(); blobGas > 0 {
Expand Down Expand Up @@ -668,6 +670,13 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
}
err = nil
}

if st.msg.PostValidation != nil {
if err := st.msg.PostValidation(st.evm, result); err != nil {
return nil, err
}
}

return result, err
}

Expand Down Expand Up @@ -811,49 +820,49 @@ func (st *StateTransition) innerTransitionDb() (*ExecutionResult, error) {
if rules.IsEIP4762 && fee.Sign() != 0 {
st.evm.AccessEvents.AddAccount(st.evm.Context.Coinbase, true)
}
}

// Check that we are post bedrock to enable op-geth to be able to create pseudo pre-bedrock blocks (these are pre-bedrock, but don't follow l2 geth rules)
// Note optimismConfig will not be nil if rules.IsOptimismBedrock is true
if optimismConfig := st.evm.ChainConfig().Optimism; optimismConfig != nil && rules.IsOptimismBedrock && !st.msg.IsDepositTx {
gasCost := new(big.Int).Mul(new(big.Int).SetUint64(st.gasUsed()), st.evm.Context.BaseFee)
// Check that we are post bedrock to enable op-geth to be able to create pseudo pre-bedrock blocks (these are pre-bedrock, but don't follow l2 geth rules)
// Note optimismConfig will not be nil if rules.IsOptimismBedrock is true
if optimismConfig := st.evm.ChainConfig().Optimism; optimismConfig != nil && rules.IsOptimismBedrock && !st.msg.IsDepositTx {
gasCost := new(big.Int).Mul(new(big.Int).SetUint64(st.gasUsed()), st.evm.Context.BaseFee)

if st.evm.ChainConfig().IsCancun(st.evm.Context.BlockNumber, st.evm.Context.Time) {
gasCost.Add(gasCost, new(big.Int).Mul(new(big.Int).SetUint64(st.blobGasUsed()), st.evm.Context.BlobBaseFee))
}

amtU256, overflow := uint256.FromBig(gasCost)
if overflow {
return nil, fmt.Errorf("optimism gas cost overflows U256: %d", gasCost)
}
if shouldCheckGasFormula {
st.baseFee = amtU256.Clone()
}
if st.evm.ChainConfig().IsCancun(st.evm.Context.BlockNumber, st.evm.Context.Time) {
gasCost.Add(gasCost, new(big.Int).Mul(new(big.Int).SetUint64(st.blobGasUsed()), st.evm.Context.BlobBaseFee))
}

amtU256 = st.collectableNativeBalance(amtU256)
st.state.AddBalance(params.OptimismBaseFeeRecipient, amtU256, tracing.BalanceIncreaseRewardTransactionFee)
if l1Cost := st.evm.Context.L1CostFunc(st.msg.RollupCostData, st.evm.Context.Time); l1Cost != nil {
amtU256, overflow = uint256.FromBig(l1Cost)
amtU256, overflow := uint256.FromBig(gasCost)
if overflow {
return nil, fmt.Errorf("optimism l1 cost overflows U256: %d", l1Cost)
return nil, fmt.Errorf("optimism gas cost overflows U256: %d", gasCost)
}

if shouldCheckGasFormula {
st.l1Fee = amtU256.Clone()
st.baseFee = amtU256.Clone()
}

amtU256 = st.collectableNativeBalance(amtU256)
st.state.AddBalance(params.OptimismL1FeeRecipient, amtU256, tracing.BalanceIncreaseRewardTransactionFee)
}
st.state.AddBalance(params.OptimismBaseFeeRecipient, amtU256, tracing.BalanceIncreaseRewardTransactionFee)
if l1Cost := st.evm.Context.L1CostFunc(st.msg.RollupCostData, st.evm.Context.Time); l1Cost != nil {
amtU256, overflow = uint256.FromBig(l1Cost)
if overflow {
return nil, fmt.Errorf("optimism l1 cost overflows U256: %d", l1Cost)
}
if shouldCheckGasFormula {
st.l1Fee = amtU256.Clone()
}

if shouldCheckGasFormula {
if st.l1Fee == nil {
st.l1Fee = new(uint256.Int)
amtU256 = st.collectableNativeBalance(amtU256)
st.state.AddBalance(params.OptimismL1FeeRecipient, amtU256, tracing.BalanceIncreaseRewardTransactionFee)
}
if err := st.checkGasFormula(); err != nil {
return nil, err

if shouldCheckGasFormula {
if st.l1Fee == nil {
st.l1Fee = new(uint256.Int)
}
if err := st.checkGasFormula(); err != nil {
return nil, err
}
}
}

}

return &ExecutionResult{
Expand Down
57 changes: 57 additions & 0 deletions core/txpool/ingress_filters.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package txpool

import (
"context"
"time"

"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types/interoptypes"
"github.com/ethereum/go-ethereum/log"
)

// IngressFilter is an interface that allows filtering of transactions before they are added to the transaction pool.
// Implementations of this interface can be used to filter transactions based on various criteria.
// FilterTx will return true if the transaction should be allowed, and false if it should be rejected.
type IngressFilter interface {
FilterTx(ctx context.Context, tx *types.Transaction) bool
}

type interopFilter struct {
logsFn func(tx *types.Transaction) ([]*types.Log, error)
checkFn func(ctx context.Context, ems []interoptypes.Message, safety interoptypes.SafetyLevel) error
}

func NewInteropFilter(
logsFn func(tx *types.Transaction) ([]*types.Log, error),
checkFn func(ctx context.Context, ems []interoptypes.Message, safety interoptypes.SafetyLevel) error) IngressFilter {
return &interopFilter{
logsFn: logsFn,
checkFn: checkFn,
}
}

// FilterTx implements IngressFilter.FilterTx
// it gets logs checks for message safety based on the function provided
func (f *interopFilter) FilterTx(ctx context.Context, tx *types.Transaction) bool {
logs, err := f.logsFn(tx)
if err != nil {
log.Debug("Failed to retrieve logs of tx", "txHash", tx.Hash(), "err", err)
return false // default to deny if logs cannot be retrieved
}
if len(logs) == 0 {
return true // default to allow if there are no logs
}
ems, err := interoptypes.ExecutingMessagesFromLogs(logs)
if err != nil {
log.Debug("Failed to parse executing messages of tx", "txHash", tx.Hash(), "err", err)
return false // default to deny if logs cannot be parsed
}
if len(ems) == 0 {
return true // default to allow if there are no executing messages
}

ctx, cancel := context.WithTimeout(ctx, time.Second*2)
defer cancel()
// check with the supervisor if the transaction should be allowed given the executing messages
return f.checkFn(ctx, ems, interoptypes.Unsafe) == nil
}
Loading