Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
efc9409c
Unverified
Commit
efc9409c
authored
Sep 27, 2022
by
Marius van der Wijden
Committed by
Péter Szilágyi
Jan 03, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
params: core: enable shanghai based on timestamps
parent
dad92500
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
23 additions
and
21 deletions
+23
-21
state_transition.go
core/state_transition.go
+1
-1
evm.go
core/vm/evm.go
+1
-1
runtime.go
core/vm/runtime/runtime.go
+3
-3
goja.go
eth/tracers/js/goja.go
+1
-1
4byte.go
eth/tracers/native/4byte.go
+1
-1
api.go
internal/ethapi/api.go
+1
-1
config.go
params/config.go
+15
-13
No files found.
core/state_transition.go
View file @
efc9409c
...
...
@@ -300,7 +300,7 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
var
(
msg
=
st
.
msg
sender
=
vm
.
AccountRef
(
msg
.
From
())
rules
=
st
.
evm
.
ChainConfig
()
.
Rules
(
st
.
evm
.
Context
.
BlockNumber
,
st
.
evm
.
Context
.
Random
!=
nil
)
rules
=
st
.
evm
.
ChainConfig
()
.
Rules
(
st
.
evm
.
Context
.
BlockNumber
,
st
.
evm
.
Context
.
Random
!=
nil
,
st
.
evm
.
Context
.
Time
)
contractCreation
=
msg
.
To
()
==
nil
)
...
...
core/vm/evm.go
View file @
efc9409c
...
...
@@ -131,7 +131,7 @@ func NewEVM(blockCtx BlockContext, txCtx TxContext, statedb StateDB, chainConfig
StateDB
:
statedb
,
Config
:
config
,
chainConfig
:
chainConfig
,
chainRules
:
chainConfig
.
Rules
(
blockCtx
.
BlockNumber
,
blockCtx
.
Random
!=
nil
),
chainRules
:
chainConfig
.
Rules
(
blockCtx
.
BlockNumber
,
blockCtx
.
Random
!=
nil
,
blockCtx
.
Time
),
}
evm
.
interpreter
=
NewEVMInterpreter
(
evm
,
config
)
return
evm
...
...
core/vm/runtime/runtime.go
View file @
efc9409c
...
...
@@ -117,7 +117,7 @@ func Execute(code, input []byte, cfg *Config) ([]byte, *state.StateDB, error) {
address
=
common
.
BytesToAddress
([]
byte
(
"contract"
))
vmenv
=
NewEnv
(
cfg
)
sender
=
vm
.
AccountRef
(
cfg
.
Origin
)
rules
=
cfg
.
ChainConfig
.
Rules
(
vmenv
.
Context
.
BlockNumber
,
vmenv
.
Context
.
Random
!=
nil
)
rules
=
cfg
.
ChainConfig
.
Rules
(
vmenv
.
Context
.
BlockNumber
,
vmenv
.
Context
.
Random
!=
nil
,
vmenv
.
Context
.
Time
)
)
// Execute the preparatory steps for state transition which includes:
// - prepare accessList(post-berlin)
...
...
@@ -151,7 +151,7 @@ func Create(input []byte, cfg *Config) ([]byte, common.Address, uint64, error) {
var
(
vmenv
=
NewEnv
(
cfg
)
sender
=
vm
.
AccountRef
(
cfg
.
Origin
)
rules
=
cfg
.
ChainConfig
.
Rules
(
vmenv
.
Context
.
BlockNumber
,
vmenv
.
Context
.
Random
!=
nil
)
rules
=
cfg
.
ChainConfig
.
Rules
(
vmenv
.
Context
.
BlockNumber
,
vmenv
.
Context
.
Random
!=
nil
,
vmenv
.
Context
.
Time
)
)
// Execute the preparatory steps for state transition which includes:
// - prepare accessList(post-berlin)
...
...
@@ -180,7 +180,7 @@ func Call(address common.Address, input []byte, cfg *Config) ([]byte, uint64, er
vmenv
=
NewEnv
(
cfg
)
sender
=
cfg
.
State
.
GetOrNewStateObject
(
cfg
.
Origin
)
statedb
=
cfg
.
State
rules
=
cfg
.
ChainConfig
.
Rules
(
vmenv
.
Context
.
BlockNumber
,
vmenv
.
Context
.
Random
!=
nil
)
rules
=
cfg
.
ChainConfig
.
Rules
(
vmenv
.
Context
.
BlockNumber
,
vmenv
.
Context
.
Random
!=
nil
,
vmenv
.
Context
.
Time
)
)
// Execute the preparatory steps for state transition which includes:
// - prepare accessList(post-berlin)
...
...
eth/tracers/js/goja.go
View file @
efc9409c
...
...
@@ -242,7 +242,7 @@ func (t *jsTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Addr
t
.
ctx
[
"value"
]
=
valueBig
t
.
ctx
[
"block"
]
=
t
.
vm
.
ToValue
(
env
.
Context
.
BlockNumber
.
Uint64
())
// Update list of precompiles based on current block
rules
:=
env
.
ChainConfig
()
.
Rules
(
env
.
Context
.
BlockNumber
,
env
.
Context
.
Random
!=
nil
)
rules
:=
env
.
ChainConfig
()
.
Rules
(
env
.
Context
.
BlockNumber
,
env
.
Context
.
Random
!=
nil
,
env
.
Context
.
Time
)
t
.
activePrecompiles
=
vm
.
ActivePrecompiles
(
rules
)
}
...
...
eth/tracers/native/4byte.go
View file @
efc9409c
...
...
@@ -81,7 +81,7 @@ func (t *fourByteTracer) store(id []byte, size int) {
// CaptureStart implements the EVMLogger interface to initialize the tracing operation.
func
(
t
*
fourByteTracer
)
CaptureStart
(
env
*
vm
.
EVM
,
from
common
.
Address
,
to
common
.
Address
,
create
bool
,
input
[]
byte
,
gas
uint64
,
value
*
big
.
Int
)
{
// Update list of precompiles based on current block
rules
:=
env
.
ChainConfig
()
.
Rules
(
env
.
Context
.
BlockNumber
,
env
.
Context
.
Random
!=
nil
)
rules
:=
env
.
ChainConfig
()
.
Rules
(
env
.
Context
.
BlockNumber
,
env
.
Context
.
Random
!=
nil
,
env
.
Context
.
Time
)
t
.
activePrecompiles
=
vm
.
ActivePrecompiles
(
rules
)
// Save the outer calldata also
...
...
internal/ethapi/api.go
View file @
efc9409c
...
...
@@ -1440,7 +1440,7 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH
}
isPostMerge
:=
header
.
Difficulty
.
Cmp
(
common
.
Big0
)
==
0
// Retrieve the precompiles since they don't need to be added to the access list
precompiles
:=
vm
.
ActivePrecompiles
(
b
.
ChainConfig
()
.
Rules
(
header
.
Number
,
isPostMerge
))
precompiles
:=
vm
.
ActivePrecompiles
(
b
.
ChainConfig
()
.
Rules
(
header
.
Number
,
isPostMerge
,
new
(
big
.
Int
)
.
SetUint64
(
header
.
Time
)
))
// Create an initial tracer
prevTracer
:=
logger
.
NewAccessListTracer
(
nil
,
args
.
from
(),
to
,
precompiles
)
...
...
params/config.go
View file @
efc9409c
...
...
@@ -281,7 +281,7 @@ var (
TestChainConfig
=
&
ChainConfig
{
big
.
NewInt
(
1
),
big
.
NewInt
(
0
),
nil
,
false
,
big
.
NewInt
(
0
),
common
.
Hash
{},
big
.
NewInt
(
0
),
big
.
NewInt
(
0
),
big
.
NewInt
(
0
),
big
.
NewInt
(
0
),
big
.
NewInt
(
0
),
big
.
NewInt
(
0
),
big
.
NewInt
(
0
),
big
.
NewInt
(
0
),
big
.
NewInt
(
0
),
big
.
NewInt
(
0
),
big
.
NewInt
(
0
),
nil
,
nil
,
nil
,
nil
,
false
,
new
(
EthashConfig
),
nil
}
NonActivatedConfig
=
&
ChainConfig
{
big
.
NewInt
(
1
),
nil
,
nil
,
false
,
nil
,
common
.
Hash
{},
nil
,
nil
,
nil
,
nil
,
nil
,
nil
,
nil
,
nil
,
nil
,
nil
,
nil
,
nil
,
nil
,
nil
,
nil
,
false
,
new
(
EthashConfig
),
nil
}
TestRules
=
TestChainConfig
.
Rules
(
new
(
big
.
Int
),
false
)
TestRules
=
TestChainConfig
.
Rules
(
new
(
big
.
Int
),
false
,
new
(
big
.
Int
)
)
)
// NetworkNames are user friendly names to use in the chain spec banner.
...
...
@@ -371,7 +371,7 @@ type ChainConfig struct {
ArrowGlacierBlock
*
big
.
Int
`json:"arrowGlacierBlock,omitempty"`
// Eip-4345 (bomb delay) switch block (nil = no fork, 0 = already activated)
GrayGlacierBlock
*
big
.
Int
`json:"grayGlacierBlock,omitempty"`
// Eip-5133 (bomb delay) switch block (nil = no fork, 0 = already activated)
MergeNetsplitBlock
*
big
.
Int
`json:"mergeNetsplitBlock,omitempty"`
// Virtual fork after The Merge to use as a network splitter
Shanghai
Block
*
big
.
Int
`json:"shanghaiBlock,omitempty"`
// Shanghai switch block
(nil = no fork, 0 = already on shanghai)
Shanghai
Time
*
big
.
Int
`json:"shanghaiBlock,omitempty"`
// Shanghai switch time
(nil = no fork, 0 = already on shanghai)
CancunBlock
*
big
.
Int
`json:"cancunBlock,omitempty"`
// Cancun switch block (nil = no fork, 0 = already on cancun)
// TerminalTotalDifficulty is the amount of total difficulty reached by
...
...
@@ -465,8 +465,8 @@ func (c *ChainConfig) Description() string {
if
c
.
GrayGlacierBlock
!=
nil
{
banner
+=
fmt
.
Sprintf
(
" - Gray Glacier: %-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/gray-glacier.md)
\n
"
,
c
.
GrayGlacierBlock
)
}
if
c
.
Shanghai
Block
!=
nil
{
banner
+=
fmt
.
Sprintf
(
" - Shanghai: %-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/shanghai.md)
\n
"
,
c
.
Shanghai
Block
)
if
c
.
Shanghai
Time
!=
nil
{
banner
+=
fmt
.
Sprintf
(
" - Shanghai: %-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/shanghai.md)
\n
"
,
c
.
Shanghai
Time
)
}
if
c
.
CancunBlock
!=
nil
{
banner
+=
fmt
.
Sprintf
(
" - Cancun: %-8v
\n
"
,
c
.
CancunBlock
)
...
...
@@ -567,9 +567,9 @@ func (c *ChainConfig) IsTerminalPoWBlock(parentTotalDiff *big.Int, totalDiff *bi
return
parentTotalDiff
.
Cmp
(
c
.
TerminalTotalDifficulty
)
<
0
&&
totalDiff
.
Cmp
(
c
.
TerminalTotalDifficulty
)
>=
0
}
// IsShanghai returns whether
num is either equal to the Shanghai fork block
or greater.
func
(
c
*
ChainConfig
)
IsShanghai
(
num
*
big
.
Int
)
bool
{
return
isForked
(
c
.
Shanghai
Block
,
num
)
// IsShanghai returns whether
time is either equal to the Shanghai fork time
or greater.
func
(
c
*
ChainConfig
)
IsShanghai
(
time
*
big
.
Int
)
bool
{
return
isForked
(
c
.
Shanghai
Time
,
time
)
}
// IsCancun returns whether num is either equal to the Cancun fork block or greater.
...
...
@@ -620,7 +620,7 @@ func (c *ChainConfig) CheckConfigForkOrder() error {
{
name
:
"arrowGlacierBlock"
,
block
:
c
.
ArrowGlacierBlock
,
optional
:
true
},
{
name
:
"grayGlacierBlock"
,
block
:
c
.
GrayGlacierBlock
,
optional
:
true
},
{
name
:
"mergeNetsplitBlock"
,
block
:
c
.
MergeNetsplitBlock
,
optional
:
true
},
{
name
:
"shanghaiBlock"
,
block
:
c
.
ShanghaiBlock
,
optional
:
true
},
//
{name: "shanghaiBlock", block: c.ShanghaiBlock, optional: true},
{
name
:
"cancunBlock"
,
block
:
c
.
CancunBlock
,
optional
:
true
},
}
{
if
lastFork
.
name
!=
""
{
...
...
@@ -700,9 +700,11 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, head *big.Int) *Confi
if
isForkIncompatible
(
c
.
MergeNetsplitBlock
,
newcfg
.
MergeNetsplitBlock
,
head
)
{
return
newCompatError
(
"Merge netsplit fork block"
,
c
.
MergeNetsplitBlock
,
newcfg
.
MergeNetsplitBlock
)
}
if
isForkIncompatible
(
c
.
ShanghaiBlock
,
newcfg
.
ShanghaiBlock
,
head
)
{
return
newCompatError
(
"Shanghai fork block"
,
c
.
ShanghaiBlock
,
newcfg
.
ShanghaiBlock
)
}
/*
if isForkIncompatible(c.ShanghaiBlock, newcfg.ShanghaiBlock, head) {
return newCompatError("Shanghai fork block", c.ShanghaiBlock, newcfg.ShanghaiBlock)
}
*/
if
isForkIncompatible
(
c
.
CancunBlock
,
newcfg
.
CancunBlock
,
head
)
{
return
newCompatError
(
"Cancun fork block"
,
c
.
CancunBlock
,
newcfg
.
CancunBlock
)
}
...
...
@@ -788,7 +790,7 @@ type Rules struct {
}
// Rules ensures c's ChainID is not nil.
func
(
c
*
ChainConfig
)
Rules
(
num
*
big
.
Int
,
isMerge
bool
)
Rules
{
func
(
c
*
ChainConfig
)
Rules
(
num
*
big
.
Int
,
isMerge
bool
,
timestamp
*
big
.
Int
)
Rules
{
chainID
:=
c
.
ChainID
if
chainID
==
nil
{
chainID
=
new
(
big
.
Int
)
...
...
@@ -806,7 +808,7 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool) Rules {
IsBerlin
:
c
.
IsBerlin
(
num
),
IsLondon
:
c
.
IsLondon
(
num
),
IsMerge
:
isMerge
,
IsShanghai
:
c
.
IsShanghai
(
num
),
IsShanghai
:
c
.
IsShanghai
(
timestamp
),
isCancun
:
c
.
IsCancun
(
num
),
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment