good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
081642ed
Commit
081642ed
authored
Aug 8, 2019
by
Martin Holst Swende
Committed by
Péter Szilágyi
Aug 8, 2019
Browse files
Options
Downloads
Patches
Plain Diff
Eip 1344 (ChainID opcode) (#19921)
* core/vm: implement EIP 1344 (ChainID opcode) * core/vm: formatting
parent
17589aa7
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/vm/eips.go
+23
-1
23 additions, 1 deletion
core/vm/eips.go
core/vm/opcodes.go
+3
-0
3 additions, 0 deletions
core/vm/opcodes.go
with
26 additions
and
1 deletion
core/vm/eips.go
+
23
−
1
View file @
081642ed
...
@@ -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
}
This diff is collapsed.
Click to expand it.
core/vm/opcodes.go
+
3
−
0
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
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment