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

Alignment with testinprod/op-erigon part 2 #86

Merged
merged 5 commits into from
Feb 29, 2024
Merged
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
8 changes: 4 additions & 4 deletions cmd/rpcdaemon/cli/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,15 @@ func RootCommand() (*cobra.Command, *httpcfg.HttpCfg) {
rootCmd.PersistentFlags().DurationVar(&cfg.EvmCallTimeout, "rpc.evmtimeout", rpccfg.DefaultEvmCallTimeout, "Maximum amount of time to wait for the answer from EVM call.")
rootCmd.PersistentFlags().IntVar(&cfg.BatchLimit, utils.RpcBatchLimit.Name, utils.RpcBatchLimit.Value, utils.RpcBatchLimit.Usage)
rootCmd.PersistentFlags().IntVar(&cfg.ReturnDataLimit, utils.RpcReturnDataLimit.Name, utils.RpcReturnDataLimit.Value, utils.RpcReturnDataLimit.Usage)
rootCmd.PersistentFlags().BoolVar(&cfg.AllowUnprotectedTxs, utils.AllowUnprotectedTxs.Name, utils.AllowUnprotectedTxs.Value, utils.AllowUnprotectedTxs.Usage)
rootCmd.PersistentFlags().IntVar(&cfg.MaxGetProofRewindBlockCount, utils.RpcMaxGetProofRewindBlockCount.Name, utils.RpcMaxGetProofRewindBlockCount.Value, utils.RpcMaxGetProofRewindBlockCount.Usage)
rootCmd.PersistentFlags().Uint64Var(&cfg.OtsMaxPageSize, utils.OtsSearchMaxCapFlag.Name, utils.OtsSearchMaxCapFlag.Value, utils.OtsSearchMaxCapFlag.Usage)
rootCmd.PersistentFlags().DurationVar(&cfg.RPCSlowLogThreshold, utils.RPCSlowFlag.Name, utils.RPCSlowFlag.Value, utils.RPCSlowFlag.Usage)

rootCmd.PersistentFlags().StringVar(&cfg.RollupSequencerHTTP, utils.RollupSequencerHTTPFlag.Name, "", "HTTP endpoint for the sequencer mempool")
rootCmd.PersistentFlags().StringVar(&cfg.RollupHistoricalRPC, utils.RollupHistoricalRPCFlag.Name, "", "RPC endpoint for historical data")
rootCmd.PersistentFlags().DurationVar(&cfg.RollupHistoricalRPCTimeout, utils.RollupHistoricalRPCTimeoutFlag.Name, rpccfg.DefaultHistoricalRPCTimeout, "Timeout for historical RPC requests")

rootCmd.PersistentFlags().BoolVar(&cfg.AllowUnprotectedTxs, utils.AllowUnprotectedTxs.Name, utils.AllowUnprotectedTxs.Value, utils.AllowUnprotectedTxs.Usage)
rootCmd.PersistentFlags().IntVar(&cfg.MaxGetProofRewindBlockCount, utils.RpcMaxGetProofRewindBlockCount.Name, utils.RpcMaxGetProofRewindBlockCount.Value, utils.RpcMaxGetProofRewindBlockCount.Usage)
rootCmd.PersistentFlags().Uint64Var(&cfg.OtsMaxPageSize, utils.OtsSearchMaxCapFlag.Name, utils.OtsSearchMaxCapFlag.Value, utils.OtsSearchMaxCapFlag.Usage)
rootCmd.PersistentFlags().DurationVar(&cfg.RPCSlowLogThreshold, utils.RPCSlowFlag.Name, utils.RPCSlowFlag.Value, utils.RPCSlowFlag.Usage)
if err := rootCmd.MarkPersistentFlagFilename("rpc.accessList", "json"); err != nil {
panic(err)
}
Expand Down
5 changes: 2 additions & 3 deletions cmd/rpcdaemon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/ledgerwatch/erigon/rpc"
"github.com/ledgerwatch/erigon/turbo/debug"
"github.com/ledgerwatch/erigon/turbo/jsonrpc"
"github.com/ledgerwatch/log/v3"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -41,7 +40,7 @@ func main() {
client, err := rpc.DialContext(ctx, cfg.RollupSequencerHTTP, logger)
cancel()
if err != nil {
log.Error(err.Error())
logger.Error(err.Error())
return nil
}
seqRPCService = client
Expand All @@ -51,7 +50,7 @@ func main() {
client, err := rpc.DialContext(ctx, cfg.RollupHistoricalRPC, logger)
cancel()
if err != nil {
log.Error(err.Error())
logger.Error(err.Error())
return nil
}
historicalRPCService = client
Expand Down
68 changes: 41 additions & 27 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,23 @@ var (
Value: ethconfig.Defaults.GPO.MaxPrice.Int64(),
}

// Rollup Flags
RollupSequencerHTTPFlag = cli.StringFlag{
Name: "rollup.sequencerhttp",
Usage: "HTTP endpoint for the sequencer mempool",
EnvVars: []string{"ROLLUP_SEQUENCER_HTTP_ENDPOINT"},
}
RollupHistoricalRPCFlag = cli.StringFlag{
Name: "rollup.historicalrpc",
Usage: "RPC endpoint for historical data.",
EnvVars: []string{"ROLLUP_HISTORICAL_RPC_ENDPOINT"},
}
RollupHistoricalRPCTimeoutFlag = cli.StringFlag{
Name: "rollup.historicalrpctimeout",
Usage: "Timeout for historical RPC requests.",
Value: "5s",
}

// Metrics flags
MetricsEnabledFlag = cli.BoolFlag{
Name: "metrics",
Expand Down Expand Up @@ -871,22 +888,6 @@ var (
Name: "silkworm.sentry",
Usage: "Enable embedded Silkworm Sentry service",
}
// Rollup Flags
RollupSequencerHTTPFlag = cli.StringFlag{
Name: "rollup.sequencerhttp",
Usage: "HTTP endpoint for the sequencer mempool",
EnvVars: []string{"ROLLUP_SEQUENCER_HTTP_ENDPOINT"},
}
RollupHistoricalRPCFlag = cli.StringFlag{
Name: "rollup.historicalrpc",
Usage: "RPC endpoint for historical data.",
EnvVars: []string{"ROLLUP_HISTORICAL_RPC_ENDPOINT"},
}
RollupHistoricalRPCTimeoutFlag = cli.StringFlag{
Name: "rollup.historicalrpctimeout",
Usage: "Timeout for historical RPC requests.",
Value: "5s",
}

BeaconAPIFlag = cli.BoolFlag{
Name: "beacon.api",
Expand Down Expand Up @@ -1733,6 +1734,14 @@ func SetEthConfig(ctx *cli.Context, nodeConfig *nodecfg.Config, cfg *ethconfig.C
cfg.EthDiscoveryURLs = libcommon.CliString2Array(urls)
}
}
// Only configure sequencer http flag if we're running in verifier mode i.e. --mine is disabled.
if ctx.IsSet(RollupSequencerHTTPFlag.Name) && !ctx.IsSet(MiningEnabledFlag.Name) {
cfg.RollupSequencerHTTP = ctx.String(RollupSequencerHTTPFlag.Name)
}
if ctx.IsSet(RollupHistoricalRPCFlag.Name) {
cfg.RollupHistoricalRPC = ctx.String(RollupHistoricalRPCFlag.Name)
}
cfg.RollupHistoricalRPCTimeout = ctx.Duration(RollupHistoricalRPCTimeoutFlag.Name)
// Override any default configs for hard coded networks.
chain := ctx.String(ChainFlag.Name)

Expand Down Expand Up @@ -1771,25 +1780,39 @@ func SetEthConfig(ctx *cli.Context, nodeConfig *nodecfg.Config, cfg *ethconfig.C
if !ctx.IsSet(MinerGasPriceFlag.Name) {
cfg.Miner.GasPrice = big.NewInt(1)
}
// TODO(jky) Review whether to add OpDevnetChainName
}

if ctx.IsSet(OverrideCancunFlag.Name) {
cfg.OverrideCancunTime = flags.GlobalBig(ctx, OverrideCancunFlag.Name)
cfg.TxPool.OverrideCancunTime = cfg.OverrideCancunTime
}
if ctx.IsSet(OverrideShanghaiTime.Name) {
cfg.OverrideShanghaiTime = flags.GlobalBig(ctx, OverrideShanghaiTime.Name)
cfg.TxPool.OverrideShanghaiTime = cfg.OverrideShanghaiTime
}

if ctx.IsSet(OverrideOptimismCanyonFlag.Name) {
cfg.OverrideOptimismCanyonTime = flags.GlobalBig(ctx, OverrideOptimismCanyonFlag.Name)
cfg.TxPool.OverrideOptimismCanyonTime = cfg.OverrideOptimismCanyonTime
// Shanghai hardfork is included in canyon hardfork
cfg.OverrideShanghaiTime = flags.GlobalBig(ctx, OverrideOptimismCanyonFlag.Name)
cfg.TxPool.OverrideShanghaiTime = cfg.OverrideOptimismCanyonTime
}
if ctx.IsSet(OverrideShanghaiTime.Name) && ctx.IsSet(OverrideOptimismCanyonFlag.Name) {
overrideShanghaiTime := flags.GlobalBig(ctx, OverrideShanghaiTime.Name)
overrideOptimismCanyonTime := flags.GlobalBig(ctx, OverrideOptimismCanyonFlag.Name)
if overrideShanghaiTime.Cmp(overrideOptimismCanyonTime) != 0 {
logger.Warn("Shanghai hardfork time is overridden by optimism canyon hardfork time",
"shanghai", overrideShanghaiTime.String(), "canyon", overrideOptimismCanyonTime.String())
}
}

if ctx.IsSet(OverrideOptimismEcotoneFlag.Name) {
cfg.OverrideOptimismEcotoneTime = flags.GlobalBig(ctx, OverrideOptimismEcotoneFlag.Name)
// Cancun hardfork is included in Ecotone hardfork
cfg.OverrideCancunTime = flags.GlobalBig(ctx, OverrideOptimismEcotoneFlag.Name)
cfg.TxPool.OverrideCancunTime = flags.GlobalBig(ctx, OverrideOptimismEcotoneFlag.Name)
}

if ctx.IsSet(OverrideCancunFlag.Name) && ctx.IsSet(OverrideOptimismEcotoneFlag.Name) {
overrideCancunTime := flags.GlobalBig(ctx, OverrideCancunFlag.Name)
overrideOptimismEcotoneTime := flags.GlobalBig(ctx, OverrideOptimismEcotoneFlag.Name)
Expand All @@ -1798,7 +1821,6 @@ func SetEthConfig(ctx *cli.Context, nodeConfig *nodecfg.Config, cfg *ethconfig.C
"cancun", overrideCancunTime.String(), "ecotone", overrideOptimismEcotoneTime.String())
}
}

if ctx.IsSet(InternalConsensusFlag.Name) && clparams.EmbeddedSupported(cfg.NetworkID) {
cfg.InternalCL = ctx.Bool(InternalConsensusFlag.Name)
}
Expand All @@ -1807,14 +1829,6 @@ func SetEthConfig(ctx *cli.Context, nodeConfig *nodecfg.Config, cfg *ethconfig.C
libkzg.SetTrustedSetupFilePath(ctx.String(TrustedSetupFile.Name))
}

// Rollup params
if ctx.IsSet(RollupSequencerHTTPFlag.Name) && !ctx.IsSet(MiningEnabledFlag.Name) {
cfg.RollupSequencerHTTP = ctx.String(RollupSequencerHTTPFlag.Name)
}
if ctx.IsSet(RollupHistoricalRPCFlag.Name) {
cfg.RollupHistoricalRPC = ctx.String(RollupHistoricalRPCFlag.Name)
}
cfg.RollupHistoricalRPCTimeout = ctx.Duration(RollupHistoricalRPCTimeoutFlag.Name)
if ctx.IsSet(TxPoolGossipDisableFlag.Name) {
cfg.DisableTxPoolGossip = ctx.Bool(TxPoolGossipDisableFlag.Name)
}
Expand Down
24 changes: 15 additions & 9 deletions core/genesis_write.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,25 +107,31 @@ func WriteGenesisBlock(tx kv.RwTx, genesis *types.Genesis, overrideCancunTime, o
if overrideCancunTime != nil {
config.CancunTime = overrideCancunTime
}
if config.IsOptimism() && overrideOptimismEcotoneTime != nil {
config.EcotoneTime = overrideOptimismEcotoneTime
// Cancun hardfork is included in Ecotone hardfork
config.CancunTime = overrideOptimismEcotoneTime
config.ShanghaiTime = overrideOptimismEcotoneTime
if config.IsOptimism() && overrideOptimismCanyonTime != nil {
config.CanyonTime = overrideOptimismCanyonTime
// Shanghai hardfork is included in canyon hardfork
config.ShanghaiTime = overrideOptimismCanyonTime
if config.Optimism.EIP1559DenominatorCanyon == 0 {
logger.Warn("EIP1559DenominatorCanyon set to 0. Overriding to 250 to avoid divide by zero.")
config.Optimism.EIP1559DenominatorCanyon = 250
}
}
if overrideShanghaiTime != nil && config.IsOptimism() && overrideOptimismCanyonTime != nil {
if overrideShanghaiTime.Cmp(overrideOptimismCanyonTime) != 0 {
logger.Warn("Shanghai hardfork time is overridden by optimism canyon time",
"shanghai", overrideShanghaiTime.String(), "canyon", overrideOptimismCanyonTime.String())
}
}
if config.IsOptimism() && overrideOptimismEcotoneTime != nil {
config.EcotoneTime = overrideOptimismEcotoneTime
// Cancun hardfork is included in Ecotone hardfork
config.CancunTime = overrideOptimismEcotoneTime
}
if overrideCancunTime != nil && config.IsOptimism() && overrideOptimismEcotoneTime != nil {
if overrideCancunTime.Cmp(overrideOptimismEcotoneTime) != 0 {
logger.Warn("Cancun hardfork time is overridden by optimism Ecotone time",
"cancun", overrideCancunTime.String(), "ecotone", overrideOptimismEcotoneTime.String())
}
if config.ShanghaiTime.Cmp(overrideOptimismCanyonTime) != 0 {
logger.Warn("Shanghai hardfork time is overridden by optimism Ecotone time",
"shanghai", config.ShanghaiTime.String(), "canyon", overrideOptimismCanyonTime.String())
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ func (st *StateTransition) innerTransitionDb(refunds bool, gasBailout bool) (*Ex
}

// Check that we are post bedrock to be able to create pseudo pre-bedrock blocks (these are pre-bedrock, but don't follow l2 geth rules)
if rules.IsBedrock {
if rules.IsOptimismBedrock {
st.state.AddBalance(params.OptimismBaseFeeRecipient, new(uint256.Int).Mul(uint256.NewInt(st.gasUsed()), st.evm.Context.BaseFee))
if st.evm.Context.L1CostFunc == nil { // Erigon EVM context is used in many unexpected/hacky ways, let's panic if it's misconfigured
panic("missing L1 cost func in block context, please configure l1 cost when using optimism config to run EVM")
Expand Down
6 changes: 6 additions & 0 deletions core/types/gen_genesis.go

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

39 changes: 24 additions & 15 deletions core/types/receipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ type Receipt struct {
// DepositNonce was introduced in Regolith to store the actual nonce used by deposit transactions
// The state transition process ensures this is only set for Regolith deposit transactions.
DepositNonce *uint64 `json:"depositNonce,omitempty"`
// The position of DepositNonce variable must NOT be changed. If changed, cbor decoding will fail
// for the data following previous struct and leading to decoding error(triggering backward imcompatibility).

// Further fields when added must be appended after the last variable. Watch out for cbor.

// Inclusion information: These fields provide information about the inclusion of the
// transaction corresponding to this receipt.
Expand All @@ -92,16 +96,19 @@ type Receipt struct {
}

type receiptMarshaling struct {
Type hexutil.Uint64
PostState hexutility.Bytes
Status hexutil.Uint64
CumulativeGasUsed hexutil.Uint64
GasUsed hexutil.Uint64
BlockNumber *hexutil.Big
TransactionIndex hexutil.Uint
L1Fee *hexutil.Big
L1GasUsed *hexutil.Big
Type hexutil.Uint64
PostState hexutility.Bytes
Status hexutil.Uint64
CumulativeGasUsed hexutil.Uint64
GasUsed hexutil.Uint64
BlockNumber *hexutil.Big
TransactionIndex hexutil.Uint

// Optimism
L1GasPrice *hexutil.Big
L1GasUsed *hexutil.Big
L1Fee *hexutil.Big
FeeScalar *big.Float
DepositNonce *hexutil.Uint64
DepositReceiptVersion *hexutil.Uint64
}
Expand Down Expand Up @@ -543,11 +550,6 @@ func (rs Receipts) EncodeIndex(i int, w *bytes.Buffer) {
if err := rlp.Encode(w, data); err != nil {
panic(err)
}
case BlobTxType:
w.WriteByte(BlobTxType)
if err := rlp.Encode(w, data); err != nil {
panic(err)
}
case DepositTxType:
w.WriteByte(DepositTxType)
if r.DepositReceiptVersion != nil {
Expand All @@ -561,6 +563,11 @@ func (rs Receipts) EncodeIndex(i int, w *bytes.Buffer) {
panic(err)
}
}
case BlobTxType:
w.WriteByte(BlobTxType)
if err := rlp.Encode(w, data); err != nil {
panic(err)
}
default:
// For unsupported types, write nothing. Since this is for
// DeriveSha, the error will be caught matching the derived hash
Expand Down Expand Up @@ -630,7 +637,9 @@ func (r Receipts) DeriveFields(config *chain.Config, hash libcommon.Hash, number
l1Fee, l1GasUsed := costFunc(txs[i].RollupCostData())
r[i].L1Fee = l1Fee.ToBig()
r[i].L1GasUsed = l1GasUsed.ToBig()
r[i].FeeScalar = feeScalar
if feeScalar != nil {
r[i].FeeScalar = feeScalar
}
}
}
return nil
Expand Down
Loading
Loading