refactor: remove all SubnetEVM references and backward compatibility

- Rename plugin/evm/upgrade/subnetevm package to feewindow
- Rename SubnetEVMTimestamp to EVMTimestamp (JSON: evmTimestamp)
- Rename IsSubnetEVM method to IsEVM
- Rename SubnetEVMDefaultChainConfig to EVMDefaultChainConfig
- Rename TestSubnetEVMChainConfig to TestEVMChainConfig
- Rename TestPreSubnetEVMChainConfig to TestPreEVMChainConfig
- Rename ethclient/subnetevmclient to ethclient/evmclient
- Update VM factory ID from "subnetevm" to "evm"
- Remove all backward compatibility aliases
- Update all documentation and comments

Breaking change: This removes all SubnetEVM naming - only "EVM" is supported.
No backward compatibility maintained as per user requirement.
This commit is contained in:
2025-12-21 10:26:52 -08:00
parent 37795e19e3
commit 162e4f6668
77 changed files with 632 additions and 698 deletions
-237
View File
@@ -1,237 +0,0 @@
# https://golangci-lint.run/usage/configuration/
version: "2"
run:
# If set we pass it to "go list -mod={option}". From "go help modules":
# If invoked with -mod=readonly, the go command is disallowed from the implicit
# automatic updating of go.mod described above. Instead, it fails when any changes
# to go.mod are needed. This setting is most useful to check that go.mod does
# not need updates, such as in a continuous integration and testing system.
# If invoked with -mod=vendor, the go command assumes that the vendor
# directory holds the correct copies of dependencies and ignores
# the dependency descriptions in go.mod.
#
# Allowed values: readonly|vendor|mod
# By default, it isn't set.
modules-download-mode: readonly
# Include non-test files tagged as test-only.
# Context: https://github.com/ava-labs/avalanchego/pull/3173
build-tags:
- test
issues:
# Make issues output unique by line.
uniq-by-line: false
# Maximum issues count per one linter.
max-issues-per-linter: 0
# Maximum count of issues with the same text.
max-same-issues: 0
formatters:
enable:
- gci
- gofmt
- gofumpt
settings:
gci:
sections:
- standard
- default
- blank
- prefix(github.com/ava-labs/subnet-evm)
- alias
- dot
custom-order: true
exclusions:
generated: lax
# Avalanche linters should be added incrementally
linters:
default: none
enable:
- asciicheck
- bodyclose
- copyloopvar
# - depguard
# - errcheck
- errorlint
# - forbidigo
- goconst
# - gocritic
- goprintffuncname
# - gosec
- govet
- importas
- ineffassign
- misspell
- nakedret
# - nilerr
- noctx
- nolintlint
- perfsprint
# - prealloc
# - predeclared
- revive
- spancheck
# - staticcheck
- tagalign
# - testifylint
- unconvert
- unparam
- unused
- usestdlibvars
- whitespace
settings:
depguard:
rules:
packages:
deny:
- pkg: container/list
desc: github.com/ava-labs/avalanchego/utils/linked should be used instead.
- pkg: github.com/golang/mock/gomock
desc: go.uber.org/mock/gomock should be used instead.
- pkg: github.com/stretchr/testify/assert
desc: github.com/stretchr/testify/require should be used instead.
- pkg: io/ioutil
desc: io/ioutil is deprecated. Use package io or os instead.
errorlint:
# Check for plain type assertions and type switches.
asserts: false
# Check for plain error comparisons.
comparison: false
forbidigo:
# Forbid the following identifiers (list of regexp).
forbid:
- pattern: require\.Error$(# ErrorIs should be used instead)?
- pattern: require\.ErrorContains$(# ErrorIs should be used instead)?
- pattern: require\.EqualValues$(# Equal should be used instead)?
- pattern: require\.NotEqualValues$(# NotEqual should be used instead)?
- pattern: ^(t|b|tb|f)\.(Fatal|Fatalf|Error|Errorf)$(# the require library should be used instead)?
- pattern: ^sort\.(Slice|Strings)$(# the slices package should be used instead)?
# Exclude godoc examples from forbidigo checks.
exclude-godoc-examples: false
gosec:
excludes:
- G107 # Url provided to HTTP request as taint input https://securego.io/docs/rules/g107
- G115 # TODO(marun) Enable this ruleset in a follow-up PR
importas:
# Do not allow unaliased imports of aliased packages.
no-unaliased: false
# Do not allow non-required aliases.
no-extra-aliases: false
# List of aliases
alias:
- pkg: github.com/ava-labs/avalanchego/utils/math
alias: safemath
- pkg: github.com/ava-labs/avalanchego/utils/json
alias: avajson
revive:
rules:
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bool-literal-in-expr
- name: bool-literal-in-expr
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#early-return
- name: early-return
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-lines
- name: empty-lines
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#redundant-import-alias
- name: redundant-import-alias
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#string-format
- name: string-format
disabled: false
arguments:
- - b.Logf[0]
- /.*%.*/
- no format directive, use b.Log instead
- - fmt.Errorf[0]
- /.*%.*/
- no format directive, use errors.New instead
- - fmt.Fprintf[1]
- /.*%.*/
- no format directive, use fmt.Fprint instead
- - fmt.Printf[0]
- /.*%.*/
- no format directive, use fmt.Print instead
- - fmt.Sprintf[0]
- /.*%.*/
- no format directive, use fmt.Sprint instead
- - log.Fatalf[0]
- /.*%.*/
- no format directive, use log.Fatal instead
- - log.Printf[0]
- /.*%.*/
- no format directive, use log.Print instead
- - t.Logf[0]
- /.*%.*/
- no format directive, use t.Log instead
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#struct-tag
- name: struct-tag
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-naming
- name: unexported-naming
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unhandled-error
- name: unhandled-error
# prefer the errcheck linter since it can be disabled directly with nolint directive
# but revive's disable directive (e.g. //revive:disable:unhandled-error) is not
# supported when run under golangci_lint
disabled: true
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-parameter
- name: unused-parameter
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-receiver
- name: unused-receiver
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#useless-break
- name: useless-break
disabled: false
spancheck:
# https://github.com/jjti/go-spancheck#checks
checks:
- end
staticcheck:
# https://staticcheck.io/docs/options#checks
checks:
- all
- -SA6002A # Storing non-pointer values in sync.Pool allocates memory
- -SA1019 # Using a deprecated function, variable, constant or field
- -QF1008 # Unnecessary embedded expressions
tagalign:
align: true
sort: true
order:
- serialize
strict: true
testifylint:
# Enable all checkers (https://github.com/Antonboom/testifylint#checkers).
# Default: false
enable-all: true
# Disable checkers by name
# (in addition to default
# suite-thelper
# ).
disable:
- go-require
- float-compare
unused:
# Mark all struct fields that have been written to as used.
# Default: true
field-writes-are-uses: false
# Treat IncDec statement (e.g. `i++` or `i--`) as both read and write operation instead of just write.
# Default: false
post-statements-are-reads: true
# Mark all local variables as used.
# default: true
local-variables-are-used: false
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
+229 -58
View File
@@ -1,66 +1,237 @@
version: 2
# https://golangci-lint.run/usage/configuration/
version: "2"
run:
timeout: 10m
tests: true
build-tags:
- all
exclude-dirs:
- tests/antithesis
exclude-files:
- ".*\\.pb\\.go$"
# If set we pass it to "go list -mod={option}". From "go help modules":
# If invoked with -mod=readonly, the go command is disallowed from the implicit
# automatic updating of go.mod described above. Instead, it fails when any changes
# to go.mod are needed. This setting is most useful to check that go.mod does
# not need updates, such as in a continuous integration and testing system.
# If invoked with -mod=vendor, the go command assumes that the vendor
# directory holds the correct copies of dependencies and ignores
# the dependency descriptions in go.mod.
#
# Allowed values: readonly|vendor|mod
# By default, it isn't set.
modules-download-mode: readonly
linters:
enable:
- govet
- ineffassign
- misspell
- gosec
- staticcheck
disable:
- errcheck # Too many legacy unchecked errors
- unused # Legacy ethereum code has many unused vars/funcs
- unconvert # Legacy ethereum code has unnecessary conversions
settings:
gosec:
excludes:
- G103 # Use of unsafe (legacy ethereum code)
- G104 # Errors unhandled (legacy code)
- G107 # Potential HTTP request made with variable url
- G108 # Profiling endpoint exposed (debug tools)
- G112 # Slowloris attack (legacy http server config)
- G114 # Use of net/http serve without timeouts (legacy)
- G115 # Integer overflow conversions (legacy ethereum code)
- G204 # Subprocess launched with variable (test commands)
- G301 # Directory permissions (build/test tools)
- G302 # File permissions
- G304 # File inclusion via variable (tool scripts)
- G306 # WriteFile permissions (tool outputs)
- G404 # Use of weak random number generator
- G602 # Slice bounds (legacy ethereum code)
staticcheck:
checks:
- all
- -QF* # Quick fixes suggestions (not errors)
- -S1040 # Type assertion to same type (legacy patterns)
- -SA1019 # Deprecated functions (legacy ethereum code uses them)
- -SA4006 # Unused value (legacy patterns)
- -SA4009 # Argument overwritten (legacy patterns)
- -SA4010 # Unused result of append (legacy code patterns)
- -SA6002 # Argument should be pointer-like (sync.Pool patterns)
- -SA9003 # Empty branch (legacy code patterns)
- -ST* # All style checks disabled (legacy ethereum code)
# Include non-test files tagged as test-only.
# Context: https://github.com/ava-labs/avalanchego/pull/3173
build-tags:
- test
issues:
# Make issues output unique by line.
uniq-by-line: false
# Maximum issues count per one linter.
max-issues-per-linter: 0
# Maximum count of issues with the same text.
max-same-issues: 0
formatters:
enable:
- gci
- gofmt
- goimports
- gofumpt
settings:
gci:
sections:
- standard
- default
- blank
- prefix(github.com/luxfi/evm)
- alias
- dot
custom-order: true
exclusions:
generated: lax
issues:
exclude-rules:
- path: _test\.go
# Avalanche linters should be added incrementally
linters:
- gosec
- path: tests/
linters:
- gosec
default: none
enable:
- asciicheck
- bodyclose
- copyloopvar
# - depguard
# - errcheck
- errorlint
# - forbidigo
- goconst
# - gocritic
- goprintffuncname
# - gosec
- govet
- importas
- ineffassign
- misspell
- nakedret
# - nilerr
- noctx
- nolintlint
- perfsprint
# - prealloc
# - predeclared
- revive
- spancheck
# - staticcheck
- tagalign
# - testifylint
- unconvert
- unparam
- unused
- usestdlibvars
- whitespace
settings:
depguard:
rules:
packages:
deny:
- pkg: container/list
desc: github.com/ava-labs/avalanchego/utils/linked should be used instead.
- pkg: github.com/golang/mock/gomock
desc: go.uber.org/mock/gomock should be used instead.
- pkg: github.com/stretchr/testify/assert
desc: github.com/stretchr/testify/require should be used instead.
- pkg: io/ioutil
desc: io/ioutil is deprecated. Use package io or os instead.
errorlint:
# Check for plain type assertions and type switches.
asserts: false
# Check for plain error comparisons.
comparison: false
forbidigo:
# Forbid the following identifiers (list of regexp).
forbid:
- pattern: require\.Error$(# ErrorIs should be used instead)?
- pattern: require\.ErrorContains$(# ErrorIs should be used instead)?
- pattern: require\.EqualValues$(# Equal should be used instead)?
- pattern: require\.NotEqualValues$(# NotEqual should be used instead)?
- pattern: ^(t|b|tb|f)\.(Fatal|Fatalf|Error|Errorf)$(# the require library should be used instead)?
- pattern: ^sort\.(Slice|Strings)$(# the slices package should be used instead)?
# Exclude godoc examples from forbidigo checks.
exclude-godoc-examples: false
gosec:
excludes:
- G107 # Url provided to HTTP request as taint input https://securego.io/docs/rules/g107
- G115 # TODO(marun) Enable this ruleset in a follow-up PR
importas:
# Do not allow unaliased imports of aliased packages.
no-unaliased: false
# Do not allow non-required aliases.
no-extra-aliases: false
# List of aliases
alias:
- pkg: github.com/ava-labs/avalanchego/utils/math
alias: safemath
- pkg: github.com/ava-labs/avalanchego/utils/json
alias: avajson
revive:
rules:
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bool-literal-in-expr
- name: bool-literal-in-expr
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#early-return
- name: early-return
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-lines
- name: empty-lines
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#redundant-import-alias
- name: redundant-import-alias
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#string-format
- name: string-format
disabled: false
arguments:
- - b.Logf[0]
- /.*%.*/
- no format directive, use b.Log instead
- - fmt.Errorf[0]
- /.*%.*/
- no format directive, use errors.New instead
- - fmt.Fprintf[1]
- /.*%.*/
- no format directive, use fmt.Fprint instead
- - fmt.Printf[0]
- /.*%.*/
- no format directive, use fmt.Print instead
- - fmt.Sprintf[0]
- /.*%.*/
- no format directive, use fmt.Sprint instead
- - log.Fatalf[0]
- /.*%.*/
- no format directive, use log.Fatal instead
- - log.Printf[0]
- /.*%.*/
- no format directive, use log.Print instead
- - t.Logf[0]
- /.*%.*/
- no format directive, use t.Log instead
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#struct-tag
- name: struct-tag
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-naming
- name: unexported-naming
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unhandled-error
- name: unhandled-error
# prefer the errcheck linter since it can be disabled directly with nolint directive
# but revive's disable directive (e.g. //revive:disable:unhandled-error) is not
# supported when run under golangci_lint
disabled: true
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-parameter
- name: unused-parameter
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-receiver
- name: unused-receiver
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#useless-break
- name: useless-break
disabled: false
spancheck:
# https://github.com/jjti/go-spancheck#checks
checks:
- end
staticcheck:
# https://staticcheck.io/docs/options#checks
checks:
- all
- -SA6002A # Storing non-pointer values in sync.Pool allocates memory
- -SA1019 # Using a deprecated function, variable, constant or field
- -QF1008 # Unnecessary embedded expressions
tagalign:
align: true
sort: true
order:
- serialize
strict: true
testifylint:
# Enable all checkers (https://github.com/Antonboom/testifylint#checkers).
# Default: false
enable-all: true
# Disable checkers by name
# (in addition to default
# suite-thelper
# ).
disable:
- go-require
- float-compare
unused:
# Mark all struct fields that have been written to as used.
# Default: true
field-writes-are-uses: false
# Treat IncDec statement (e.g. `i++` or `i--`) as both read and write operation instead of just write.
# Default: false
post-statements-are-reads: true
# Mark all local variables as used.
# default: true
local-variables-are-used: false
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
+8 -8
View File
@@ -1,7 +1,7 @@
# LLM.md - Lux EVM Module
## Project Overview
Lux EVM (formerly Subnet-EVM) is the Ethereum Virtual Machine implementation for Lux subnets. This module provides EVM compatibility for the Lux network.
Lux EVM (formerly EVM) is the Ethereum Virtual Machine implementation for Lux subnets. This module provides EVM compatibility for the Lux network.
## CRITICAL VERSION REQUIREMENTS
**ALWAYS use these Lux-specific versions:**
@@ -151,7 +151,7 @@ go test ./... # Will work after build issues are resolved
- Tests will pass after build issues are resolved
## Important Notes
- This module is actively being migrated from subnet-evm
- This module is actively being migrated from evm
- Maintains backwards compatibility with existing Lux subnets
- Uses single validator POA for development (k=1 consensus)
- Major refactoring needed to reconcile ID type differences between packages
@@ -246,7 +246,7 @@ Successfully implemented and verified readonly database access for legacy Pebble
- **Size**: 7.1GB (751 files)
- **Blockchain ID**: `dnmzhuf6poM6PUNQCe7MWWfBdTJEnddhHRNXz2x7H6qSmyBEJ`
- **Chain ID**: 96369
- **Purpose**: Legacy subnet-evm data for regenesis export
- **Purpose**: Legacy evm data for regenesis export
### Correct Migration Approach
@@ -558,11 +558,11 @@ This analysis examines the deployment process for Zoo and SPC subnets, identifyi
### 1. Root Cause: Zoo RPC 404
**Diagnosis:** The subnet RPC endpoint returns 404 because the SubnetEVM plugin is not properly initialized or the blockchain is not registered with the node.
**Diagnosis:** The subnet RPC endpoint returns 404 because the EVM plugin is not properly initialized or the blockchain is not registered with the node.
**Key Findings:**
1. **Plugin Registration**: SubnetEVM must be registered as a plugin with the node. The C-Chain uses `cchainvm` which is built into the node, but Zoo/SPC require the external `evm` plugin.
1. **Plugin Registration**: EVM must be registered as a plugin with the node. The C-Chain uses `cchainvm` which is built into the node, but Zoo/SPC require the external `evm` plugin.
2. **Blockchain ID Mismatch**: The RPC path uses the blockchain ID (e.g., `ext/bc/<blockchain-id>/rpc`). If the subnet is not tracking the correct blockchain ID, RPC returns 404.
@@ -634,7 +634,7 @@ func (bc *BlockChain) HasState(hash common.Hash) bool {
3. **Continuous state**: C-Chain has been running since network genesis - full state trie exists
4. **State scheme consistency**: Uses the same state scheme as the node's defaults
**Zoo/SPC (SubnetEVM plugin):**
**Zoo/SPC (EVM plugin):**
1. **External plugin**: Loaded dynamically, separate initialization path
2. **Fresh genesis**: Genesis is created from the subnet's genesis.json at deployment time
@@ -652,7 +652,7 @@ bc.stateCache = state.NewDatabaseWithNodeDB(bc.db, bc.triedb)
// - bc.triedb: the trie database
// For C-Chain: triedb already has the state from continuous operation
// For SubnetEVM: triedb only has genesis state from fresh Commit()
// For EVM: triedb only has genesis state from fresh Commit()
```
---
@@ -783,7 +783,7 @@ cat > /tmp/zoo-genesis.json << 'EOF'
{
"config": {
"chainId": 200200,
"subnetEVMTimestamp": 0,
"evmTimestamp": 0,
"durangoTimestamp": 0,
"feeConfig": {
"gasLimit": 12000000,
+5 -5
View File
@@ -56,7 +56,7 @@ The Subnet EVM is compatible with almost all Ethereum tooling, including [Remix]
## Block Format
To support these changes, there have been a number of changes to the SubnetEVM block format compared to what exists on the C-Chain and Ethereum. Here we list the changes to the block format as compared to Ethereum.
To support these changes, there have been a number of changes to the EVM block format compared to what exists on the C-Chain and Ethereum. Here we list the changes to the block format as compared to Ethereum.
### Block Header
@@ -65,7 +65,7 @@ To support these changes, there have been a number of changes to the SubnetEVM b
## Create an EVM Subnet on a Local Network
### Clone Subnet-evm
### Clone EVM
First install Go 1.23.9 or later. Follow the instructions [here](https://go.dev/doc/install). You can verify by running `go version`.
@@ -87,12 +87,12 @@ This will clone and checkout to `master` branch.
### Run Local Network
To run a local network, it is recommended to use the [lux-cli](https://github.com/luxfi/lux-cli#lux-cli) to set up an instance of Subnet-EVM on a local Lux Network.
To run a local network, it is recommended to use the [lux-cli](https://github.com/luxfi/lux-cli#lux-cli) to set up an instance of EVM on a local Lux Network.
There are two options when using the Lux-CLI:
1. Use an official Subnet-EVM release: <https://docs.lux.network/subnets/build-first-subnet>
2. Build and deploy a locally built (and optionally modified) version of Subnet-EVM: <https://docs.lux.network/subnets/create-custom-subnet>
1. Use an official EVM release: <https://docs.lux.network/subnets/build-first-subnet>
2. Build and deploy a locally built (and optionally modified) version of EVM: <https://docs.lux.network/subnets/create-custom-subnet>
## Releasing
+2 -2
View File
@@ -34,7 +34,7 @@ The plugin version is **updated** to 41 and is compatible with Luxd version v1.1
### Breaking changes
- Removed static API handler and functions: `subnetevm.decodeGenesis`, `subnetevm.buildGenesis`
- Removed static API handler and functions: `evm.decodeGenesis`, `evm.buildGenesis`
### Updates
@@ -140,7 +140,7 @@ The plugin version is unchanged at 37 and is compatible with Luxd versions v1.11
### Updates
* Added Standalone DB creation in chain data directory (`~/.luxd/chainData/{chain-ID}/db/`). Subnet-EVM will create seperate databases for chains by default if there is no accepted blocks previously
* Added Standalone DB creation in chain data directory (`~/.luxd/chainData/{chain-ID}/db/`). EVM will create seperate databases for chains by default if there is no accepted blocks previously
* Refactored Warp Backend to support new payload types
* Refactored TrieDB reference root configuration
* Bumped Luxd dependency to v1.11.12
+2 -2
View File
@@ -38,7 +38,7 @@ import (
"github.com/luxfi/evm/core/state"
"github.com/luxfi/evm/params"
customheader "github.com/luxfi/evm/plugin/evm/header"
"github.com/luxfi/evm/plugin/evm/upgrade/subnetevm"
"github.com/luxfi/evm/plugin/evm/upgrade/feewindow"
"github.com/luxfi/evm/tests"
"github.com/luxfi/geth/common"
"github.com/luxfi/geth/common/hexutil"
@@ -231,7 +231,7 @@ func applyLondonChecks(env *stEnv, chainConfig *params.ChainConfig) error {
BaseFee: env.ParentBaseFee,
GasUsed: env.ParentGasUsed,
GasLimit: env.ParentGasLimit,
Extra: make([]byte, subnetevm.WindowSize), // TODO: consider passing extra through env
Extra: make([]byte, feewindow.WindowSize), // TODO: consider passing extra through env
}
feeConfig := params.DefaultFeeConfig
if env.MinBaseFee != nil {
+2 -2
View File
@@ -154,7 +154,7 @@ func runCmd(ctx *cli.Context) error {
initialGas = genesisConfig.GasLimit
}
} else {
genesisConfig.Config = params.TestSubnetEVMChainConfig
genesisConfig.Config = params.TestEVMChainConfig
}
db := rawdb.NewMemoryDatabase()
@@ -240,7 +240,7 @@ func runCmd(ctx *cli.Context) error {
if chainConfig != nil {
runtimeConfig.ChainConfig = chainConfig
} else {
runtimeConfig.ChainConfig = params.SubnetEVMDefaultChainConfig // NOTE: Replaced AllEthashProtocolChanges with SubnetEVMDefaultChainConfig here
runtimeConfig.ChainConfig = params.EVMDefaultChainConfig // NOTE: Replaced AllEthashProtocolChanges with EVMDefaultChainConfig here
}
var hexInput []byte
+1 -1
View File
@@ -260,7 +260,7 @@ func TestT8n(t *testing.T) {
// expExitCode: 3,
// },
// NOTE: this test was modified to test a non-trivial calculation
// of dynamic Subnet-EVM fees (instead of the original EIP-1559
// of dynamic EVM fees (instead of the original EIP-1559
// [misc.CalcBaseFee] calculation).
{ // Test base fee calculation
base: "./testdata/25",
+1 -1
View File
@@ -28,7 +28,7 @@ This should give the following output:
v0.1.0
```
To run the load simulator, you must first start an EVM based network. The load simulator works on both the C-Chain and Subnet-EVM, so we will start a single node network and run the load simulator on the C-Chain.
To run the load simulator, you must first start an EVM based network. The load simulator works on both the C-Chain and EVM, so we will start a single node network and run the load simulator on the C-Chain.
To start a single node network, follow the instructions from the Luxd [README](https://github.com/luxfi/luxd#building-luxd) to build from source.
+5 -5
View File
@@ -4,7 +4,7 @@ Disclaimer: the consensus package in evm is a complete misnomer.
The consensus package in go-ethereum handles block validation and specifically handles validating the PoW portion of consensus - thus the name.
Since Luxd handles consensus for Subnet-EVM, Subnet-EVM is just the VM, but we keep the consensus package in place to handle part of the block verification process.
Since Luxd handles consensus for EVM, EVM is just the VM, but we keep the consensus package in place to handle part of the block verification process.
## Block Verification
@@ -12,17 +12,17 @@ The dummy consensus engine is responsible for performing verification on the hea
## Dynamic Fees
Subnet-EVM includes a dynamic fee algorithm based off of (EIP-1559)[https://eips.ethereum.org/EIPS/eip-1559]. This introduces a field to the block type called `BaseFee`. The Base Fee sets a minimum gas price for any transaction to be included in the block. For example, a transaction with a gas price of 49 gwei, will be invalid to include in a block with a base fee of 50 gwei.
EVM includes a dynamic fee algorithm based off of (EIP-1559)[https://eips.ethereum.org/EIPS/eip-1559]. This introduces a field to the block type called `BaseFee`. The Base Fee sets a minimum gas price for any transaction to be included in the block. For example, a transaction with a gas price of 49 gwei, will be invalid to include in a block with a base fee of 50 gwei.
The dynamic fee algorithm aims to adjust the base fee to handle network congestion. Subnet-EVM sets a target utilization on the network, and the dynamic fee algorithm adjusts the base fee accordingly. If the network operates above the target utilization, the dynamic fee algorithm will increase the base fee to make utilizing the network more expensive and bring overall utilization down. If the network operates below the target utilization, the dynamic fee algorithm will decrease the base fee to make it cheaper to use the network.
The dynamic fee algorithm aims to adjust the base fee to handle network congestion. EVM sets a target utilization on the network, and the dynamic fee algorithm adjusts the base fee accordingly. If the network operates above the target utilization, the dynamic fee algorithm will increase the base fee to make utilizing the network more expensive and bring overall utilization down. If the network operates below the target utilization, the dynamic fee algorithm will decrease the base fee to make it cheaper to use the network.
- EIP-1559 is intended for Ethereum where a block is produced roughly every 10s
- The dynamic fee algorithm needs to handle the case that the network quiesces and there are no blocks for a long period of time
- Since Subnet-EVM produces blocks at a different cadence, it adapts EIP-1559 to sum the amount of gas consumed within a 10-second interval instead of using only the amount of gas consumed in the parent block
- Since EVM produces blocks at a different cadence, it adapts EIP-1559 to sum the amount of gas consumed within a 10-second interval instead of using only the amount of gas consumed in the parent block
## Consensus Engine Callbacks
The consensus engine is called while blocks are being both built and processed and Subnet-EVM adds callback functions into the dummy consensus engine to insert its own logic into these stages.
The consensus engine is called while blocks are being both built and processed and EVM adds callback functions into the dummy consensus engine to insert its own logic into these stages.
### FinalizeAndAssemble
+2 -2
View File
@@ -366,7 +366,7 @@ func (eng *DummyEngine) Finalize(chain consensus.ChainHeaderReader, block *types
if !utils.BigEqual(blockGasCost, expectedBlockGasCost) {
return fmt.Errorf("invalid blockGasCost: have %d, want %d", blockGasCost, expectedBlockGasCost)
}
if config.IsSubnetEVM(timestamp) {
if config.IsEVM(timestamp) {
// Verify the block fee was paid.
if err := eng.verifyBlockFee(
block.BaseFee(),
@@ -403,7 +403,7 @@ func (eng *DummyEngine) FinalizeAndAssemble(chain consensus.ChainHeaderReader, h
header.Time,
),
}
if config.IsSubnetEVM(header.Time) {
if config.IsEVM(header.Time) {
// Verify that this block covers the block fee.
if err := eng.verifyBlockFee(
header.BaseFee,
+4 -4
View File
@@ -48,7 +48,7 @@ For more information about precompiles see [evm precompiles](https://github.com/
Hardhat uses `hardhat.config.js` as the configuration file. You can define tasks, networks, compilers and more in that file. For more information see [here](https://hardhat.org/config/).
In Subnet-EVM, we provide a pre-configured file [hardhat.config.ts](https://github.com/luxfi/evm/blob/master/contracts/hardhat.config.ts).
In EVM, we provide a pre-configured file [hardhat.config.ts](https://github.com/luxfi/evm/blob/master/contracts/hardhat.config.ts).
The HardHat config file includes a single network configuration: `local`. `local` defaults to using the following values for the RPC URL and the Chain ID:
@@ -57,7 +57,7 @@ var local_rpc_uri = process.env.RPC_URI || "http://127.0.0.1:9650/ext/bc/C/rpc";
var local_chain_id = process.env.CHAIN_ID || 99999;
```
You can use this network configuration by providing the environment variables and specifying the `--network` flag, as Subnet-EVM does in its testing suite:
You can use this network configuration by providing the environment variables and specifying the `--network` flag, as EVM does in its testing suite:
```bash
RPC_URI=http://127.0.0.1:9650/ext/bc/28N1Tv5CZziQ3FKCaXmo8xtxoFtuoVA6NvZykAT5MtGjF4JkGs/rpc CHAIN_ID=77777 npx hardhat test --network local
@@ -101,8 +101,8 @@ You can define custom hardhat tasks in [tasks.ts](https://github.com/luxfi/lux-s
## Tests
Tests are written for a local network which runs a Subnet-EVM Blockchain.
Tests are written for a local network which runs a EVM Blockchain.
E.g `RPC_URI=http://127.0.0.1:9650/ext/bc/28N1Tv5CZziQ3FKCaXmo8xtxoFtuoVA6NvZykAT5MtGjF4JkGs/rpc CHAIN_ID=77777 npx hardhat test --network local`.
Subnet-EVM must activate any precompiles used in the test in the genesis.
EVM must activate any precompiles used in the test in the genesis.
+1 -1
View File
@@ -10,7 +10,7 @@ When the consensus engine verifies blocks as they are ready to be issued into co
InsertBlockManual verifies the block, inserts it into the state manager to track the merkle trie for the block, and adds it to the canonical chain if it extends the currently preferred chain.
Subnet-EVM adds functions for Accept and Reject, which take care of marking a block as finalized and performing garbage collection where possible.
EVM adds functions for Accept and Reject, which take care of marking a block as finalized and performing garbage collection where possible.
The consensus engine can also call `SetPreference` on a VM to tell the VM that a specific block is preferred by the consensus engine to be accepted. This triggers a call to `reorg` the blockchain and set the newly preferred block as the preferred chain.
+3 -3
View File
@@ -362,13 +362,13 @@ func (bc *BlockChain) SubscribeAcceptedTransactionEvent(ch chan<- NewTxsEvent) e
}
// GetFeeConfigAt returns the fee configuration and the last changed block number at [parent].
// If Subnet-EVM is not activated, returns default fee config and nil block number.
// If EVM is not activated, returns default fee config and nil block number.
// If FeeManager is activated at [parent], returns the fee config in the precompile contract state.
// Otherwise returns the fee config in the chain config.
// Assumes that a valid configuration is stored when the precompile is activated.
func (bc *BlockChain) GetFeeConfigAt(parent *types.Header) (commontype.FeeConfig, *big.Int, error) {
config := params.GetExtra(bc.Config())
if !config.IsSubnetEVM(parent.Time) {
if !config.IsEVM(parent.Time) {
return params.DefaultFeeConfig, nil, nil
}
if !config.IsPrecompileEnabled(feemanager.ContractAddress, parent.Time) {
@@ -405,7 +405,7 @@ func (bc *BlockChain) GetFeeConfigAt(parent *types.Header) (commontype.FeeConfig
// If fee recipients are allowed, returns true in the second return value.
func (bc *BlockChain) GetCoinbaseAt(parent *types.Header) (common.Address, bool, error) {
configExtra := params.GetExtra(bc.Config())
if !configExtra.IsSubnetEVM(parent.Time) {
if !configExtra.IsEVM(parent.Time) {
return constants.BlackholeAddr, false, nil
}
+1 -1
View File
@@ -678,7 +678,7 @@ func TestCreateThenDeletePreByzantium(t *testing.T) {
t.Skip("Pre-byzantium chain config not supported in Lux EVM (all forks enabled from genesis)")
// We want to use pre-byzantium rules where we have intermediate state roots
// between transactions.
config := *params.TestPreSubnetEVMChainConfig
config := *params.TestPreEVMChainConfig
config.ByzantiumBlock = nil
config.ConstantinopleBlock = nil
config.PetersburgBlock = nil
+2 -2
View File
@@ -133,7 +133,7 @@ func (b *BlockGen) addTx(bc ChainContext, vmConfig vm.Config, tx *types.Transact
blockContext := NewEVMBlockContext(b.header, bc, &b.header.Coinbase)
// If BaseFee is still nil, set it from the chain config
if blockContext.BaseFee == nil && b.cm.config != nil {
if params.GetExtra(b.cm.config).IsSubnetEVM(b.header.Time) {
if params.GetExtra(b.cm.config).IsEVM(b.header.Time) {
blockContext.BaseFee = new(big.Int).Set(params.GetExtra(b.cm.config).FeeConfig.MinBaseFee)
}
}
@@ -404,7 +404,7 @@ func (cm *chainMaker) makeHeader(parent *types.Block, gap uint64, state *state.S
if err != nil {
panic(err)
}
// BaseFee is nil when neither London nor SubnetEVM forks are active.
// BaseFee is nil when neither London nor EVM forks are active.
// This is the correct behavior - pre-EIP1559 blocks should have no base fee.
header := &types.Header{
+2 -2
View File
@@ -51,8 +51,8 @@ func NewEVMBlockContext(header *types.Header, chain ChainContext, author *common
baseFee := header.BaseFee
if baseFee == nil && chain != nil && chain.Config() != nil {
// If BaseFee is nil, check if EIP-1559 is enabled and set a default
if params.GetExtra(chain.Config()).IsSubnetEVM(header.Time) {
// SubnetEVM requires base fee
if params.GetExtra(chain.Config()).IsEVM(header.Time) {
// EVM requires base fee
baseFee = new(big.Int).Set(params.GetExtra(chain.Config()).FeeConfig.MinBaseFee)
}
}
+1 -1
View File
@@ -359,7 +359,7 @@ func (g *Genesis) toBlock(db ethdb.Database, triedb *triedb.Database) *types.Blo
if conf := g.Config; conf != nil {
num := new(big.Int).SetUint64(g.Number)
confExtra := params.GetExtra(conf)
if confExtra.IsSubnetEVM(g.Timestamp) {
if confExtra.IsEVM(g.Timestamp) {
if g.BaseFee != nil {
head.BaseFee = g.BaseFee
} else {
+1 -1
View File
@@ -46,7 +46,7 @@ func TestGenesisEthUpgrades(t *testing.T) {
MinBaseFee: big.NewInt(1),
},
NetworkUpgrades: extras.NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(0),
EVMTimestamp: utils.NewUint64(0),
},
},
)
+5 -5
View File
@@ -85,8 +85,8 @@ func TestSetupGenesis(t *testing.T) {
}
func testSetupGenesis(t *testing.T, scheme string) {
preSubnetConfig := params.Copy(params.TestPreSubnetEVMChainConfig)
params.GetExtra(preSubnetConfig).SubnetEVMTimestamp = utils.NewUint64(100)
preSubnetConfig := params.Copy(params.TestPreEVMChainConfig)
params.GetExtra(preSubnetConfig).EVMTimestamp = utils.NewUint64(100)
var (
customg = Genesis{
Config: preSubnetConfig,
@@ -101,7 +101,7 @@ func testSetupGenesis(t *testing.T, scheme string) {
customghash := customg.ToBlock().Hash()
rollbackpreSubnetConfig := params.Copy(preSubnetConfig)
params.GetExtra(rollbackpreSubnetConfig).SubnetEVMTimestamp = utils.NewUint64(90)
params.GetExtra(rollbackpreSubnetConfig).EVMTimestamp = utils.NewUint64(90)
oldcustomg.Config = rollbackpreSubnetConfig
oldcustomghash := oldcustomg.ToBlock().Hash()
@@ -160,8 +160,8 @@ func testSetupGenesis(t *testing.T, scheme string) {
{
name: "config upgrade preserves stored genesis",
fn: func(db ethdb.Database) (*params.ChainConfig, common.Hash, error) {
// Commit the 'old' genesis block with SubnetEVM transition at 90.
// Advance to block #4, past the SubnetEVM transition block of customg.
// Commit the 'old' genesis block with EVM transition at 90.
// Advance to block #4, past the EVM transition block of customg.
tdb := triedb.NewDatabase(db, newDbConfig(t, rawdb.HashScheme))
genesis, err := oldcustomg.Commit(db, tdb)
if err != nil {
+1 -1
View File
@@ -46,7 +46,7 @@ func TestBadTxAllowListBlock(t *testing.T) {
&extras.ChainConfig{
FeeConfig: params.DefaultFeeConfig,
NetworkUpgrades: extras.NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(0),
EVMTimestamp: utils.NewUint64(0),
},
GenesisPrecompiles: extras.Precompiles{
txallowlist.ConfigKey: txallowlist.NewConfig(utils.NewUint64(0), nil, nil, nil),
+1 -1
View File
@@ -394,7 +394,7 @@ func GenerateBadBlock(parent *types.Block, engine consensus.Engine, txs types.Tr
BaseFee: baseFee,
}
if params.GetExtra(config).IsSubnetEVM(header.Time) {
if params.GetExtra(config).IsEVM(header.Time) {
headerExtra := customtypes.GetHeaderExtra(header)
headerExtra.BlockGasCost = big.NewInt(0)
}
+5 -5
View File
@@ -403,8 +403,8 @@ func (st *StateTransition) preCheck() error {
if st.evm.Config.NoBaseFee {
// If NoBaseFee is set, skip this check
skipCheck = true
} else if st.evm.ChainConfig() != nil && params.GetExtra(st.evm.ChainConfig()).IsSubnetEVM(st.evm.Context.Time) {
// Set default BaseFee for SubnetEVM
} else if st.evm.ChainConfig() != nil && params.GetExtra(st.evm.ChainConfig()).IsEVM(st.evm.Context.Time) {
// Set default BaseFee for EVM
st.evm.Context.BaseFee = new(big.Int).Set(params.GetExtra(st.evm.ChainConfig()).FeeConfig.MinBaseFee)
} else {
return fmt.Errorf("BaseFee is nil in EVM context")
@@ -543,7 +543,7 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
if overflow {
return nil, ErrGasUintOverflow
}
gasRefund := st.refundGas(rulesExtra.IsSubnetEVM)
gasRefund := st.refundGas(rulesExtra.IsEVM)
fee := new(uint256.Int).SetUint64(st.gasUsed())
fee.Mul(fee, price)
st.state.AddBalance(st.evm.Context.Coinbase, fee, tracing.BalanceIncreaseRewardTransactionFee)
@@ -556,10 +556,10 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
}, nil
}
func (st *StateTransition) refundGas(subnetEVM bool) uint64 {
func (st *StateTransition) refundGas(isEVM bool) uint64 {
var refund uint64
// Inspired by: https://gist.github.com/holiman/460f952716a74eeb9ab358bb1836d821#gistcomment-3642048
if !subnetEVM {
if !isEVM {
// Apply refund counter, capped to half of the used gas.
refund = st.gasUsed() / 2
if refund > st.state.GetRefund() {
+6 -6
View File
@@ -50,7 +50,7 @@ import (
"github.com/luxfi/evm/params"
"github.com/luxfi/evm/plugin/evm/header"
"github.com/luxfi/evm/plugin/evm/upgrade/legacy"
"github.com/luxfi/evm/plugin/evm/upgrade/subnetevm"
"github.com/luxfi/evm/plugin/evm/upgrade/feewindow"
"github.com/luxfi/geth/common"
"github.com/luxfi/geth/consensus/misc/eip4844"
"github.com/luxfi/geth/core/rawdb"
@@ -79,9 +79,9 @@ func init() {
params.GetExtra(testChainConfig).FeeConfig = commontype.ValidTestFeeConfig
params.GetExtra(testChainConfig).FeeConfig.MinBaseFee = new(big.Int).SetUint64(1)
// Set SubnetEVMTimestamp to enable base fee calculation
params.GetExtra(testChainConfig).SubnetEVMTimestamp = new(uint64)
*params.GetExtra(testChainConfig).SubnetEVMTimestamp = 0
// Set EVMTimestamp to enable base fee calculation
params.GetExtra(testChainConfig).EVMTimestamp = new(uint64)
*params.GetExtra(testChainConfig).EVMTimestamp = 0
testChainConfig.CancunTime = new(uint64)
*testChainConfig.CancunTime = uint64(time.Now().Unix())
@@ -136,7 +136,7 @@ func (bc *testBlockChain) CurrentBlock() *types.Header {
GasLimit: gasLimit,
GasUsed: 0,
BaseFee: mid,
Extra: make([]byte, subnetevm.WindowSize),
Extra: make([]byte, feewindow.WindowSize),
}
config := params.GetExtra(bc.config)
baseFee, err := header.BaseFee(
@@ -184,7 +184,7 @@ func (bc *testBlockChain) CurrentBlock() *types.Header {
GasLimit: gasLimit,
BaseFee: baseFee,
ExcessBlobGas: &excessBlobGas,
Extra: make([]byte, subnetevm.WindowSize),
Extra: make([]byte, feewindow.WindowSize),
}
}
+6 -6
View File
@@ -82,7 +82,7 @@ var (
var (
evictionInterval = time.Minute // Time interval to check for evictable transactions
statsReportInterval = 8 * time.Second // Time interval to report transaction pool stats
baseFeeUpdateInterval = 10 * time.Second // Time interval at which to schedule a base fee update for the tx pool after SubnetEVM is enabled
baseFeeUpdateInterval = 10 * time.Second // Time interval at which to schedule a base fee update for the tx pool after EVM is enabled
)
// ====== If resolving merge conflicts ======
@@ -1792,14 +1792,14 @@ func (pool *LegacyPool) demoteUnexecutables() {
}
func (pool *LegacyPool) startPeriodicFeeUpdate() {
subnetEVMTimestamp := params.GetExtra(pool.chainconfig).SubnetEVMTimestamp
if subnetEVMTimestamp == nil {
evmTimestamp := params.GetExtra(pool.chainconfig).EVMTimestamp
if evmTimestamp == nil {
return
}
// Call updateBaseFee here to ensure that there is not a [baseFeeUpdateInterval] delay
// when starting up in ApricotPhase3 before the base fee is updated.
if time.Now().After(utils.Uint64ToTime(subnetEVMTimestamp)) {
if time.Now().After(utils.Uint64ToTime(evmTimestamp)) {
pool.updateBaseFee()
}
@@ -1811,9 +1811,9 @@ func (pool *LegacyPool) periodicBaseFeeUpdate() {
defer pool.wg.Done()
// Sleep until its time to start the periodic base fee update or the tx pool is shutting down
subnetEVMTime := utils.Uint64ToTime(params.GetExtra(pool.chainconfig).SubnetEVMTimestamp)
evmTime := utils.Uint64ToTime(params.GetExtra(pool.chainconfig).EVMTimestamp)
select {
case <-time.After(time.Until(subnetEVMTime)):
case <-time.After(time.Until(evmTime)):
case <-pool.generalShutdownChan:
return // Return early if shutting down
}
+1 -1
View File
@@ -89,7 +89,7 @@ func setDefaults(cfg *Config) {
},
&extras.ChainConfig{
NetworkUpgrades: extras.NetworkUpgrades{
SubnetEVMTimestamp: new(uint64),
EVMTimestamp: new(uint64),
},
FeeConfig: extras.DefaultFeeConfig,
},
+2 -2
View File
@@ -3,7 +3,7 @@
## When to release
- When [Luxd](https://github.com/luxfi/luxd/releases) increases its RPC chain VM protocol version, which you can also check in [its `version/compatibility.json`](https://github.com/luxfi/luxd/blob/master/version/compatibility.json)
- When Subnet-EVM needs to release a new feature or bug fix.
- When EVM needs to release a new feature or bug fix.
## Procedure
@@ -173,7 +173,7 @@ Once the tag is created, you need to test it on the Testnet testnet both locally
git clone git@github.com:luxfi/luxd.git
```
6. Checkout correct Luxd version, the version should match the one used in Subnet-EVM `go.mod` file
6. Checkout correct Luxd version, the version should match the one used in EVM `go.mod` file
```bash
cd luxd
+1 -1
View File
@@ -197,7 +197,7 @@ func New(
if !config.SkipBcVersionCheck {
if bcVersion != nil && *bcVersion > core.BlockChainVersion {
return nil, fmt.Errorf("database version is v%d, Subnet-EVM %s only supports v%d", *bcVersion, params.VersionWithMeta, core.BlockChainVersion)
return nil, fmt.Errorf("database version is v%d, EVM %s only supports v%d", *bcVersion, params.VersionWithMeta, core.BlockChainVersion)
} else if bcVersion == nil || *bcVersion < core.BlockChainVersion {
log.Warn("Upgrade blockchain database version", "from", dbVer, "to", core.BlockChainVersion)
rawdb.WriteDatabaseVersion(chainDb, core.BlockChainVersion)
+1 -1
View File
@@ -27,7 +27,7 @@ func makeTestHeader(number int64, parentHash common.Hash, gasUsed uint64) *types
if parentHash != (common.Hash{}) {
header.ParentHash = parentHash
}
// Set header extras with BlockGasCost for SubnetEVM compatibility
// Set header extras with BlockGasCost for EVM compatibility
customtypes.SetHeaderExtra(header, &customtypes.HeaderExtra{
BlockGasCost: big.NewInt(0), // Use 0 for test blocks
})
+2 -2
View File
@@ -210,7 +210,7 @@ func NewOracle(backend OracleBackend, config Config) (*Oracle, error) {
}
// EstimateBaseFee returns an estimate of what the base fee will be on a block
// produced at the current time. If SubnetEVM has not been activated, it may
// produced at the current time. If EVM has not been activated, it may
// return a nil value and a nil error.
func (oracle *Oracle) EstimateBaseFee(ctx context.Context) (*big.Int, error) {
return oracle.estimateNextBaseFee(ctx)
@@ -258,7 +258,7 @@ func (oracle *Oracle) SuggestPrice(ctx context.Context) (*big.Int, error) {
return nil, err
}
if nextBaseFee == nil {
// This occurs if Subnet-EVM has not been scheduled yet
// This occurs if EVM has not been scheduled yet
return tip, nil
}
+1 -1
View File
@@ -353,7 +353,7 @@ func TestSuggestTipCapMinGas(t *testing.T) {
// Regression test to ensure that SuggestPrice does not panic with activation of Subnet EVM
// Note: support for gas estimation without activated hard forks has been deprecated, but we still
// ensure that the call does not panic.
func TestSuggestGasPriceSubnetEVM(t *testing.T) {
func TestSuggestGasPriceEVM(t *testing.T) {
config := Config{
Blocks: 20,
Percentile: 60,
@@ -25,8 +25,8 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
// Package subnetevmclient provides an RPC client for evm-specific APIs.
package subnetevmclient
// Package evmclient provides an RPC client for evm-specific APIs.
package evmclient
import (
"context"
+4 -4
View File
@@ -94,10 +94,10 @@ type Backend struct {
//
// A simulated backend always uses chainID 1337.
func NewBackend(alloc types.GenesisAlloc, options ...func(nodeConf *node.Config, ethConf *ethconfig.Config)) *Backend {
// Use TestSubnetEVMChainConfig which doesn't have Shanghai/Cancun enabled.
// Use TestEVMChainConfig which doesn't have Shanghai/Cancun enabled.
// This is needed for backward compatibility with legacy contract bytecode
// that uses pre-Shanghai opcodes (e.g., SELFDESTRUCT, certain JUMP patterns).
chainConfig := params.Copy(params.TestSubnetEVMChainConfig)
chainConfig := params.Copy(params.TestEVMChainConfig)
chainConfig.ChainID = big.NewInt(1337)
// Create the default configurations for the outer node shell and the Ethereum
@@ -106,10 +106,10 @@ func NewBackend(alloc types.GenesisAlloc, options ...func(nodeConf *node.Config,
ethConf := ethconfig.DefaultConfig
// Initialize the extras with proper defaults for SubnetEVM without Shanghai/Cancun
// Initialize the extras with proper defaults for EVM without Shanghai/Cancun
extra := &extras.ChainConfig{
FeeConfig: extras.TestFeeConfig, // Use TestFeeConfig with minimal fees for test compatibility
NetworkUpgrades: extras.TestSubnetEVMChainConfig.NetworkUpgrades,
NetworkUpgrades: extras.TestEVMChainConfig.NetworkUpgrades,
}
params.SetExtra(chainConfig, extra)
+2 -2
View File
@@ -1326,7 +1326,7 @@ func RPCMarshalBlock(block *types.Block, inclTx bool, fullTx bool, config *param
// a `BlockchainAPI`.
func (s *BlockChainAPI) rpcMarshalHeader(ctx context.Context, header *types.Header) map[string]interface{} {
fields := RPCMarshalHeader(header)
// Note: Subnet-EVM enforces that the difficulty of a block is always 1, such that the total difficulty of a block
// Note: EVM enforces that the difficulty of a block is always 1, such that the total difficulty of a block
// will be equivalent to its height.
fields["totalDifficulty"] = (*hexutil.Big)(header.Number)
return fields
@@ -1337,7 +1337,7 @@ func (s *BlockChainAPI) rpcMarshalHeader(ctx context.Context, header *types.Head
func (s *BlockChainAPI) rpcMarshalBlock(ctx context.Context, b *types.Block, inclTx bool, fullTx bool) (map[string]interface{}, error) {
fields := RPCMarshalBlock(b, inclTx, fullTx, s.b.ChainConfig())
if inclTx {
// Note: Subnet-EVM enforces that the difficulty of a block is always 1, such that the total difficulty of a block
// Note: EVM enforces that the difficulty of a block is always 1, such that the total difficulty of a block
// will be equivalent to its height.
fields["totalDifficulty"] = (*hexutil.Big)(b.Number())
}
+4 -4
View File
@@ -847,8 +847,8 @@ func TestEstimateGas(t *testing.T) {
func TestCall(t *testing.T) {
// Test re-enabled for mainnet deployment
// Enable BLOBHASH opcode in Cancun
// Use TestPreSubnetEVMChainConfig which doesn't have SubnetEVM at time 0
cfg := *params.TestPreSubnetEVMChainConfig
// Use TestPreEVMChainConfig which doesn't have EVM at time 0
cfg := *params.TestPreEVMChainConfig
cfg.ShanghaiTime = utils.NewUint64(0)
cfg.CancunTime = utils.NewUint64(0)
// Add blob schedule config for Cancun
@@ -1638,7 +1638,7 @@ func TestRPCMarshalBlock(t *testing.T) {
}
for i, tc := range testSuite {
resp := RPCMarshalBlock(block, tc.inclTx, tc.fullTx, params.TestSubnetEVMChainConfig)
resp := RPCMarshalBlock(block, tc.inclTx, tc.fullTx, params.TestEVMChainConfig)
out, err := json.Marshal(resp)
if err != nil {
t.Errorf("test %d: json marshal error: %v", i, err)
@@ -1911,7 +1911,7 @@ func TestRPCGetBlockOrHeader(t *testing.T) {
func setupReceiptBackend(t *testing.T, genBlocks int) (*testBackend, []common.Hash) {
// Use params.TestChainConfig directly - it already has Shanghai/Cancun enabled at epoch 0
// Copying the config loses the Extra interface connection needed for SubnetEVM
// Copying the config loses the Extra interface connection needed for EVM
var (
acc1Key, _ = crypto.HexToECDSA("8a1f9a8f95be41cd7ccb6168179afb4504aefe388d1e14474d32c45c72ce7b7a")
acc2Key, _ = crypto.HexToECDSA("49a7b37aa6f6645917e7b807e9d1c00d4fa71f18343b0d4122a4d2df64dd6fee")
+3 -3
View File
@@ -243,7 +243,7 @@ func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b feeBackend) e
// Now attempt to fill in default value depending on whether London is active or not.
if isLondon {
// London is active, set maxPriorityFeePerGas and maxFeePerGas.
if err := args.setSubnetEVMFeeDefault(ctx, head, b); err != nil {
if err := args.setEVMFeeDefault(ctx, head, b); err != nil {
return err
}
} else {
@@ -275,8 +275,8 @@ func (args *TransactionArgs) setCancunFeeDefaults(ctx context.Context, head *typ
return nil
}
// setSubnetEVMFeeDefault fills in reasonable default fee values for unspecified fields.
func (args *TransactionArgs) setSubnetEVMFeeDefault(ctx context.Context, head *types.Header, b feeBackend) error {
// setEVMFeeDefault fills in reasonable default fee values for unspecified fields.
func (args *TransactionArgs) setEVMFeeDefault(ctx context.Context, head *types.Header, b feeBackend) error {
// Set maxPriorityFeePerGas if it is missing.
if args.MaxPriorityFeePerGas == nil {
tip, err := b.SuggestGasTipCap(ctx)
+1 -1
View File
@@ -2,7 +2,7 @@
The miner is a package inherited from go-ethereum with a large amount of functionality stripped out since it is not needed in evm.
In go-ethereum, the miner needs to perform PoW in order to try and produce the next block. Since Lux does not rely on PoW in any way, the miner within Subnet-EVM is only used to produce blocks on demand.
In go-ethereum, the miner needs to perform PoW in order to try and produce the next block. Since Lux does not rely on PoW in any way, the miner within EVM is only used to produce blocks on demand.
All of the async functionality has been stripped out in favor of a much lighter weight miner implementation which takes a backend that supplies the blockchain and transaction pool and exposes the functionality to produce a new block with the contents of the transaction pool.
+1 -1
View File
@@ -57,7 +57,7 @@ type web3API struct {
// ClientVersion returns the node name
func (s *web3API) ClientVersion() string {
return s.stack.config.SubnetEVMVersion
return s.stack.config.EVMVersion
}
// Sha3 applies the ethereum sha3 implementation on the input.
+1 -1
View File
@@ -67,7 +67,7 @@ type Config struct {
// BatchResponseMaxSize is the maximum number of bytes returned from a batched rpc call.
BatchResponseMaxSize int `toml:",omitempty"`
SubnetEVMVersion string
EVMVersion string
}
// ExtRPCEnabled returns the indicator whether node enables the external
+8 -8
View File
@@ -48,9 +48,9 @@ var (
)
var (
// SubnetEVMDefaultConfig is the default configuration
// EVMDefaultConfig is the default configuration
// without any network upgrades.
SubnetEVMDefaultChainConfig = WithExtra(
EVMDefaultChainConfig = WithExtra(
&ChainConfig{
ChainID: DefaultChainID,
@@ -66,7 +66,7 @@ var (
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
},
extras.SubnetEVMDefaultChainConfig,
extras.EVMDefaultChainConfig,
)
TestChainConfig = WithExtra(
@@ -98,7 +98,7 @@ var (
extras.TestChainConfig,
)
TestPreSubnetEVMChainConfig = WithExtra(
TestPreEVMChainConfig = WithExtra(
&ChainConfig{
ChainID: big.NewInt(1337),
HomesteadBlock: big.NewInt(0),
@@ -112,7 +112,7 @@ var (
MuirGlacierBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
// Add Shanghai/Cancun so CheckCompatible test checks SubnetEVM fork, not Shanghai
// Add Shanghai/Cancun so CheckCompatible test checks EVM fork, not Shanghai
ShanghaiTime: utils.TimeToNewUint64(InitiallyActiveTime),
CancunTime: utils.TimeToNewUint64(InitiallyActiveTime),
BlobScheduleConfig: &ethparams.BlobScheduleConfig{
@@ -123,10 +123,10 @@ var (
},
},
},
extras.TestPreSubnetEVMChainConfig,
extras.TestPreEVMChainConfig,
)
TestSubnetEVMChainConfig = WithExtra(
TestEVMChainConfig = WithExtra(
&ChainConfig{
ChainID: big.NewInt(1337),
HomesteadBlock: big.NewInt(0),
@@ -141,7 +141,7 @@ var (
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
},
extras.TestSubnetEVMChainConfig,
extras.TestEVMChainConfig,
)
TestDurangoChainConfig = WithExtra(
+4 -4
View File
@@ -60,7 +60,7 @@ func getPrecompileAddress(config precompileconfig.Config) common.Address {
// RulesExtra represents extra EVM rules - part of libevm integration
type RulesExtra struct {
IsSubnetEVM bool
IsEVM bool
IsDurango bool
IsEtna bool
IsFortuna bool
@@ -314,7 +314,7 @@ func GetRulesExtra(rules Rules) RulesExtra {
if chainConfig == nil {
// No context found, return default RulesExtra
rulesExtra := RulesExtra{
IsSubnetEVM: true,
IsEVM: true,
IsDurango: true,
IsEtna: true,
IsFortuna: true,
@@ -323,7 +323,7 @@ func GetRulesExtra(rules Rules) RulesExtra {
Predicaters: make(map[common.Address]precompileconfig.Predicater),
}
rulesExtra.LuxRules = extras.LuxRules{
IsSubnetEVM: true,
IsEVM: true,
IsDurango: true,
IsEtna: true,
IsFortuna: true,
@@ -338,7 +338,7 @@ func GetRulesExtra(rules Rules) RulesExtra {
// Build RulesExtra from extras.Rules
rulesExtra := RulesExtra{
IsSubnetEVM: extrasRules.IsSubnetEVM,
IsEVM: extrasRules.IsEVM,
IsDurango: extrasRules.IsDurango,
IsEtna: extrasRules.IsEtna,
IsFortuna: extrasRules.IsFortuna,
+2 -2
View File
@@ -9,8 +9,8 @@ func TestLocalNetworkChainID(t *testing.T) {
// Test that all test configurations use chain ID 1337 for local networks
testConfigs := map[string]*ChainConfig{
"TestChainConfig": TestChainConfig,
"TestPreSubnetEVMChainConfig": TestPreSubnetEVMChainConfig,
"TestSubnetEVMChainConfig": TestSubnetEVMChainConfig,
"TestPreEVMChainConfig": TestPreEVMChainConfig,
"TestEVMChainConfig": TestEVMChainConfig,
"TestDurangoChainConfig": TestDurangoChainConfig,
"TestEtnaChainConfig": TestEtnaChainConfig,
"TestFortunaChainConfig": TestFortunaChainConfig,
+21 -21
View File
@@ -128,22 +128,22 @@ func TestCheckCompatible(t *testing.T) {
RewindToBlock: 30,
},
},
// Note: SubnetEVM fork compatibility is checked in extras.CheckCompatible,
// Note: EVM fork compatibility is checked in extras.CheckCompatible,
// not in the base ChainConfig.CheckCompatible. These tests now expect nil
// since the base Ethereum forks are compatible.
{
stored: TestChainConfig,
new: TestPreSubnetEVMChainConfig,
new: TestPreEVMChainConfig,
headBlock: 0,
headTimestamp: 0,
wantErr: nil, // Base ChainConfig doesn't check SubnetEVM forks
wantErr: nil, // Base ChainConfig doesn't check EVM forks
},
{
stored: TestChainConfig,
new: TestPreSubnetEVMChainConfig,
new: TestPreEVMChainConfig,
headBlock: 10,
headTimestamp: 100,
wantErr: nil, // Base ChainConfig doesn't check SubnetEVM forks
wantErr: nil, // Base ChainConfig doesn't check EVM forks
},
}
@@ -161,7 +161,7 @@ func TestConfigRules(t *testing.T) {
&ChainConfig{},
&extras.ChainConfig{
NetworkUpgrades: extras.NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(500),
EVMTimestamp: utils.NewUint64(500),
},
},
)
@@ -170,21 +170,21 @@ func TestConfigRules(t *testing.T) {
extra := GetExtra(c)
var stamp uint64
// Test that SubnetEVM is not active at timestamp 0
if extra.IsSubnetEVM(stamp) {
t.Errorf("expected timestamp %v to not be SubnetEVM", stamp)
// Test that EVM is not active at timestamp 0
if extra.IsEVM(stamp) {
t.Errorf("expected timestamp %v to not be EVM", stamp)
}
stamp = 500
// Test that SubnetEVM is active at timestamp 500
if !extra.IsSubnetEVM(stamp) {
t.Errorf("expected timestamp %v to be SubnetEVM", stamp)
// Test that EVM is active at timestamp 500
if !extra.IsEVM(stamp) {
t.Errorf("expected timestamp %v to be EVM", stamp)
}
stamp = math.MaxInt64
// Test that SubnetEVM is active at max timestamp
if !extra.IsSubnetEVM(stamp) {
t.Errorf("expected timestamp %v to be SubnetEVM", stamp)
// Test that EVM is active at max timestamp
if !extra.IsEVM(stamp) {
t.Errorf("expected timestamp %v to be EVM", stamp)
}
}
@@ -300,7 +300,7 @@ func TestExtrasMarshaling(t *testing.T) {
FeeConfig: DefaultFeeConfig,
AllowFeeRecipients: false,
NetworkUpgrades: extras.NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(0),
EVMTimestamp: utils.NewUint64(0),
DurangoTimestamp: utils.NewUint64(0),
},
GenesisPrecompiles: extras.Precompiles{},
@@ -316,7 +316,7 @@ func TestExtrasMarshaling(t *testing.T) {
require.NoError(t, err)
require.Contains(t, decoded, "feeConfig")
require.Contains(t, decoded, "subnetEVMTimestamp")
require.Contains(t, decoded, "evmTimestamp")
require.Contains(t, decoded, "durangoTimestamp")
feeConfig := decoded["feeConfig"].(map[string]interface{})
@@ -326,7 +326,7 @@ func TestExtrasMarshaling(t *testing.T) {
func TestChainConfigMarshalWithUpgrades(t *testing.T) {
// Test re-enabled for mainnet deployment
// Create ChainConfig with extras
// Note: SubnetEVMTimestamp and DurangoTimestamp must be set on ChainConfig
// Note: EVMTimestamp and DurangoTimestamp must be set on ChainConfig
// to match extras, since they will be populated during unmarshal
chainConfig := &ChainConfig{
ChainID: big.NewInt(1),
@@ -339,7 +339,7 @@ func TestChainConfigMarshalWithUpgrades(t *testing.T) {
PetersburgBlock: big.NewInt(0),
IstanbulBlock: big.NewInt(0),
MuirGlacierBlock: big.NewInt(0),
SubnetEVMTimestamp: utils.NewUint64(0),
EVMTimestamp: utils.NewUint64(0),
DurangoTimestamp: utils.NewUint64(0),
}
@@ -347,7 +347,7 @@ func TestChainConfigMarshalWithUpgrades(t *testing.T) {
FeeConfig: DefaultFeeConfig,
AllowFeeRecipients: false,
NetworkUpgrades: extras.NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(0),
EVMTimestamp: utils.NewUint64(0),
DurangoTimestamp: utils.NewUint64(0),
},
GenesisPrecompiles: extras.Precompiles{},
@@ -394,7 +394,7 @@ func TestChainConfigMarshalWithUpgrades(t *testing.T) {
"istanbulBlock": 0,
"muirGlacierBlock": 0,
"depositContractAddress": "0x0000000000000000000000000000000000000000",
"subnetEVMTimestamp": 0,
"evmTimestamp": 0,
"durangoTimestamp": 0,
"upgrades": {
"precompileUpgrades": [
+9 -9
View File
@@ -49,7 +49,7 @@ var (
BlockGasCostStep: big.NewInt(200_000),
}
SubnetEVMDefaultChainConfig = &ChainConfig{
EVMDefaultChainConfig = &ChainConfig{
FeeConfig: DefaultFeeConfig,
NetworkUpgrades: GetDefaultNetworkUpgrades(), // TODO: upgrade.GetConfig seems to be removed
GenesisPrecompiles: Precompiles{},
@@ -61,18 +61,18 @@ var (
GenesisPrecompiles: Precompiles{},
}
TestPreSubnetEVMChainConfig = copyAndSet(TestChainConfig, func(c *ChainConfig) {
TestPreEVMChainConfig = copyAndSet(TestChainConfig, func(c *ChainConfig) {
c.NetworkUpgrades = NetworkUpgrades{
SubnetEVMTimestamp: utils.TimeToNewUint64(UnscheduledActivationTime),
EVMTimestamp: utils.TimeToNewUint64(UnscheduledActivationTime),
DurangoTimestamp: utils.TimeToNewUint64(UnscheduledActivationTime),
EtnaTimestamp: utils.TimeToNewUint64(UnscheduledActivationTime),
FortunaTimestamp: utils.TimeToNewUint64(UnscheduledActivationTime),
}
})
TestSubnetEVMChainConfig = copyAndSet(TestChainConfig, func(c *ChainConfig) {
TestEVMChainConfig = copyAndSet(TestChainConfig, func(c *ChainConfig) {
c.NetworkUpgrades = NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(0),
EVMTimestamp: utils.NewUint64(0),
DurangoTimestamp: utils.TimeToNewUint64(UnscheduledActivationTime),
EtnaTimestamp: utils.TimeToNewUint64(UnscheduledActivationTime),
FortunaTimestamp: utils.TimeToNewUint64(UnscheduledActivationTime),
@@ -81,7 +81,7 @@ var (
TestDurangoChainConfig = copyAndSet(TestChainConfig, func(c *ChainConfig) {
c.NetworkUpgrades = NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(0),
EVMTimestamp: utils.NewUint64(0),
DurangoTimestamp: utils.TimeToNewUint64(InitiallyActiveTime),
EtnaTimestamp: utils.TimeToNewUint64(UnscheduledActivationTime),
FortunaTimestamp: utils.TimeToNewUint64(UnscheduledActivationTime),
@@ -90,7 +90,7 @@ var (
TestEtnaChainConfig = copyAndSet(TestChainConfig, func(c *ChainConfig) {
c.NetworkUpgrades = NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(0),
EVMTimestamp: utils.NewUint64(0),
DurangoTimestamp: utils.TimeToNewUint64(InitiallyActiveTime),
EtnaTimestamp: utils.TimeToNewUint64(InitiallyActiveTime),
FortunaTimestamp: utils.TimeToNewUint64(UnscheduledActivationTime),
@@ -99,7 +99,7 @@ var (
TestFortunaChainConfig = copyAndSet(TestChainConfig, func(c *ChainConfig) {
c.NetworkUpgrades = NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(0),
EVMTimestamp: utils.NewUint64(0),
DurangoTimestamp: utils.TimeToNewUint64(InitiallyActiveTime),
EtnaTimestamp: utils.TimeToNewUint64(InitiallyActiveTime),
FortunaTimestamp: utils.TimeToNewUint64(InitiallyActiveTime),
@@ -108,7 +108,7 @@ var (
TestGraniteChainConfig = copyAndSet(TestChainConfig, func(c *ChainConfig) {
c.NetworkUpgrades = NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(0),
EVMTimestamp: utils.NewUint64(0),
DurangoTimestamp: utils.TimeToNewUint64(InitiallyActiveTime),
EtnaTimestamp: utils.TimeToNewUint64(InitiallyActiveTime),
FortunaTimestamp: utils.TimeToNewUint64(InitiallyActiveTime),
+7 -7
View File
@@ -29,7 +29,7 @@ func TestChainConfigDescription(t *testing.T) {
"empty": {
config: &ChainConfig{},
wantRegex: `Lux Upgrades \(timestamp based\)\:
- SubnetEVM Timestamp: ( )+@nil( )+\(https:\/\/github\.com\/luxfi\/node\/releases\/tag\/v1\.10\.0\)
- EVM Timestamp: ( )+@nil( )+\(https:\/\/github\.com\/luxfi\/node\/releases\/tag\/v1\.10\.0\)
( - .+Timestamp: .+\n)+
Upgrade Config: {}
Fee Config: {}
@@ -39,7 +39,7 @@ $`,
"set": {
config: &ChainConfig{
NetworkUpgrades: NetworkUpgrades{
SubnetEVMTimestamp: pointer(uint64(1)),
EVMTimestamp: pointer(uint64(1)),
DurangoTimestamp: pointer(uint64(2)),
EtnaTimestamp: pointer(uint64(3)),
FortunaTimestamp: pointer(uint64(4)),
@@ -57,7 +57,7 @@ $`,
AllowFeeRecipients: true,
UpgradeConfig: UpgradeConfig{
NetworkUpgradeOverrides: &NetworkUpgrades{
SubnetEVMTimestamp: pointer(uint64(13)),
EVMTimestamp: pointer(uint64(13)),
},
StateUpgrades: []StateUpgrade{
{
@@ -72,9 +72,9 @@ $`,
},
},
wantRegex: `Lux Upgrades \(timestamp based\)\:
- SubnetEVM Timestamp: ( )+@1( )+\(https:\/\/github\.com\/luxfi\/node\/releases\/tag\/v1\.10\.0\)
- EVM Timestamp: ( )+@1( )+\(https:\/\/github\.com\/luxfi\/node\/releases\/tag\/v1\.10\.0\)
( - .+Timestamp: .+\n)+
Upgrade Config: {"networkUpgradeOverrides":{"subnetEVMTimestamp":13},"stateUpgrades":\[{"blockTimestamp":14,"accounts":{"0x0f00000000000000000000000000000000000000":{"code":"0x10"}}}\]}
Upgrade Config: {"networkUpgradeOverrides":{"evmTimestamp":13},"stateUpgrades":\[{"blockTimestamp":14,"accounts":{"0x0f00000000000000000000000000000000000000":{"code":"0x10"}}}\]}
Fee Config: {"gasLimit":5,"targetBlockRate":6,"minBaseFee":7,"targetGas":8,"baseFeeChangeDenominator":9,"minBlockGasCost":10,"maxBlockGasCost":11,"blockGasCostStep":12}
Allow Fee Recipients: true
$`,
@@ -145,7 +145,7 @@ func TestChainConfigVerify(t *testing.T) {
config: ChainConfig{
FeeConfig: validFeeConfig,
NetworkUpgrades: NetworkUpgrades{
SubnetEVMTimestamp: nil,
EVMTimestamp: nil,
},
LuxContext: LuxContext{ConsensusCtx: utilstest.NewTestConsensusContext(t)},
},
@@ -155,7 +155,7 @@ func TestChainConfigVerify(t *testing.T) {
config: ChainConfig{
FeeConfig: validFeeConfig,
NetworkUpgrades: NetworkUpgrades{
SubnetEVMTimestamp: pointer(uint64(0)), // Must be 0 (genesis activation)
EVMTimestamp: pointer(uint64(0)), // Must be 0 (genesis activation)
DurangoTimestamp: pointer(uint64(0)), // Must be 0 for default
EtnaTimestamp: nil, // Optional
FortunaTimestamp: nil, // Optional
+28 -28
View File
@@ -42,15 +42,15 @@ func newTimestampCompatError(what string, storedtime, newtime *uint64) *ethparam
// Lux specific network upgrades are also included here.
// (nil = no fork, 0 = already activated)
type NetworkUpgrades struct {
// SubnetEVMTimestamp is a placeholder that activates Lux Upgrades prior to ApricotPhase6
SubnetEVMTimestamp *uint64 `json:"subnetEVMTimestamp,omitempty"`
// EVMTimestamp is a placeholder that activates Lux Upgrades prior to ApricotPhase6
EVMTimestamp *uint64 `json:"evmTimestamp,omitempty"`
// Durango activates the Shanghai Execution Spec Upgrade from Ethereum (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/shanghai.md#included-eips)
// and Lux Warp Messaging.
// Note: EIP-4895 is excluded since withdrawals are not relevant to the Lux C-Chain or Subnets running the EVM.
DurangoTimestamp *uint64 `json:"durangoTimestamp,omitempty"`
// Placeholder for EtnaTimestamp
EtnaTimestamp *uint64 `json:"etnaTimestamp,omitempty"`
// Fortuna has no effect on Subnet-EVM by itself, but is included for completeness.
// Fortuna has no effect on EVM by itself, but is included for completeness.
FortunaTimestamp *uint64 `json:"fortunaTimestamp,omitempty"`
// Granite is a placeholder for the next upgrade.
GraniteTimestamp *uint64 `json:"graniteTimestamp,omitempty"`
@@ -61,8 +61,8 @@ func (n *NetworkUpgrades) Equal(other *NetworkUpgrades) bool {
}
func (n *NetworkUpgrades) checkNetworkUpgradesCompatible(newcfg *NetworkUpgrades, time uint64) *ethparams.ConfigCompatError {
if isForkTimestampIncompatible(n.SubnetEVMTimestamp, newcfg.SubnetEVMTimestamp, time) {
return newTimestampCompatError("SubnetEVM fork block timestamp", n.SubnetEVMTimestamp, newcfg.SubnetEVMTimestamp)
if isForkTimestampIncompatible(n.EVMTimestamp, newcfg.EVMTimestamp, time) {
return newTimestampCompatError("EVM fork block timestamp", n.EVMTimestamp, newcfg.EVMTimestamp)
}
if isForkTimestampIncompatible(n.DurangoTimestamp, newcfg.DurangoTimestamp, time) {
return newTimestampCompatError("Durango fork block timestamp", n.DurangoTimestamp, newcfg.DurangoTimestamp)
@@ -86,7 +86,7 @@ func (n *NetworkUpgrades) checkNetworkUpgradesCompatible(newcfg *NetworkUpgrades
func (n *NetworkUpgrades) forkOrder() []fork {
return []fork{
{name: "subnetEVMTimestamp", timestamp: n.SubnetEVMTimestamp},
{name: "evmTimestamp", timestamp: n.EVMTimestamp},
{name: "durangoTimestamp", timestamp: n.DurangoTimestamp},
{name: "etnaTimestamp", timestamp: n.EtnaTimestamp},
{name: "fortunaTimestamp", timestamp: n.FortunaTimestamp, optional: true},
@@ -103,8 +103,8 @@ func (n *NetworkUpgrades) SetDefaults(agoUpgrades upgrade.Config) {
// This is because in prior versions, upgrades were not modifiable and were directly set to their default values.
// Most of the tools and configurations just provide these as 0, so it is safer to treat 0 as nil and set to default
// to prevent premature activations of the network upgrades for live networks.
if n.SubnetEVMTimestamp == nil || *n.SubnetEVMTimestamp == 0 {
n.SubnetEVMTimestamp = defaults.SubnetEVMTimestamp
if n.EVMTimestamp == nil || *n.EVMTimestamp == 0 {
n.EVMTimestamp = defaults.EVMTimestamp
}
if n.DurangoTimestamp == nil || *n.DurangoTimestamp == 0 {
n.DurangoTimestamp = defaults.DurangoTimestamp
@@ -122,16 +122,16 @@ func (n *NetworkUpgrades) verifyNetworkUpgrades(agoUpgrades upgrade.Config) erro
defaults := GetNetworkUpgrades(agoUpgrades)
maxTimestamp := uint64(time.Unix(1<<63-1, 0).Unix())
// SubnetEVMTimestamp must not be nil
if n.SubnetEVMTimestamp == nil {
return fmt.Errorf("SubnetEVM fork block timestamp is invalid: %w", errCannotBeNil)
// EVMTimestamp must not be nil
if n.EVMTimestamp == nil {
return fmt.Errorf("EVM fork block timestamp is invalid: %w", errCannotBeNil)
}
// SubnetEVMTimestamp must be 0 (activated at genesis)
if *n.SubnetEVMTimestamp != 0 {
return fmt.Errorf("SubnetEVM fork block timestamp is invalid: must be 0 (activated at genesis), got %d", *n.SubnetEVMTimestamp)
// EVMTimestamp must be 0 (activated at genesis)
if *n.EVMTimestamp != 0 {
return fmt.Errorf("EVM fork block timestamp is invalid: must be 0 (activated at genesis), got %d", *n.EVMTimestamp)
}
if err := verifyWithDefault(n.SubnetEVMTimestamp, defaults.SubnetEVMTimestamp); err != nil {
return fmt.Errorf("SubnetEVM fork block timestamp is invalid: %w", err)
if err := verifyWithDefault(n.EVMTimestamp, defaults.EVMTimestamp); err != nil {
return fmt.Errorf("EVM fork block timestamp is invalid: %w", err)
}
// DurangoTimestamp must not be nil
@@ -184,8 +184,8 @@ func (n *NetworkUpgrades) verifyNetworkUpgrades(agoUpgrades upgrade.Config) erro
}
func (n *NetworkUpgrades) Override(o *NetworkUpgrades) {
if o.SubnetEVMTimestamp != nil {
n.SubnetEVMTimestamp = o.SubnetEVMTimestamp
if o.EVMTimestamp != nil {
n.EVMTimestamp = o.EVMTimestamp
}
if o.DurangoTimestamp != nil {
n.DurangoTimestamp = o.DurangoTimestamp
@@ -201,10 +201,10 @@ func (n *NetworkUpgrades) Override(o *NetworkUpgrades) {
}
}
// IsSubnetEVM returns whether [time] represents a block
// with a timestamp after the SubnetEVM upgrade time.
func (n NetworkUpgrades) IsSubnetEVM(time uint64) bool {
return isTimestampForked(n.SubnetEVMTimestamp, time)
// IsEVM returns whether [time] represents a block
// with a timestamp after the EVM upgrade time.
func (n NetworkUpgrades) IsEVM(time uint64) bool {
return isTimestampForked(n.EVMTimestamp, time)
}
// IsDurango returns whether [time] represents a block
@@ -233,7 +233,7 @@ func (n *NetworkUpgrades) IsGranite(time uint64) bool {
func (n *NetworkUpgrades) Description() string {
var banner string
banner += fmt.Sprintf(" - SubnetEVM Timestamp: @%-10v (https://github.com/luxfi/node/releases/tag/v1.10.0)\n", ptrToString(n.SubnetEVMTimestamp))
banner += fmt.Sprintf(" - EVM Timestamp: @%-10v (https://github.com/luxfi/node/releases/tag/v1.10.0)\n", ptrToString(n.EVMTimestamp))
banner += fmt.Sprintf(" - Durango Timestamp: @%-10v (https://github.com/luxfi/node/releases/tag/v1.11.0)\n", ptrToString(n.DurangoTimestamp))
banner += fmt.Sprintf(" - Etna Timestamp: @%-10v (https://github.com/luxfi/node/releases/tag/v1.12.0)\n", ptrToString(n.EtnaTimestamp))
banner += fmt.Sprintf(" - Fortuna Timestamp: @%-10v (https://github.com/luxfi/node/releases/tag/v1.13.0)\n", ptrToString(n.FortunaTimestamp))
@@ -242,7 +242,7 @@ func (n *NetworkUpgrades) Description() string {
}
type LuxRules struct {
IsSubnetEVM bool
IsEVM bool
IsDurango bool
IsEtna bool
IsFortuna bool
@@ -251,7 +251,7 @@ type LuxRules struct {
func (n *NetworkUpgrades) GetLuxRules(time uint64) LuxRules {
return LuxRules{
IsSubnetEVM: n.IsSubnetEVM(time),
IsEVM: n.IsEVM(time),
IsDurango: n.IsDurango(time),
IsEtna: n.IsEtna(time),
IsFortuna: n.IsFortuna(time),
@@ -265,9 +265,9 @@ func (n *NetworkUpgrades) GetLuxRules(time uint64) LuxRules {
// at or after UnscheduledActivationTime, it is considered not scheduled.
// InitiallyActiveTime is treated as "activated at genesis (timestamp 0)".
func GetNetworkUpgrades(agoUpgrade upgrade.Config) NetworkUpgrades {
// SubnetEVM is always activated at genesis (0)
// EVM is always activated at genesis (0)
result := NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(0),
EVMTimestamp: utils.NewUint64(0),
}
// Use upgrade.UnscheduledActivationTime as the threshold for "unscheduled"
@@ -314,7 +314,7 @@ func GetNetworkUpgrades(agoUpgrade upgrade.Config) NetworkUpgrades {
// GetDefaultNetworkUpgrades returns default network upgrades
func GetDefaultNetworkUpgrades() NetworkUpgrades {
return NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(0),
EVMTimestamp: utils.NewUint64(0),
DurangoTimestamp: utils.NewUint64(0), // Already activated
EtnaTimestamp: nil, // Not scheduled
FortunaTimestamp: nil, // Not scheduled
+32 -32
View File
@@ -16,7 +16,7 @@ import (
// This is used for testing upgrade compatibility scenarios
func getTestFujiUpgrades() NetworkUpgrades {
return NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(0),
EVMTimestamp: utils.NewUint64(0),
DurangoTimestamp: utils.NewUint64(0),
EtnaTimestamp: utils.NewUint64(100), // Set for testing
FortunaTimestamp: utils.NewUint64(1000),
@@ -44,11 +44,11 @@ func TestNetworkUpgradesEqual(t *testing.T) {
{
name: "EqualNetworkUpgrades",
upgrades1: &NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(1),
EVMTimestamp: utils.NewUint64(1),
DurangoTimestamp: utils.NewUint64(2),
},
upgrades2: &NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(1),
EVMTimestamp: utils.NewUint64(1),
DurangoTimestamp: utils.NewUint64(2),
},
expected: true,
@@ -56,11 +56,11 @@ func TestNetworkUpgradesEqual(t *testing.T) {
{
name: "NotEqualNetworkUpgrades",
upgrades1: &NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(1),
EVMTimestamp: utils.NewUint64(1),
DurangoTimestamp: utils.NewUint64(2),
},
upgrades2: &NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(1),
EVMTimestamp: utils.NewUint64(1),
DurangoTimestamp: utils.NewUint64(3),
},
expected: false,
@@ -68,7 +68,7 @@ func TestNetworkUpgradesEqual(t *testing.T) {
{
name: "NilNetworkUpgrades",
upgrades1: &NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(1),
EVMTimestamp: utils.NewUint64(1),
DurangoTimestamp: utils.NewUint64(2),
},
upgrades2: nil,
@@ -77,11 +77,11 @@ func TestNetworkUpgradesEqual(t *testing.T) {
{
name: "NilNetworkUpgrade",
upgrades1: &NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(1),
EVMTimestamp: utils.NewUint64(1),
DurangoTimestamp: utils.NewUint64(2),
},
upgrades2: &NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(1),
EVMTimestamp: utils.NewUint64(1),
DurangoTimestamp: nil,
},
expected: false,
@@ -105,11 +105,11 @@ func TestCheckNetworkUpgradesCompatible(t *testing.T) {
{
name: "Compatible_same_NetworkUpgrades",
upgrades1: &NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(1),
EVMTimestamp: utils.NewUint64(1),
DurangoTimestamp: utils.NewUint64(2),
},
upgrades2: &NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(1),
EVMTimestamp: utils.NewUint64(1),
DurangoTimestamp: utils.NewUint64(2),
},
time: 1,
@@ -118,11 +118,11 @@ func TestCheckNetworkUpgradesCompatible(t *testing.T) {
{
name: "Compatible_different_NetworkUpgrades",
upgrades1: &NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(1),
EVMTimestamp: utils.NewUint64(1),
DurangoTimestamp: utils.NewUint64(2),
},
upgrades2: &NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(1),
EVMTimestamp: utils.NewUint64(1),
DurangoTimestamp: utils.NewUint64(3),
},
time: 1,
@@ -131,11 +131,11 @@ func TestCheckNetworkUpgradesCompatible(t *testing.T) {
{
name: "Compatible_nil_NetworkUpgrades",
upgrades1: &NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(1),
EVMTimestamp: utils.NewUint64(1),
DurangoTimestamp: utils.NewUint64(2),
},
upgrades2: &NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(1),
EVMTimestamp: utils.NewUint64(1),
DurangoTimestamp: nil,
},
time: 1,
@@ -144,11 +144,11 @@ func TestCheckNetworkUpgradesCompatible(t *testing.T) {
{
name: "Incompatible_rewinded_NetworkUpgrades",
upgrades1: &NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(1),
EVMTimestamp: utils.NewUint64(1),
DurangoTimestamp: utils.NewUint64(2),
},
upgrades2: &NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(1),
EVMTimestamp: utils.NewUint64(1),
DurangoTimestamp: utils.NewUint64(1),
},
time: 1,
@@ -157,11 +157,11 @@ func TestCheckNetworkUpgradesCompatible(t *testing.T) {
{
name: "Incompatible_fastforward_NetworkUpgrades",
upgrades1: &NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(1),
EVMTimestamp: utils.NewUint64(1),
DurangoTimestamp: utils.NewUint64(2),
},
upgrades2: &NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(1),
EVMTimestamp: utils.NewUint64(1),
DurangoTimestamp: utils.NewUint64(3),
},
time: 4,
@@ -170,11 +170,11 @@ func TestCheckNetworkUpgradesCompatible(t *testing.T) {
{
name: "Incompatible_nil_NetworkUpgrades",
upgrades1: &NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(1),
EVMTimestamp: utils.NewUint64(1),
DurangoTimestamp: utils.NewUint64(2),
},
upgrades2: &NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(1),
EVMTimestamp: utils.NewUint64(1),
DurangoTimestamp: nil,
},
time: 2,
@@ -231,7 +231,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) {
{
name: "ValidNetworkUpgrades_for_latest_network",
upgrades: &NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(0),
EVMTimestamp: utils.NewUint64(0),
DurangoTimestamp: utils.NewUint64(0), // Must be 0 since default is 0
EtnaTimestamp: utils.NewUint64(0), // Must be 0 for Latest
FortunaTimestamp: utils.NewUint64(0), // Must be 0 for Latest
@@ -243,16 +243,16 @@ func TestVerifyNetworkUpgrades(t *testing.T) {
{
name: "Invalid_Durango_nil_upgrade",
upgrades: &NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(1),
EVMTimestamp: utils.NewUint64(1),
DurangoTimestamp: nil,
},
luxdUpgrades: getTestMainnetConfig(),
valid: false,
},
{
name: "Invalid_Subnet-EVM_non-zero",
name: "Invalid_EVM_non-zero",
upgrades: &NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(1),
EVMTimestamp: utils.NewUint64(1),
DurangoTimestamp: utils.NewUint64(2),
},
luxdUpgrades: getTestMainnetConfig(),
@@ -261,7 +261,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) {
{
name: "Invalid_Durango_before_default_upgrade",
upgrades: &NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(0),
EVMTimestamp: utils.NewUint64(0),
DurangoTimestamp: utils.NewUint64(1), // Non-zero when default is 0
},
luxdUpgrades: getTestMainnetConfig(),
@@ -270,7 +270,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) {
{
name: "Invalid_Mainnet_Durango_reconfigured",
upgrades: &NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(0),
EVMTimestamp: utils.NewUint64(0),
DurangoTimestamp: utils.NewUint64(1000), // Changed from default 0
},
luxdUpgrades: getTestMainnetConfig(),
@@ -279,7 +279,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) {
{
name: "Invalid_Testnet_Durango_reconfigured",
upgrades: &NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(0),
EVMTimestamp: utils.NewUint64(0),
DurangoTimestamp: utils.NewUint64(1000), // Changed from default 0
},
luxdUpgrades: getTestFujiConfig(),
@@ -288,7 +288,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) {
{
name: "Valid_Etna_nil_when_unscheduled",
upgrades: &NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(0),
EVMTimestamp: utils.NewUint64(0),
DurangoTimestamp: utils.NewUint64(0), // Genesis
EtnaTimestamp: nil, // Valid when Etna is unscheduled
},
@@ -298,7 +298,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) {
{
name: "Invalid_Etna_before_Durango",
upgrades: &NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(0),
EVMTimestamp: utils.NewUint64(0),
DurangoTimestamp: utils.NewUint64(100),
EtnaTimestamp: utils.NewUint64(99),
},
@@ -308,7 +308,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) {
{
name: "Valid_Fortuna_nil",
upgrades: &NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(0),
EVMTimestamp: utils.NewUint64(0),
DurangoTimestamp: utils.NewUint64(0), // Genesis
EtnaTimestamp: utils.NewUint64(500), // Test timestamp
FortunaTimestamp: nil,
@@ -338,7 +338,7 @@ func TestForkOrder(t *testing.T) {
{
name: "ValidNetworkUpgrades",
upgrades: &NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(0),
EVMTimestamp: utils.NewUint64(0),
DurangoTimestamp: utils.NewUint64(2),
},
expectedErr: false,
@@ -346,7 +346,7 @@ func TestForkOrder(t *testing.T) {
{
name: "Invalid order",
upgrades: &NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(1),
EVMTimestamp: utils.NewUint64(1),
DurangoTimestamp: utils.NewUint64(0),
},
expectedErr: true,
+2 -2
View File
@@ -11,8 +11,8 @@ import (
// ForkToChainConfig maps a fork to a chain config
var ForkToChainConfig = map[upgradetest.Fork]*params.ChainConfig{
upgradetest.ApricotPhase5: params.TestPreSubnetEVMChainConfig,
upgradetest.ApricotPhase6: params.TestSubnetEVMChainConfig,
upgradetest.ApricotPhase5: params.TestPreEVMChainConfig,
upgradetest.ApricotPhase6: params.TestEVMChainConfig,
upgradetest.Durango: params.TestDurangoChainConfig,
upgradetest.Etna: params.TestEtnaChainConfig,
upgradetest.Fortuna: params.TestFortunaChainConfig,
+1 -1
View File
@@ -8,7 +8,7 @@ The VM creates the Ethereum backend and provides basic block building, parsing,
## APIs
The VM creates APIs for the node through the function `CreateHandlers()`. CreateHandlers returns the `Service` struct to serve Subnet-EVM specific APIs. Additionally, the Ethereum backend APIs are also returned at the `/rpc` extension.
The VM creates APIs for the node through the function `CreateHandlers()`. CreateHandlers returns the `Service` struct to serve EVM specific APIs. Additionally, the Ethereum backend APIs are also returned at the `/rpc` extension.
## Block Handling
+5 -5
View File
@@ -67,9 +67,9 @@ func (v blockValidator) SyntacticVerify(b *Block, rules params.Rules) error {
return err
}
if rulesExtra.IsSubnetEVM {
if rulesExtra.IsEVM {
if ethHeader.BaseFee == nil {
return errNilBaseFeeSubnetEVM
return errNilBaseFeeEVM
}
if bfLen := ethHeader.BaseFee.BitLen(); bfLen > 256 {
return fmt.Errorf("too large base fee: bitlen %d", bfLen)
@@ -98,7 +98,7 @@ func (v blockValidator) SyntacticVerify(b *Block, rules params.Rules) error {
return errEmptyBlock
}
if !rulesExtra.IsSubnetEVM {
if !rulesExtra.IsEVM {
// Make sure that all the txs have the correct fee set.
for _, tx := range txs {
if tx.GasPrice().Cmp(legacyMinGasPrice) < 0 {
@@ -113,13 +113,13 @@ func (v blockValidator) SyntacticVerify(b *Block, rules params.Rules) error {
return fmt.Errorf("block timestamp is too far in the future: %d > allowed %d", blockTimestamp, maxBlockTime)
}
if rulesExtra.IsSubnetEVM {
if rulesExtra.IsEVM {
blockGasCost := customtypes.GetHeaderExtra(ethHeader).BlockGasCost
switch {
// Make sure BlockGasCost is not nil
// NOTE: ethHeader.BlockGasCost correctness is checked in header verification
case blockGasCost == nil:
return errNilBlockGasCostSubnetEVM
return errNilBlockGasCostEVM
case !blockGasCost.IsUint64():
return fmt.Errorf("too large blockGasCost: %d", blockGasCost)
}
+5 -5
View File
@@ -1,10 +1,10 @@
# Subnet-EVM Configuration
# EVM Configuration
> **Note**: These are the configuration options available in the Subnet-EVM codebase. To set these values, you need to create a configuration file at `~/.luxd/configs/chains/<blockchainID>/config.json`.
> **Note**: These are the configuration options available in the EVM codebase. To set these values, you need to create a configuration file at `~/.luxd/configs/chains/<blockchainID>/config.json`.
>
> For the Luxd node configuration options, see the Luxd Configuration page.
This document describes all configuration options available for Subnet-EVM.
This document describes all configuration options available for EVM.
## Example Configuration
@@ -37,7 +37,7 @@ Configuration is provided as a JSON object. All fields are optional unless other
|--------|------|-------------|---------|
| `eth-apis` | array of strings | List of Ethereum services that should be enabled | `["eth", "eth-filter", "net", "web3", "internal-eth", "internal-blockchain", "internal-transaction"]` |
### Subnet-EVM Specific APIs
### EVM Specific APIs
| Option | Type | Description | Default |
|--------|------|-------------|---------|
@@ -267,7 +267,7 @@ Configuration is provided as a JSON object. All fields are optional unless other
## Gossip Constants
The following constants are defined for transaction gossip behavior and cannot be configured without a custom build of Subnet-EVM:
The following constants are defined for transaction gossip behavior and cannot be configured without a custom build of EVM:
| Constant | Type | Description | Value |
|----------|------|-------------|-------|
+4 -4
View File
@@ -293,13 +293,13 @@ func makeBenchBlock() *types.Block {
return types.NewBlock(header, body, receipts, blocktest.NewHasher())
}
// TestSubnetEVMBlockEncoding tests block creation with SubnetEVM extras (BlockGasCost).
// Note: We use dynamic block creation instead of hardcoded RLP because the SubnetEVM
// TestEVMBlockEncoding tests block creation with EVM extras (BlockGasCost).
// Note: We use dynamic block creation instead of hardcoded RLP because the EVM
// header format (with BlockGasCost) is not compatible with geth's header format.
func TestSubnetEVMBlockEncoding(t *testing.T) {
func TestEVMBlockEncoding(t *testing.T) {
t.Parallel()
// Create a header with SubnetEVM extras
// Create a header with EVM extras
header := &types.Header{
ParentHash: common.HexToHash("0x83cafc574e1f51ba9dc0568fc617a08ea2429fb384059c972f13b19fa1c8dd55"),
UncleHash: common.HexToHash("0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"),
+4 -4
View File
@@ -60,7 +60,7 @@ func WithHeaderExtra(h *ethtypes.Header, extra *HeaderExtra) *ethtypes.Header {
return h
}
// HeaderExtra is a struct that contains extra fields used by Subnet-EVM
// HeaderExtra is a struct that contains extra fields used by EVM
// in the block header.
// This type uses [HeaderSerializable] to encode and decode the extra fields
// along with the upstream type for compatibility with existing network blocks.
@@ -222,7 +222,7 @@ type HeaderSerializable struct {
// BaseFee was added by EIP-1559 and is ignored in legacy headers.
BaseFee *big.Int `json:"baseFeePerGas" rlp:"optional"`
// BlockGasCost was added by SubnetEVM and is ignored in legacy
// BlockGasCost was added by EVM and is ignored in legacy
// headers.
BlockGasCost *big.Int `json:"blockGasCost" rlp:"optional"`
@@ -239,11 +239,11 @@ type HeaderSerializable struct {
RequestsHash *common.Hash `json:"requestsHash" rlp:"optional"`
// ExtDataHash was added by Lux for cross-chain data and is ignored in legacy headers.
// Placed at end for RLP backward compatibility with existing subnet-evm blocks.
// Placed at end for RLP backward compatibility with existing evm blocks.
ExtDataHash *common.Hash `json:"extDataHash" rlp:"optional"`
// ExtDataGasUsed was added by Lux for cross-chain gas accounting and is ignored in legacy headers.
// Placed at end for RLP backward compatibility with existing subnet-evm blocks.
// Placed at end for RLP backward compatibility with existing evm blocks.
ExtDataGasUsed *big.Int `json:"extDataGasUsed" rlp:"optional"`
}
+2 -2
View File
@@ -11,8 +11,8 @@ import (
var (
// ID this VM should be referenced by
IDStr = "subnetevm"
ID = ids.ID{'s', 'u', 'b', 'n', 'e', 't', 'e', 'v', 'm'}
IDStr = "evm"
ID = ids.ID{'e', 'v', 'm'}
_ vms.Factory = (*Factory)(nil)
)
+7 -7
View File
@@ -17,7 +17,7 @@ var errEstimateBaseFeeWithoutActivation = errors.New("cannot estimate base fee f
// BaseFee takes the previous header and the timestamp of its child block and
// calculates the expected base fee for the child block.
//
// Prior to SubnetEVM, the returned base fee will be nil.
// Prior to EVM, the returned base fee will be nil.
func BaseFee(
config *extras.ChainConfig,
feeConfig commontype.FeeConfig,
@@ -25,10 +25,10 @@ func BaseFee(
timestamp uint64,
) (*big.Int, error) {
switch {
case config.IsSubnetEVM(timestamp):
case config.IsEVM(timestamp):
return baseFeeFromWindow(config, feeConfig, parent, timestamp)
default:
// Prior to SubnetEVM the expected base fee is nil.
// Prior to EVM the expected base fee is nil.
return nil, nil
}
}
@@ -36,8 +36,8 @@ func BaseFee(
// EstimateNextBaseFee attempts to estimate the base fee of a block built at
// `timestamp` on top of `parent`.
//
// If timestamp is before parent.Time or the SubnetEVM activation time, then timestamp
// is set to the maximum of parent.Time and the SubnetEVM activation time.
// If timestamp is before parent.Time or the EVM activation time, then timestamp
// is set to the maximum of parent.Time and the EVM activation time.
//
// Warning: This function should only be used in estimation and should not be
// used when calculating the canonical base fee for a block.
@@ -47,10 +47,10 @@ func EstimateNextBaseFee(
parent *types.Header,
timestamp uint64,
) (*big.Int, error) {
if config.SubnetEVMTimestamp == nil {
if config.EVMTimestamp == nil {
return nil, errEstimateBaseFeeWithoutActivation
}
timestamp = max(timestamp, parent.Time, *config.SubnetEVMTimestamp)
timestamp = max(timestamp, parent.Time, *config.EVMTimestamp)
return BaseFee(config, feeConfig, parent, timestamp)
}
+22 -22
View File
@@ -9,7 +9,7 @@ import (
"github.com/luxfi/evm/commontype"
"github.com/luxfi/evm/params/extras"
"github.com/luxfi/evm/plugin/evm/upgrade/subnetevm"
"github.com/luxfi/evm/plugin/evm/upgrade/feewindow"
"github.com/luxfi/evm/utils"
"github.com/luxfi/geth/common"
"github.com/luxfi/geth/core/types"
@@ -40,14 +40,14 @@ func BaseFeeTest(t *testing.T, feeConfig commontype.FeeConfig) {
}{
{
name: "pre_subnet_evm",
upgrades: extras.TestPreSubnetEVMChainConfig.NetworkUpgrades,
upgrades: extras.TestPreEVMChainConfig.NetworkUpgrades,
want: nil,
wantErr: nil,
},
{
name: "subnet_evm_first_block",
upgrades: extras.NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(1),
EVMTimestamp: utils.NewUint64(1),
},
parent: &types.Header{
Number: big.NewInt(1),
@@ -57,7 +57,7 @@ func BaseFeeTest(t *testing.T, feeConfig commontype.FeeConfig) {
},
{
name: "subnet_evm_genesis_block",
upgrades: extras.TestSubnetEVMChainConfig.NetworkUpgrades,
upgrades: extras.TestEVMChainConfig.NetworkUpgrades,
parent: &types.Header{
Number: big.NewInt(0),
},
@@ -65,31 +65,31 @@ func BaseFeeTest(t *testing.T, feeConfig commontype.FeeConfig) {
},
{
name: "subnet_evm_invalid_fee_window",
upgrades: extras.TestSubnetEVMChainConfig.NetworkUpgrades,
upgrades: extras.TestEVMChainConfig.NetworkUpgrades,
parent: &types.Header{
Number: big.NewInt(1),
},
wantErr: subnetevm.ErrWindowInsufficientLength,
wantErr: feewindow.ErrWindowInsufficientLength,
},
{
name: "subnet_evm_invalid_timestamp",
upgrades: extras.TestSubnetEVMChainConfig.NetworkUpgrades,
upgrades: extras.TestEVMChainConfig.NetworkUpgrades,
parent: &types.Header{
Number: big.NewInt(1),
Time: 1,
Extra: (&subnetevm.Window{}).Bytes(),
Extra: (&feewindow.Window{}).Bytes(),
},
timestamp: 0,
wantErr: errInvalidTimestamp,
},
{
name: "subnet_evm_no_change",
upgrades: extras.TestSubnetEVMChainConfig.NetworkUpgrades,
upgrades: extras.TestEVMChainConfig.NetworkUpgrades,
parent: &types.Header{
Number: big.NewInt(1),
GasUsed: feeConfig.TargetGas.Uint64(),
Time: 1,
Extra: (&subnetevm.Window{}).Bytes(),
Extra: (&feewindow.Window{}).Bytes(),
BaseFee: big.NewInt(feeConfig.MinBaseFee.Int64() + 1),
},
timestamp: 1,
@@ -97,10 +97,10 @@ func BaseFeeTest(t *testing.T, feeConfig commontype.FeeConfig) {
},
{
name: "subnet_evm_small_decrease",
upgrades: extras.TestSubnetEVMChainConfig.NetworkUpgrades,
upgrades: extras.TestEVMChainConfig.NetworkUpgrades,
parent: &types.Header{
Number: big.NewInt(1),
Extra: (&subnetevm.Window{}).Bytes(),
Extra: (&feewindow.Window{}).Bytes(),
BaseFee: big.NewInt(maxBaseFee),
},
timestamp: 1,
@@ -120,13 +120,13 @@ func BaseFeeTest(t *testing.T, feeConfig commontype.FeeConfig) {
},
{
name: "subnet_evm_large_decrease",
upgrades: extras.TestSubnetEVMChainConfig.NetworkUpgrades,
upgrades: extras.TestEVMChainConfig.NetworkUpgrades,
parent: &types.Header{
Number: big.NewInt(1),
Extra: (&subnetevm.Window{}).Bytes(),
Extra: (&feewindow.Window{}).Bytes(),
BaseFee: big.NewInt(maxBaseFee),
},
timestamp: 2 * subnetevm.WindowLen,
timestamp: 2 * feewindow.WindowLen,
want: func() *big.Int {
var (
gasTarget = feeConfig.TargetGas.Int64()
@@ -144,11 +144,11 @@ func BaseFeeTest(t *testing.T, feeConfig commontype.FeeConfig) {
},
{
name: "subnet_evm_increase",
upgrades: extras.TestSubnetEVMChainConfig.NetworkUpgrades,
upgrades: extras.TestEVMChainConfig.NetworkUpgrades,
parent: &types.Header{
Number: big.NewInt(1),
GasUsed: 2 * feeConfig.TargetGas.Uint64(),
Extra: (&subnetevm.Window{}).Bytes(),
Extra: (&feewindow.Window{}).Bytes(),
BaseFee: big.NewInt(feeConfig.MinBaseFee.Int64()),
},
timestamp: 1,
@@ -168,14 +168,14 @@ func BaseFeeTest(t *testing.T, feeConfig commontype.FeeConfig) {
},
{
name: "subnet_evm_big_1_not_modified",
upgrades: extras.TestSubnetEVMChainConfig.NetworkUpgrades,
upgrades: extras.TestEVMChainConfig.NetworkUpgrades,
parent: &types.Header{
Number: big.NewInt(1),
GasUsed: 1,
Extra: (&subnetevm.Window{}).Bytes(),
Extra: (&feewindow.Window{}).Bytes(),
BaseFee: big.NewInt(1),
},
timestamp: 2 * subnetevm.WindowLen,
timestamp: 2 * feewindow.WindowLen,
want: big.NewInt(feeConfig.MinBaseFee.Int64()),
},
}
@@ -218,10 +218,10 @@ func EstimateNextBaseFeeTest(t *testing.T, feeConfig commontype.FeeConfig) {
}{
{
name: "activated",
upgrades: extras.TestSubnetEVMChainConfig.NetworkUpgrades,
upgrades: extras.TestEVMChainConfig.NetworkUpgrades,
parent: &types.Header{
Number: big.NewInt(1),
Extra: (&subnetevm.Window{}).Bytes(),
Extra: (&feewindow.Window{}).Bytes(),
BaseFee: new(big.Int).SetUint64(testBaseFee),
},
timestamp: 1,
+4 -4
View File
@@ -23,14 +23,14 @@ var (
// BlockGasCost calculates the required block gas cost based on the parent
// header and the timestamp of the new block.
// Prior to Subnet-EVM, the returned block gas cost will be nil.
// Prior to EVM, the returned block gas cost will be nil.
func BlockGasCost(
config *extras.ChainConfig,
feeConfig commontype.FeeConfig,
parent *types.Header,
timestamp uint64,
) *big.Int {
if !config.IsSubnetEVM(timestamp) {
if !config.IsEVM(timestamp) {
return nil
}
step := feeConfig.BlockGasCostStep.Uint64()
@@ -83,14 +83,14 @@ func BlockGasCostWithStep(
// transactions. The only correctness check performed is that the sum of all
// tips is >= the required block fee.
//
// This function will return nil for all return values prior to SubnetEVM.
// This function will return nil for all return values prior to EVM.
func EstimateRequiredTip(
config *extras.ChainConfig,
header *types.Header,
) (*big.Int, error) {
extra := customtypes.GetHeaderExtra(header)
switch {
case !config.IsSubnetEVM(header.Time):
case !config.IsEVM(header.Time):
return nil, nil
case header.BaseFee == nil:
return nil, errBaseFeeNil
+9 -9
View File
@@ -67,7 +67,7 @@ func BlockGasCostTest(t *testing.T, feeConfig commontype.FeeConfig) {
{
name: "before_subnet_evm",
parentTime: 10,
upgrades: extras.TestPreSubnetEVMChainConfig.NetworkUpgrades,
upgrades: extras.TestPreEVMChainConfig.NetworkUpgrades,
parentCost: maxBlockGasCostBig,
timestamp: 10 + targetBlockRate + 1,
expected: nil,
@@ -218,19 +218,19 @@ func BlockGasCostWithStepTest(t *testing.T, feeConfig commontype.FeeConfig) {
func TestEstimateRequiredTip(t *testing.T) {
tests := []struct {
name string
subnetEVMTimestamp *uint64
evmTimestamp *uint64
header *types.Header
want *big.Int
wantErr error
}{
{
name: "not_subnet_evm",
subnetEVMTimestamp: utils.NewUint64(1),
evmTimestamp: utils.NewUint64(1),
header: &types.Header{},
},
{
name: "nil_base_fee",
subnetEVMTimestamp: utils.NewUint64(0),
evmTimestamp: utils.NewUint64(0),
header: customtypes.WithHeaderExtra(
&types.Header{},
&customtypes.HeaderExtra{
@@ -241,7 +241,7 @@ func TestEstimateRequiredTip(t *testing.T) {
},
{
name: "nil_block_gas_cost",
subnetEVMTimestamp: utils.NewUint64(0),
evmTimestamp: utils.NewUint64(0),
header: &types.Header{
BaseFee: big.NewInt(1),
Number: big.NewInt(1), // Ensure unique hash to avoid collision with no_gas_used test case
@@ -250,7 +250,7 @@ func TestEstimateRequiredTip(t *testing.T) {
},
{
name: "no_gas_used",
subnetEVMTimestamp: utils.NewUint64(0),
evmTimestamp: utils.NewUint64(0),
header: customtypes.WithHeaderExtra(
&types.Header{
GasUsed: 0,
@@ -264,7 +264,7 @@ func TestEstimateRequiredTip(t *testing.T) {
},
{
name: "success",
subnetEVMTimestamp: utils.NewUint64(0),
evmTimestamp: utils.NewUint64(0),
header: customtypes.WithHeaderExtra(
&types.Header{
GasUsed: 912,
@@ -280,7 +280,7 @@ func TestEstimateRequiredTip(t *testing.T) {
},
{
name: "success_rounds_up",
subnetEVMTimestamp: utils.NewUint64(0),
evmTimestamp: utils.NewUint64(0),
header: customtypes.WithHeaderExtra(
&types.Header{
GasUsed: 124,
@@ -302,7 +302,7 @@ func TestEstimateRequiredTip(t *testing.T) {
config := &extras.ChainConfig{
NetworkUpgrades: extras.NetworkUpgrades{
SubnetEVMTimestamp: test.subnetEVMTimestamp,
EVMTimestamp: test.evmTimestamp,
},
}
requiredTip, err := EstimateRequiredTip(config, test.header)
+14 -14
View File
@@ -10,7 +10,7 @@ import (
"github.com/luxfi/evm/commontype"
"github.com/luxfi/evm/params/extras"
"github.com/luxfi/evm/plugin/evm/upgrade/subnetevm"
"github.com/luxfi/evm/plugin/evm/upgrade/feewindow"
"github.com/luxfi/geth/common"
"github.com/luxfi/geth/core/types"
)
@@ -30,11 +30,11 @@ func bigMax(x, y *big.Int) *big.Int {
return y
}
// baseFeeFromWindow should only be called if `timestamp` >= `config.SubnetEVMTimestamp`
// baseFeeFromWindow should only be called if `timestamp` >= `config.EVMTimestamp`
func baseFeeFromWindow(config *extras.ChainConfig, feeConfig commontype.FeeConfig, parent *types.Header, timestamp uint64) (*big.Int, error) {
// If the current block is the first EIP-1559 block, or it is the genesis block
// return the initial slice and initial base fee.
if !config.IsSubnetEVM(parent.Time) || parent.Number.Cmp(common.Big0) == 0 {
if !config.IsEVM(parent.Time) || parent.Number.Cmp(common.Big0) == 0 {
return big.NewInt(feeConfig.MinBaseFee.Int64()), nil
}
@@ -90,16 +90,16 @@ func baseFeeFromWindow(config *extras.ChainConfig, feeConfig commontype.FeeConfi
)
}
// If timeElapsed is greater than [subnetevm.WindowLen], apply the state
// If timeElapsed is greater than [feewindow.WindowLen], apply the state
// transition to the base fee to account for the interval during which
// no blocks were produced.
//
// We use timeElapsed/[subnetevm.WindowLen], so that the transition is applied
// for every [subnetevm.WindowLen] seconds that has elapsed between the parent
// We use timeElapsed/[feewindow.WindowLen], so that the transition is applied
// for every [feewindow.WindowLen] seconds that has elapsed between the parent
// and this block.
var (
timeElapsed = timestamp - parent.Time
windowsElapsed = timeElapsed / subnetevm.WindowLen
windowsElapsed = timeElapsed / feewindow.WindowLen
)
if windowsElapsed > 1 {
bigWindowsElapsed := new(big.Int).SetUint64(windowsElapsed)
@@ -120,25 +120,25 @@ func baseFeeFromWindow(config *extras.ChainConfig, feeConfig commontype.FeeConfi
// feeWindow takes the previous header and the timestamp of its child block and
// calculates the expected fee window.
//
// feeWindow should only be called if timestamp >= config.SubnetEVMTimestamp
// feeWindow should only be called if timestamp >= config.EVMTimestamp
func feeWindow(
config *extras.ChainConfig,
parent *types.Header,
timestamp uint64,
) (subnetevm.Window, error) {
) (feewindow.Window, error) {
// If the current block is the first EIP-1559 block, or it is the genesis block
// return the initial window.
if !config.IsSubnetEVM(parent.Time) || parent.Number.Cmp(common.Big0) == 0 {
return subnetevm.Window{}, nil
if !config.IsEVM(parent.Time) || parent.Number.Cmp(common.Big0) == 0 {
return feewindow.Window{}, nil
}
dynamicFeeWindow, err := subnetevm.ParseWindow(parent.Extra)
dynamicFeeWindow, err := feewindow.ParseWindow(parent.Extra)
if err != nil {
return subnetevm.Window{}, err
return feewindow.Window{}, err
}
if timestamp < parent.Time {
return subnetevm.Window{}, fmt.Errorf("%w: timestamp %d prior to parent timestamp %d",
return feewindow.Window{}, fmt.Errorf("%w: timestamp %d prior to parent timestamp %d",
errInvalidTimestamp,
timestamp,
parent.Time,
+11 -11
View File
@@ -9,7 +9,7 @@ import (
"fmt"
"github.com/luxfi/evm/params/extras"
"github.com/luxfi/evm/plugin/evm/upgrade/subnetevm"
"github.com/luxfi/evm/plugin/evm/upgrade/feewindow"
"github.com/luxfi/geth/core/types"
)
@@ -30,14 +30,14 @@ func ExtraPrefix(
header *types.Header,
) ([]byte, error) {
switch {
case config.IsSubnetEVM(header.Time):
case config.IsEVM(header.Time):
window, err := feeWindow(config, parent, header.Time)
if err != nil {
return nil, fmt.Errorf("failed to calculate fee window: %w", err)
}
return window.Bytes(), nil
default:
// Prior to SubnetEVM there was no expected extra prefix.
// Prior to EVM there was no expected extra prefix.
return nil, nil
}
}
@@ -50,7 +50,7 @@ func VerifyExtraPrefix(
header *types.Header,
) error {
switch {
case config.IsSubnetEVM(header.Time):
case config.IsEVM(header.Time):
feeWindow, err := feeWindow(config, parent, header.Time)
if err != nil {
return fmt.Errorf("calculating expected fee window: %w", err)
@@ -75,20 +75,20 @@ func VerifyExtra(rules extras.LuxRules, extra []byte) error {
extraLen := len(extra)
switch {
case rules.IsDurango:
if extraLen < subnetevm.WindowSize {
if extraLen < feewindow.WindowSize {
return fmt.Errorf(
"%w: expected >= %d but got %d",
errInvalidExtraLength,
subnetevm.WindowSize,
feewindow.WindowSize,
extraLen,
)
}
case rules.IsSubnetEVM:
if extraLen != subnetevm.WindowSize {
case rules.IsEVM:
if extraLen != feewindow.WindowSize {
return fmt.Errorf(
"%w: expected %d but got %d",
errInvalidExtraLength,
subnetevm.WindowSize,
feewindow.WindowSize,
extraLen,
)
}
@@ -108,7 +108,7 @@ func VerifyExtra(rules extras.LuxRules, extra []byte) error {
// PredicateBytesFromExtra returns the predicate result bytes from the header's
// extra data. If the extra data is not long enough, an empty slice is returned.
func PredicateBytesFromExtra(extra []byte) []byte {
offset := subnetevm.WindowSize
offset := feewindow.WindowSize
// Prior to Durango, the VM enforces the extra data is smaller than or equal
// to `offset`.
// After Durango, the VM pre-verifies the extra data past `offset` is valid.
@@ -122,7 +122,7 @@ func PredicateBytesFromExtra(extra []byte) []byte {
// data. If the extra data is not long enough (i.e., an incomplete header.Extra
// as built in the miner), it is padded with zeros.
func SetPredicateBytesInExtra(extra []byte, predicateBytes []byte) []byte {
offset := subnetevm.WindowSize
offset := feewindow.WindowSize
if len(extra) < offset {
// pad extra with zeros
extra = append(extra, make([]byte, offset-len(extra))...)
+38 -38
View File
@@ -9,7 +9,7 @@ import (
"github.com/luxfi/evm/params/extras"
"github.com/luxfi/evm/plugin/evm/customtypes"
"github.com/luxfi/evm/plugin/evm/upgrade/subnetevm"
"github.com/luxfi/evm/plugin/evm/upgrade/feewindow"
"github.com/luxfi/evm/utils"
"github.com/luxfi/geth/core/types"
"github.com/stretchr/testify/require"
@@ -31,7 +31,7 @@ func TestExtraPrefix(t *testing.T) {
}{
{
name: "pre_subnet_evm",
upgrades: extras.TestPreSubnetEVMChainConfig.NetworkUpgrades,
upgrades: extras.TestPreEVMChainConfig.NetworkUpgrades,
header: &types.Header{},
want: nil,
wantErr: nil,
@@ -39,7 +39,7 @@ func TestExtraPrefix(t *testing.T) {
{
name: "subnet_evm_first_block",
upgrades: extras.NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(1),
EVMTimestamp: utils.NewUint64(1),
},
parent: &types.Header{
Number: big.NewInt(1),
@@ -47,33 +47,33 @@ func TestExtraPrefix(t *testing.T) {
header: &types.Header{
Time: 1,
},
want: (&subnetevm.Window{}).Bytes(),
want: (&feewindow.Window{}).Bytes(),
},
{
name: "subnet_evm_genesis_block",
upgrades: extras.TestSubnetEVMChainConfig.NetworkUpgrades,
upgrades: extras.TestEVMChainConfig.NetworkUpgrades,
parent: &types.Header{
Number: big.NewInt(0),
},
header: &types.Header{},
want: (&subnetevm.Window{}).Bytes(),
want: (&feewindow.Window{}).Bytes(),
},
{
name: "subnet_evm_invalid_fee_window",
upgrades: extras.TestSubnetEVMChainConfig.NetworkUpgrades,
upgrades: extras.TestEVMChainConfig.NetworkUpgrades,
parent: &types.Header{
Number: big.NewInt(1),
},
header: &types.Header{},
wantErr: subnetevm.ErrWindowInsufficientLength,
wantErr: feewindow.ErrWindowInsufficientLength,
},
{
name: "subnet_evm_invalid_timestamp",
upgrades: extras.TestSubnetEVMChainConfig.NetworkUpgrades,
upgrades: extras.TestEVMChainConfig.NetworkUpgrades,
parent: &types.Header{
Number: big.NewInt(1),
Time: 1,
Extra: (&subnetevm.Window{}).Bytes(),
Extra: (&feewindow.Window{}).Bytes(),
},
header: &types.Header{
Time: 0,
@@ -82,12 +82,12 @@ func TestExtraPrefix(t *testing.T) {
},
{
name: "subnet_evm_normal",
upgrades: extras.TestSubnetEVMChainConfig.NetworkUpgrades,
upgrades: extras.TestEVMChainConfig.NetworkUpgrades,
parent: customtypes.WithHeaderExtra(
&types.Header{
Number: big.NewInt(1),
GasUsed: targetGas,
Extra: (&subnetevm.Window{
Extra: (&feewindow.Window{
1, 2, 3, 4,
}).Bytes(),
},
@@ -99,7 +99,7 @@ func TestExtraPrefix(t *testing.T) {
Time: 1,
},
want: func() []byte {
window := subnetevm.Window{
window := feewindow.Window{
1, 2, 3, 4,
}
window.Add(targetGas)
@@ -132,22 +132,22 @@ func TestVerifyExtraPrefix(t *testing.T) {
}{
{
name: "pre_subnet_evm",
upgrades: extras.TestPreSubnetEVMChainConfig.NetworkUpgrades,
upgrades: extras.TestPreEVMChainConfig.NetworkUpgrades,
header: &types.Header{},
wantErr: nil,
},
{
name: "subnet_evm_invalid_parent_header",
upgrades: extras.TestSubnetEVMChainConfig.NetworkUpgrades,
upgrades: extras.TestEVMChainConfig.NetworkUpgrades,
parent: &types.Header{
Number: big.NewInt(1),
},
header: &types.Header{},
wantErr: subnetevm.ErrWindowInsufficientLength,
wantErr: feewindow.ErrWindowInsufficientLength,
},
{
name: "subnet_evm_invalid_header",
upgrades: extras.TestSubnetEVMChainConfig.NetworkUpgrades,
upgrades: extras.TestEVMChainConfig.NetworkUpgrades,
parent: &types.Header{
Number: big.NewInt(0),
},
@@ -156,12 +156,12 @@ func TestVerifyExtraPrefix(t *testing.T) {
},
{
name: "subnet_evm_valid",
upgrades: extras.TestSubnetEVMChainConfig.NetworkUpgrades,
upgrades: extras.TestEVMChainConfig.NetworkUpgrades,
parent: &types.Header{
Number: big.NewInt(0),
},
header: &types.Header{
Extra: (&subnetevm.Window{}).Bytes(),
Extra: (&feewindow.Window{}).Bytes(),
},
wantErr: nil,
},
@@ -199,25 +199,25 @@ func TestVerifyExtra(t *testing.T) {
{
name: "subnet_evm_valid",
rules: extras.LuxRules{
IsSubnetEVM: true,
IsEVM: true,
},
extra: make([]byte, subnetevm.WindowSize),
extra: make([]byte, feewindow.WindowSize),
expected: nil,
},
{
name: "subnet_evm_invalid_less",
rules: extras.LuxRules{
IsSubnetEVM: true,
IsEVM: true,
},
extra: make([]byte, subnetevm.WindowSize-1),
extra: make([]byte, feewindow.WindowSize-1),
expected: errInvalidExtraLength,
},
{
name: "subnet_evm_invalid_more",
rules: extras.LuxRules{
IsSubnetEVM: true,
IsEVM: true,
},
extra: make([]byte, subnetevm.WindowSize+1),
extra: make([]byte, feewindow.WindowSize+1),
expected: errInvalidExtraLength,
},
{
@@ -225,7 +225,7 @@ func TestVerifyExtra(t *testing.T) {
rules: extras.LuxRules{
IsDurango: true,
},
extra: make([]byte, subnetevm.WindowSize),
extra: make([]byte, feewindow.WindowSize),
expected: nil,
},
{
@@ -233,7 +233,7 @@ func TestVerifyExtra(t *testing.T) {
rules: extras.LuxRules{
IsDurango: true,
},
extra: make([]byte, subnetevm.WindowSize+1),
extra: make([]byte, feewindow.WindowSize+1),
expected: nil,
},
{
@@ -241,7 +241,7 @@ func TestVerifyExtra(t *testing.T) {
rules: extras.LuxRules{
IsDurango: true,
},
extra: make([]byte, subnetevm.WindowSize-1),
extra: make([]byte, feewindow.WindowSize-1),
expected: errInvalidExtraLength,
},
}
@@ -266,18 +266,18 @@ func TestPredicateBytesFromExtra(t *testing.T) {
},
{
name: "too_short",
extra: make([]byte, subnetevm.WindowSize-1),
extra: make([]byte, feewindow.WindowSize-1),
expected: nil,
},
{
name: "empty_predicate",
extra: make([]byte, subnetevm.WindowSize),
extra: make([]byte, feewindow.WindowSize),
expected: nil,
},
{
name: "non_empty_predicate",
extra: []byte{
subnetevm.WindowSize: 5,
feewindow.WindowSize: 5,
},
expected: []byte{5},
},
@@ -299,7 +299,7 @@ func TestSetPredicateBytesInExtra(t *testing.T) {
}{
{
name: "empty_extra_predicate",
want: make([]byte, subnetevm.WindowSize),
want: make([]byte, feewindow.WindowSize),
},
{
name: "extra_too_short",
@@ -307,17 +307,17 @@ func TestSetPredicateBytesInExtra(t *testing.T) {
predicate: []byte{2},
want: []byte{
0: 1,
subnetevm.WindowSize: 2,
feewindow.WindowSize: 2,
},
},
{
name: "extra_too_long",
extra: []byte{
subnetevm.WindowSize: 1,
feewindow.WindowSize: 1,
},
predicate: []byte{2},
want: []byte{
subnetevm.WindowSize: 2,
feewindow.WindowSize: 2,
},
},
}
@@ -341,19 +341,19 @@ func TestPredicateBytesExtra(t *testing.T) {
name: "empty_extra_predicate",
extra: nil,
predicate: nil,
wantExtraWithPredicate: make([]byte, subnetevm.WindowSize),
wantExtraWithPredicate: make([]byte, feewindow.WindowSize),
wantPredicateBytes: nil,
},
{
name: "extra_too_short",
extra: []byte{
0: 1,
subnetevm.WindowSize - 1: 0,
feewindow.WindowSize - 1: 0,
},
predicate: []byte{2},
wantExtraWithPredicate: []byte{
0: 1,
subnetevm.WindowSize: 2,
feewindow.WindowSize: 2,
},
wantPredicateBytes: []byte{2},
},
+5 -5
View File
@@ -30,13 +30,13 @@ func GasLimit(
timestamp uint64,
) (uint64, error) {
switch {
case config.IsSubnetEVM(timestamp):
case config.IsEVM(timestamp):
return feeConfig.GasLimit.Uint64(), nil
default:
// since all chains have activated Subnet-EVM,
// since all chains have activated EVM,
// this code is not used in production. To avoid a dependency on the
// `core` package, this code is modified to just return the parent gas
// limit; which was valid to do prior to Subnet-EVM.
// limit; which was valid to do prior to EVM.
return parent.GasLimit, nil
}
}
@@ -72,10 +72,10 @@ func VerifyGasLimit(
header *types.Header,
) error {
switch {
case config.IsSubnetEVM(header.Time):
case config.IsEVM(header.Time):
expectedGasLimit := feeConfig.GasLimit.Uint64()
if header.GasLimit != expectedGasLimit {
return fmt.Errorf("%w: expected to be %d in Subnet-EVM, but found %d",
return fmt.Errorf("%w: expected to be %d in EVM, but found %d",
errInvalidGasLimit,
expectedGasLimit,
header.GasLimit,
+9 -9
View File
@@ -33,12 +33,12 @@ func GasLimitTest(t *testing.T, feeConfig commontype.FeeConfig) {
}{
{
name: "subnet_evm",
upgrades: extras.TestSubnetEVMChainConfig.NetworkUpgrades,
upgrades: extras.TestEVMChainConfig.NetworkUpgrades,
want: feeConfig.GasLimit.Uint64(),
},
{
name: "pre_subnet_evm",
upgrades: extras.TestPreSubnetEVMChainConfig.NetworkUpgrades,
upgrades: extras.TestPreEVMChainConfig.NetworkUpgrades,
parent: &types.Header{
GasLimit: 1,
},
@@ -78,14 +78,14 @@ func VerifyGasLimitTest(t *testing.T, feeConfig commontype.FeeConfig) {
}{
{
name: "subnet_evm_valid",
upgrades: extras.TestSubnetEVMChainConfig.NetworkUpgrades,
upgrades: extras.TestEVMChainConfig.NetworkUpgrades,
header: &types.Header{
GasLimit: feeConfig.GasLimit.Uint64(),
},
},
{
name: "subnet_evm_invalid",
upgrades: extras.TestSubnetEVMChainConfig.NetworkUpgrades,
upgrades: extras.TestEVMChainConfig.NetworkUpgrades,
header: &types.Header{
GasLimit: feeConfig.GasLimit.Uint64() + 1,
},
@@ -93,7 +93,7 @@ func VerifyGasLimitTest(t *testing.T, feeConfig commontype.FeeConfig) {
},
{
name: "pre_subnet_evm_valid",
upgrades: extras.TestPreSubnetEVMChainConfig.NetworkUpgrades,
upgrades: extras.TestPreEVMChainConfig.NetworkUpgrades,
parent: &types.Header{
GasLimit: 50_000,
},
@@ -103,7 +103,7 @@ func VerifyGasLimitTest(t *testing.T, feeConfig commontype.FeeConfig) {
},
{
name: "pre_subnet_evm_too_low",
upgrades: extras.TestPreSubnetEVMChainConfig.NetworkUpgrades,
upgrades: extras.TestPreEVMChainConfig.NetworkUpgrades,
parent: &types.Header{
GasLimit: ethparams.MinGasLimit,
},
@@ -114,7 +114,7 @@ func VerifyGasLimitTest(t *testing.T, feeConfig commontype.FeeConfig) {
},
{
name: "pre_subnet_evm_too_high",
upgrades: extras.TestPreSubnetEVMChainConfig.NetworkUpgrades,
upgrades: extras.TestPreEVMChainConfig.NetworkUpgrades,
parent: &types.Header{
GasLimit: ethparams.MaxGasLimit,
},
@@ -125,7 +125,7 @@ func VerifyGasLimitTest(t *testing.T, feeConfig commontype.FeeConfig) {
},
{
name: "pre_subnet_evm_too_large",
upgrades: extras.TestPreSubnetEVMChainConfig.NetworkUpgrades,
upgrades: extras.TestPreEVMChainConfig.NetworkUpgrades,
parent: &types.Header{
GasLimit: ethparams.MinGasLimit,
},
@@ -166,7 +166,7 @@ func GasCapacityTest(t *testing.T, feeConfig commontype.FeeConfig) {
}{
{
name: "subnet_evm",
upgrades: extras.TestSubnetEVMChainConfig.NetworkUpgrades,
upgrades: extras.TestEVMChainConfig.NetworkUpgrades,
want: feeConfig.GasLimit.Uint64(),
},
}
+7 -7
View File
@@ -1,17 +1,17 @@
---
title: Subnet-EVM API
title: EVM API
---
[Subnet-EVM](https://github.com/luxfi/evm) APIs are identical to
[EVM](https://github.com/luxfi/evm) APIs are identical to
[Coreth](https://build.lux.network/docs/api-reference/c-chain/api) C-Chain APIs, except Lux Specific APIs
starting with `lux`. Subnet-EVM also supports standard Ethereum APIs as well. For more
starting with `lux`. EVM also supports standard Ethereum APIs as well. For more
information about Coreth APIs see [GitHub](https://github.com/luxfi/coreth).
Subnet-EVM has some additional APIs that are not available in Coreth.
EVM has some additional APIs that are not available in Coreth.
## `eth_feeConfig`
Subnet-EVM comes with an API request for getting fee config at a specific block. You can use this
EVM comes with an API request for getting fee config at a specific block. You can use this
API to check your activated fee config.
**Signature:**
@@ -110,7 +110,7 @@ curl -X POST --data '{
"petersburgBlock": 0,
"istanbulBlock": 0,
"muirGlacierBlock": 0,
"subnetEVMTimestamp": 0,
"evmTimestamp": 0,
"contractDeployerAllowListConfig": {
"adminAddresses": ["0x8db97c7cece249c2b98bdc0226cc4c2a57bf52fc"],
"blockTimestamp": 0
@@ -238,7 +238,7 @@ curl -X POST --data '{
"IsCancun": true
},
"luxRules": {
"IsSubnetEVM": true,
"IsEVM": true,
"IsDurango": true,
"IsEUpgrade": true
},
@@ -1,8 +1,8 @@
// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
// subnetevm defines the dynamic fee window used after subnetevm upgrade.
package subnetevm
// feewindow defines the dynamic fee window used by EVM.
package feewindow
import (
"encoding/binary"
@@ -1,7 +1,7 @@
// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package subnetevm
package feewindow
import (
"math"
+4 -4
View File
@@ -1,6 +1,6 @@
# Validators
The Validators package is a collection of structs and functions to manage the state and uptime of validators in the Subnet-EVM. It consists of the following components:
The Validators package is a collection of structs and functions to manage the state and uptime of validators in the EVM. It consists of the following components:
- State package : The state package stores the validator state and uptime information.
- Uptime package: The uptime package manages the uptime tracking of the validators.
@@ -10,7 +10,7 @@ The Validators package is a collection of structs and functions to manage the st
The state package stores the validator state and uptime information. The state package implements a CRUD interface for validators. The implementation tracks validators by their validationIDs and assumes they're unique per node and their validation period. The state implementation also assumes NodeIDs are unique in the tracked set. The state implementation only allows existing validator's `weight` and `IsActive` fields to be updated; all other fields should be constant and if any other field changes, the state manager errors and does not update the validator.
For L1 validators, an `active` status implies the validator balance on the P-Chain is sufficient to cover the continuous validation fee. When an L1 validator balance is depleted, it is marked as `inactive` on the P-Chain and this information is passed to the Subnet-EVM's state.
For L1 validators, an `active` status implies the validator balance on the P-Chain is sufficient to cover the continuous validation fee. When an L1 validator balance is depleted, it is marked as `inactive` on the P-Chain and this information is passed to the EVM's state.
The state interface allows a listener to register state changes including validator addition, removal, and active status change. The listener always receives the full state when it first subscribes.
@@ -26,7 +26,7 @@ Uptime tracking works as follows:
### StartTracking
Nodes can start uptime tracking with the `StartTracking` method once they're bootstrapped. This method updates the uptime of up-to-date validators by adding the duration between their last updated time and tracker node's initializing time to their uptime. This effectively adds the tracker node's offline duration to the validator's uptime and optimistically assumes that the validators are online during this period. Subnet-EVM's pausable manager does not directly modify this behavior and it also updates validators that were paused/inactive before the node initialized. The pausable uptime manager assumes peers are online and `active` when the tracker nodes are offline.
Nodes can start uptime tracking with the `StartTracking` method once they're bootstrapped. This method updates the uptime of up-to-date validators by adding the duration between their last updated time and tracker node's initializing time to their uptime. This effectively adds the tracker node's offline duration to the validator's uptime and optimistically assumes that the validators are online during this period. EVM's pausable manager does not directly modify this behavior and it also updates validators that were paused/inactive before the node initialized. The pausable uptime manager assumes peers are online and `active` when the tracker nodes are offline.
### Connected
@@ -56,6 +56,6 @@ The `CalculateUptime` method calculates a node's uptime based on its connection
`Manager` struct in `validators` package is responsible for managing the state of the validators by fetching the information from P-Chain state (via `GetCurrentValidatorSet` in chain context) and updating the state accordingly. It dispatches a `goroutine` to sync the validator state every 60 seconds. The manager fetches the up-to-date validator set from P-Chain and performs the sync operation. The sync operation first performs removing the validators from the state that are not in the P-Chain validator set. Then it adds new validators and updates the existing validators in the state. This order of operations ensures that the uptimes of validators being removed and re-added under same nodeIDs are updated in the same sync operation despite having different validationIDs.
P-Chain's `GetCurrentValidatorSet` can report both L1 and Subnet validators. Subnet-EVM's uptime manager also tracks both of these validator types. So even if a the Subnet has not yet been converted to an L1, the uptime and validator state tracking is still performed by Subnet-EVM.
P-Chain's `GetCurrentValidatorSet` can report both L1 and Subnet validators. EVM's uptime manager also tracks both of these validator types. So even if a the Subnet has not yet been converted to an L1, the uptime and validator state tracking is still performed by EVM.
Validator Manager persists the state to disk at the end of every sync operation. The VM also persists the validator database when the node is shutting down.
+13 -13
View File
@@ -32,7 +32,7 @@ import (
"github.com/luxfi/evm/core/txpool"
"github.com/luxfi/evm/eth"
"github.com/luxfi/evm/eth/ethconfig"
subnetevmprometheus "github.com/luxfi/evm/metrics/prometheus"
evmprometheus "github.com/luxfi/evm/metrics/prometheus"
"github.com/luxfi/evm/miner"
"github.com/luxfi/evm/network"
"github.com/luxfi/evm/node"
@@ -40,7 +40,7 @@ import (
"github.com/luxfi/evm/params/extras"
"github.com/luxfi/evm/plugin/evm/config"
gossipHandler "github.com/luxfi/evm/plugin/evm/gossip"
subnetevmlog "github.com/luxfi/evm/plugin/evm/log"
evmlog "github.com/luxfi/evm/plugin/evm/log"
"github.com/luxfi/evm/plugin/evm/message"
"github.com/luxfi/evm/plugin/evm/validators"
"github.com/luxfi/evm/plugin/evm/validators/interfaces"
@@ -155,8 +155,8 @@ var (
errInvalidBlock = errors.New("invalid block")
errInvalidNonce = errors.New("invalid nonce")
errUnclesUnsupported = errors.New("uncles unsupported")
errNilBaseFeeSubnetEVM = errors.New("nil base fee is invalid after subnetEVM")
errNilBlockGasCostSubnetEVM = errors.New("nil blockGasCost is invalid after subnetEVM")
errNilBaseFeeEVM = errors.New("nil base fee is invalid after EVM activation")
errNilBlockGasCostEVM = errors.New("nil blockGasCost is invalid after EVM activation")
errInvalidHeaderPredicateResults = errors.New("invalid header predicate results")
errInitializingLogger = errors.New("failed to initialize logger")
errShuttingDownVM = errors.New("shutting down VM")
@@ -258,7 +258,7 @@ type VM struct {
stateSyncDone chan struct{}
logger subnetevmlog.Logger
logger evmlog.Logger
// State sync server and client
StateSyncServer
StateSyncClient
@@ -397,11 +397,11 @@ func (vm *VM) initializeInternal(
// TODO: Integrate with proper logging from consensus package
contextLogger := log.New()
logWriter := newLoggerWriter(contextLogger)
subnetEVMLogger, err := subnetevmlog.InitLogger(vm.chainAlias, vm.config.LogLevel, vm.config.LogJSONFormat, logWriter)
evmLogger, err := evmlog.InitLogger(vm.chainAlias, vm.config.LogLevel, vm.config.LogJSONFormat, logWriter)
if err != nil {
return fmt.Errorf("%w: %w ", errInitializingLogger, err)
}
vm.logger = subnetEVMLogger
vm.logger = evmLogger
log.Info("Initializing Subnet EVM VM", "Version", Version, "geth version", params.VersionWithMeta, "Config", vm.config)
@@ -689,7 +689,7 @@ func parseGenesis(ctx context.Context, genesisBytes []byte, upgradeBytes []byte,
// Set the default chain config if not provided
if g.Config == nil {
g.Config = params.SubnetEVMDefaultChainConfig
g.Config = params.EVMDefaultChainConfig
}
// Populate the Lux config extras.
@@ -760,9 +760,9 @@ func parseGenesis(ctx context.Context, genesisBytes []byte, upgradeBytes []byte,
if err := json.Unmarshal(genesisBytes, &genesisMap); err == nil {
if configData, ok := genesisMap["config"].(map[string]interface{}); ok {
// Extract network upgrade timestamps
if val, ok := configData["subnetEVMTimestamp"]; ok {
if val, ok := configData["evmTimestamp"]; ok {
if ts, ok := val.(float64); ok {
configExtra.SubnetEVMTimestamp = utils.NewUint64(uint64(ts))
configExtra.EVMTimestamp = utils.NewUint64(uint64(ts))
}
}
if val, ok := configData["durangoTimestamp"]; ok {
@@ -877,7 +877,7 @@ func (vm *VM) initializeMetrics() error {
// Enable metrics collection using our geth's Enable function
metrics.Enable()
vm.sdkMetrics = prometheus.NewRegistry()
gatherer := subnetevmprometheus.NewGatherer(metrics.DefaultRegistry)
gatherer := evmprometheus.NewGatherer(metrics.DefaultRegistry)
// Metrics are handled through sdkMetrics parameter
_ = gatherer
@@ -893,7 +893,7 @@ func (vm *VM) initializeMetrics() error {
func (vm *VM) initializeChain(lastAcceptedHash common.Hash, ethConfig ethconfig.Config) error {
nodecfg := &node.Config{
SubnetEVMVersion: Version,
EVMVersion: Version,
KeyStoreDir: vm.config.KeystoreDirectory,
ExternalSigner: vm.config.KeystoreExternalSigner,
InsecureUnlockAllowed: vm.config.KeystoreInsecureUnlockAllowed,
@@ -1313,7 +1313,7 @@ func (vm *VM) Shutdown(context.Context) error {
}
}
vm.shutdownWg.Wait()
log.Info("Subnet-EVM Shutdown completed")
log.Info("EVM Shutdown completed")
return nil
}
+2 -2
View File
@@ -10,7 +10,7 @@ import (
"github.com/spf13/viper"
)
func subnetEVMFlagSet() *flag.FlagSet {
func evmFlagSet() *flag.FlagSet {
fs := flag.NewFlagSet("evm", flag.ContinueOnError)
fs.Bool(versionKey, false, "If true, print version and quit")
@@ -22,7 +22,7 @@ func subnetEVMFlagSet() *flag.FlagSet {
func getViper() (*viper.Viper, error) {
v := viper.New()
fs := subnetEVMFlagSet()
fs := evmFlagSet()
pflag.CommandLine.AddGoFlagSet(fs)
pflag.Parse()
if err := v.BindPFlags(pflag.CommandLine); err != nil {
+1 -1
View File
@@ -2,7 +2,7 @@
Lux Warp Messaging offers a basic primitive to enable Cross-L1 communication on the Lux Network.
It is intended to allow communication between arbitrary Custom Virtual Machines (including, but not limited to Subnet-EVM and Coreth).
It is intended to allow communication between arbitrary Custom Virtual Machines (including, but not limited to EVM and Coreth).
## How does Lux Warp Messaging Work?
+3 -3
View File
@@ -9,7 +9,7 @@ import (
"github.com/luxfi/codec"
"github.com/luxfi/codec/linearcodec"
"github.com/luxfi/evm/plugin/evm/upgrade/subnetevm"
"github.com/luxfi/evm/plugin/evm/upgrade/feewindow"
"github.com/luxfi/geth/common"
"github.com/luxfi/units"
"github.com/luxfi/utils/wrappers"
@@ -126,10 +126,10 @@ func (r *Results) String() string {
// Returns nil if there are no predicate results (extra data <= WindowSize).
func ParseResultsFromHeaderExtra(extra []byte) (*Results, error) {
// Check if extra data has predicate results beyond the window
if len(extra) <= subnetevm.WindowSize {
if len(extra) <= feewindow.WindowSize {
return nil, nil
}
predicateBytes := extra[subnetevm.WindowSize:]
predicateBytes := extra[feewindow.WindowSize:]
return ParseResults(predicateBytes)
}
+6 -6
View File
@@ -101,15 +101,15 @@ func executeBlockRequestTest(t testing.TB, test blockRequestTest, blocks []*type
}
func TestBlockRequestHandler(t *testing.T) {
// Use TestSubnetEVMChainConfig which doesn't activate Shanghai/Cancun to avoid RLP format mismatch
// Use TestEVMChainConfig which doesn't activate Shanghai/Cancun to avoid RLP format mismatch
var gspec = &core.Genesis{
Config: params.TestSubnetEVMChainConfig,
Config: params.TestEVMChainConfig,
}
memdb := rawdb.NewMemoryDatabase()
tdb := triedb.NewDatabase(memdb, nil)
genesis := gspec.MustCommit(memdb, tdb)
engine := dummy.NewETHFaker()
blocks, _, err := core.GenerateChain(params.TestSubnetEVMChainConfig, genesis, engine, memdb, 96, 0, func(i int, b *core.BlockGen) {})
blocks, _, err := core.GenerateChain(params.TestEVMChainConfig, genesis, engine, memdb, 96, 0, func(i int, b *core.BlockGen) {})
if err != nil {
t.Fatal("unexpected error when generating test blockchain", err)
}
@@ -214,15 +214,15 @@ func TestBlockRequestHandlerLargeBlocks(t *testing.T) {
}
func TestBlockRequestHandlerCtxExpires(t *testing.T) {
// Use TestSubnetEVMChainConfig which doesn't activate Shanghai/Cancun to avoid RLP format mismatch
// Use TestEVMChainConfig which doesn't activate Shanghai/Cancun to avoid RLP format mismatch
var gspec = &core.Genesis{
Config: params.TestSubnetEVMChainConfig,
Config: params.TestEVMChainConfig,
}
memdb := rawdb.NewMemoryDatabase()
tdb := triedb.NewDatabase(memdb, nil)
genesis := gspec.MustCommit(memdb, tdb)
engine := dummy.NewETHFaker()
blocks, _, err := core.GenerateChain(params.TestSubnetEVMChainConfig, genesis, engine, memdb, 11, 0, func(i int, b *core.BlockGen) {})
blocks, _, err := core.GenerateChain(params.TestEVMChainConfig, genesis, engine, memdb, 11, 0, func(i int, b *core.BlockGen) {})
if err != nil {
t.Fatal("unexpected error when generating test blockchain", err)
}
+5 -5
View File
@@ -158,7 +158,7 @@ var Forks = map[string]*params.ChainConfig{
PetersburgBlock: big.NewInt(0),
IstanbulBlock: big.NewInt(5),
},
"Pre-SubnetEVM": {
"Pre-EVM": {
ChainID: big.NewInt(1),
HomesteadBlock: big.NewInt(0),
EIP150Block: big.NewInt(0),
@@ -170,7 +170,7 @@ var Forks = map[string]*params.ChainConfig{
IstanbulBlock: big.NewInt(0),
MuirGlacierBlock: big.NewInt(0),
},
"SubnetEVM": params.WithExtra(
"EVM": params.WithExtra(
&params.ChainConfig{
ChainID: big.NewInt(1),
HomesteadBlock: big.NewInt(0),
@@ -186,7 +186,7 @@ var Forks = map[string]*params.ChainConfig{
},
&extras.ChainConfig{
NetworkUpgrades: extras.NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(0),
EVMTimestamp: utils.NewUint64(0),
},
},
),
@@ -206,7 +206,7 @@ var Forks = map[string]*params.ChainConfig{
},
&extras.ChainConfig{
NetworkUpgrades: extras.NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(0),
EVMTimestamp: utils.NewUint64(0),
DurangoTimestamp: utils.NewUint64(0),
},
},
@@ -229,7 +229,7 @@ var Forks = map[string]*params.ChainConfig{
},
&extras.ChainConfig{
NetworkUpgrades: extras.NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(0),
EVMTimestamp: utils.NewUint64(0),
DurangoTimestamp: utils.NewUint64(0),
},
},
+6 -6
View File
@@ -164,11 +164,11 @@ func GetChainConfig(forkString string) (baseConfig *params.ChainConfig, eips []i
// NOTE: this is added to support mapping geth fork names to
// evm fork names.
forkAliases := map[string]string{
"Berlin": "Pre-SubnetEVM",
"London": "SubnetEVM",
"ArrowGlacier": "SubnetEVM",
"GrayGlacier": "SubnetEVM",
"Merge": "SubnetEVM",
"Berlin": "Pre-EVM",
"London": "EVM",
"ArrowGlacier": "EVM",
"GrayGlacier": "EVM",
"Merge": "EVM",
}
if alias, ok := forkAliases[baseName]; ok {
baseName = alias
@@ -268,7 +268,7 @@ func (t *StateTest) RunNoVerify(subtest StateSubtest, vmconfig vm.Config, snapsh
state = MakePreState(rawdb.NewMemoryDatabase(), t.json.Pre, snapshotter, scheme)
var baseFee *big.Int
if params.GetExtra(config).IsSubnetEVM(0) {
if params.GetExtra(config).IsEVM(0) {
baseFee = t.json.Env.BaseFee
if baseFee == nil {
// Retesteth uses `0x10` for genesis baseFee. Therefore, it defaults to
+1 -1
View File
@@ -3,7 +3,7 @@
//go:build tools
package subnetevm
package evm
import (
_ "github.com/fjl/gencodec"
+4 -4
View File
@@ -14,8 +14,8 @@ import (
"github.com/luxfi/ids"
)
// SubnetEVMTestChainID is a evm specific chain ID for testing
var SubnetEVMTestChainID = ids.GenerateTestID()
// EVMTestChainID is a evm specific chain ID for testing
var EVMTestChainID = ids.GenerateTestID()
// testValidatorState wraps validatorstest.State to implement consensuscontext.ValidatorState
type testValidatorState struct {
@@ -102,7 +102,7 @@ func NewTestValidatorState() consensuscontext.ValidatorState {
},
// GetSubnetIDF: func(chainID ids.ID) (ids.ID, error) { // TODO: Fix GetSubnetIDF field
// // For testing, all chains belong to the primary network
// if chainID == constants.PlatformChainID || chainID == SubnetEVMTestChainID {
// if chainID == constants.PlatformChainID || chainID == EVMTestChainID {
// return constants.PrimaryNetworkID, nil
// }
// // Default to primary network for any test chain
@@ -139,7 +139,7 @@ func NewTestValidatorStateFromBase(baseState *validatorstest.State) consensuscon
// This function ensures that the consensus context has a properly configured validator state
// that includes the GetValidatorSetF function, which is required by many tests.
func NewTestConsensusContext(t testing.TB) context.Context {
consensusCtx := consensustest.Context(t, SubnetEVMTestChainID)
consensusCtx := consensustest.Context(t, EVMTestChainID)
// Create a standard context and add the consensus context to it
ctx := context.Background()
ctx = consensuscontext.WithContext(ctx, consensusCtx)
+1 -1
View File
@@ -31,7 +31,7 @@ func TestNewTestConsensusContext(t *testing.T) {
require.Equal(t, uint64(0), height)
// Test GetSubnetID
subnetID, err := validatorState.GetSubnetID(SubnetEVMTestChainID)
subnetID, err := validatorState.GetSubnetID(EVMTestChainID)
require.NoError(t, err)
require.Equal(t, ids.Empty, subnetID) // Default returns empty ID
}