Skip to content
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
14 changes: 7 additions & 7 deletions cmd/run/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,23 +170,18 @@ func parseConfigFromFlags() error {
case "flow-testnet":
cfg.FlowNetworkID = flowGo.Testnet
cfg.EVMNetworkID = types.FlowEVMTestNetChainID
cfg.InitCadenceHeight = config.LiveNetworkInitCadenceHeight
cfg.InitCadenceHeight = config.TestnetInitCadenceHeight
case "flow-mainnet":
cfg.FlowNetworkID = flowGo.Mainnet
cfg.EVMNetworkID = types.FlowEVMMainNetChainID
cfg.InitCadenceHeight = config.LiveNetworkInitCadenceHeight
cfg.InitCadenceHeight = config.MainnetInitCadenceHeight
default:
return fmt.Errorf(
"flow network ID: %s not supported, valid values are ('flow-emulator', 'flow-previewnet', 'flow-testnet', 'flow-mainnet')",
flowNetwork,
)
}

// if a specific value was provided use it
if initHeight != 0 {
cfg.InitCadenceHeight = initHeight
}

// configure logging
level, err := zerolog.ParseLevel(logLevel)
if err != nil {
Expand Down Expand Up @@ -296,4 +291,9 @@ func init() {
Cmd.Flags().BoolVar(&cfg.TxBatchMode, "tx-batch-mode", false, "Enable batch transaction submission, to avoid nonce mismatch issues for high-volume EOAs.")
Cmd.Flags().DurationVar(&cfg.TxBatchInterval, "tx-batch-interval", time.Millisecond*1200, "Time interval upon which to submit the transaction batches to the Flow network.")
Cmd.Flags().DurationVar(&cfg.EOAActivityCacheTTL, "eoa-activity-cache-ttl", time.Second*10, "Time interval used to track EOA activity. Tx send more frequently than this interval will be batched. Useful only when batch transaction submission is enabled.")

err := Cmd.Flags().MarkDeprecated("init-cadence-height", "This flag is no longer necessary and will be removed in future version. The initial Cadence height is known for testnet/mainnet and this was only required for fresh deployments of EVM Gateway. Once the DB has been initialized, the latest index Cadence height will be used upon start-up.")
if err != nil {
panic(err)
}
}
24 changes: 17 additions & 7 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,24 @@ import (
"github.com/rs/zerolog"
)

// Default InitCadenceHeight for initializing the database on a local emulator.
// TODO: temporary fix until https://github.com/onflow/flow-go/issues/5481 is
// fixed upstream and released.
const EmulatorInitCadenceHeight = uint64(0)
const (
// Default InitCadenceHeight for initializing the database on a local emulator.
// TODO: temporary fix until https://github.com/onflow/flow-go/issues/5481 is
// fixed upstream and released.
EmulatorInitCadenceHeight = uint64(0)

// Default InitCadenceHeight for initializing the database on a live network.
// We don't use 0 as it has a special meaning to represent latest block in the AN API context.
LiveNetworkInitCadenceHeight = uint64(1)

// Default InitCadenceHeight for initializing the database on a live network.
// We don't use 0 as it has a special meaning to represent latest block in the AN API context.
const LiveNetworkInitCadenceHeight = uint64(1)
// Testnet height at which the `EVM` system contract was first deployed.
// This is the first height at which the EVM state starts.
TestnetInitCadenceHeight = uint64(211176670)

// Mainnet height at which the `EVM` system contract was first deployed.
// This is the first height at which the EVM state starts.
MainnetInitCadenceHeight = uint64(85981134)
)
Comment on lines +17 to +34

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

🧩 Analysis chain

Confirm network init heights; clarify "LiveNetwork" naming

  • Please confirm 211176670 (testnet) and 85981134 (mainnet) are the canonical heights of the first EVM system contract deployment and are immutable across sporks. Consider adding the deployment date/tx link in comments for future maintainers.
  • The name LiveNetworkInitCadenceHeight now effectively maps to previewnet only. Consider renaming to PreviewnetInitCadenceHeight or expand the comment to state its intended/current usage to avoid confusion.

If helpful, I can push a follow-up PR to rename with a deprecation alias to avoid churn.


🌐 Web query:

Please verify the canonical Flow block heights where the EVM system contract was first deployed on testnet and mainnet, and whether previewnet has a known fixed height or should remain 1.

💡 Result:

  • Testnet (Flow Testnet): first EVM/Cadence height = 211,176,670. [1][2]
  • Mainnet (Flow Mainnet): first EVM/Cadence height = 85,981,135. [2][3]
  • PreviewNet: no canonical fixed init height published — PreviewNet is ephemeral/preview-focused (contracts live at the PreviewNet EVM address), so keep init height = 1 (or reindex from 1) unless you have a specific PreviewNet snapshot. [4][2]

Sources:
[1] flow-evm-gateway README (testnet guidance).
[2] Flow docs — EVM Gateway / node-ops (mainnet & testnet init heights).
[3] Flow docs — EVM core-contracts (PreviewNet EVM address / PreviewNet context).


Fix mainnet init height; confirm PreviewNet usage and rename LiveNetwork var

  • Testnet: canonical init height = 211,176,670 — matches TestnetInitCadenceHeight (no change).
  • Mainnet: canonical init height = 85,981,135 but code uses 85,981,134 (off-by-one). Update MainnetInitCadenceHeight → uint64(85981135) in config/config.go (lines 17–34).
  • PreviewNet / LiveNetwork: PreviewNet has no canonical fixed init height — keeping init = 1 is correct for preview/ephemeral networks. Rename LiveNetworkInitCadenceHeight → PreviewnetInitCadenceHeight or add an explicit comment clarifying it maps to PreviewNet; add a deprecation alias if renaming.
  • Add deployment tx/date (and link) to the testnet/mainnet constant comments for future maintainers.
🤖 Prompt for AI Agents
In config/config.go around lines 17 to 34, MainnetInitCadenceHeight is
off-by-one (currently 85981134) — change it to uint64(85981135); rename
LiveNetworkInitCadenceHeight to PreviewnetInitCadenceHeight (or add a new
PreviewnetInitCadenceHeight constant set to uint64(1)) and provide a deprecated
alias LiveNetworkInitCadenceHeight = PreviewnetInitCadenceHeight to preserve
backwards compat, update comments to clarify this maps to PreviewNet/ephemeral
networks, and update the Testnet/Mainnet constant comments to include the
deployment tx/date and a link to the source for future maintainers.


type TxStateValidation string

Expand Down