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
081642ed
Commit
081642ed
authored
Aug 08, 2019
by
Martin Holst Swende
Committed by
Péter Szilágyi
Aug 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Eip 1344 (ChainID opcode) (#19921)
* core/vm: implement EIP 1344 (ChainID opcode) * core/vm: formatting
parent
17589aa7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
1 deletion
+26
-1
eips.go
core/vm/eips.go
+23
-1
opcodes.go
core/vm/opcodes.go
+3
-0
No files found.
core/vm/eips.go
View file @
081642ed
...
@@ -18,7 +18,7 @@ package vm
...
@@ -18,7 +18,7 @@ package vm
import
(
import
(
"fmt"
"fmt"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/params"
)
)
...
@@ -29,6 +29,8 @@ func EnableEIP(eipNum int, jt *JumpTable) error {
...
@@ -29,6 +29,8 @@ func EnableEIP(eipNum int, jt *JumpTable) error {
switch
eipNum
{
switch
eipNum
{
case
1884
:
case
1884
:
enable1884
(
jt
)
enable1884
(
jt
)
case
1344
:
enable1344
(
jt
)
default
:
default
:
return
fmt
.
Errorf
(
"undefined eip %d"
,
eipNum
)
return
fmt
.
Errorf
(
"undefined eip %d"
,
eipNum
)
}
}
...
@@ -61,3 +63,23 @@ func opSelfBalance(pc *uint64, interpreter *EVMInterpreter, contract *Contract,
...
@@ -61,3 +63,23 @@ func opSelfBalance(pc *uint64, interpreter *EVMInterpreter, contract *Contract,
stack
.
push
(
balance
)
stack
.
push
(
balance
)
return
nil
,
nil
return
nil
,
nil
}
}
// enable1344 applies EIP-1344 (ChainID Opcode)
// - Adds an opcode that returns the current chain’s EIP-155 unique identifier
func
enable1344
(
jt
*
JumpTable
)
{
// New opcode
jt
[
CHAINID
]
=
operation
{
execute
:
opChainID
,
constantGas
:
GasQuickStep
,
minStack
:
minStack
(
0
,
1
),
maxStack
:
maxStack
(
0
,
1
),
valid
:
true
,
}
}
// opChainID implements CHAINID opcode
func
opChainID
(
pc
*
uint64
,
interpreter
*
EVMInterpreter
,
contract
*
Contract
,
memory
*
Memory
,
stack
*
Stack
)
([]
byte
,
error
)
{
chainId
:=
interpreter
.
intPool
.
get
()
.
Set
(
interpreter
.
evm
.
chainConfig
.
ChainID
)
stack
.
push
(
chainId
)
return
nil
,
nil
}
core/vm/opcodes.go
View file @
081642ed
...
@@ -101,6 +101,7 @@ const (
...
@@ -101,6 +101,7 @@ const (
NUMBER
NUMBER
DIFFICULTY
DIFFICULTY
GASLIMIT
GASLIMIT
CHAINID
=
0x46
SELFBALANCE
=
0x47
SELFBALANCE
=
0x47
)
)
...
@@ -278,6 +279,7 @@ var opCodeToString = map[OpCode]string{
...
@@ -278,6 +279,7 @@ var opCodeToString = map[OpCode]string{
NUMBER
:
"NUMBER"
,
NUMBER
:
"NUMBER"
,
DIFFICULTY
:
"DIFFICULTY"
,
DIFFICULTY
:
"DIFFICULTY"
,
GASLIMIT
:
"GASLIMIT"
,
GASLIMIT
:
"GASLIMIT"
,
CHAINID
:
"CHAINID"
,
SELFBALANCE
:
"SELFBALANCE"
,
SELFBALANCE
:
"SELFBALANCE"
,
// 0x50 range - 'storage' and execution.
// 0x50 range - 'storage' and execution.
...
@@ -430,6 +432,7 @@ var stringToOp = map[string]OpCode{
...
@@ -430,6 +432,7 @@ var stringToOp = map[string]OpCode{
"CALLDATALOAD"
:
CALLDATALOAD
,
"CALLDATALOAD"
:
CALLDATALOAD
,
"CALLDATASIZE"
:
CALLDATASIZE
,
"CALLDATASIZE"
:
CALLDATASIZE
,
"CALLDATACOPY"
:
CALLDATACOPY
,
"CALLDATACOPY"
:
CALLDATACOPY
,
"CHAINID"
:
CHAINID
,
"DELEGATECALL"
:
DELEGATECALL
,
"DELEGATECALL"
:
DELEGATECALL
,
"STATICCALL"
:
STATICCALL
,
"STATICCALL"
:
STATICCALL
,
"CODESIZE"
:
CODESIZE
,
"CODESIZE"
:
CODESIZE
,
...
...
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