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
2d3c3674
Commit
2d3c3674
authored
Jan 03, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated stack based vm
parent
6ab61f2c
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
221 additions
and
225 deletions
+221
-225
parsing.go
parsing.go
+23
-44
vm.go
vm.go
+147
-173
vm_test.go
vm_test.go
+51
-8
No files found.
parsing.go
View file @
2d3c3674
...
@@ -10,50 +10,29 @@ import (
...
@@ -10,50 +10,29 @@ import (
// Op codes
// Op codes
var
OpCodes
=
map
[
string
]
string
{
var
OpCodes
=
map
[
string
]
string
{
"STOP"
:
"0"
,
"STOP"
:
"0"
,
"PUSH"
:
"48"
,
// 0x30
"ADD"
:
"1"
,
"POP"
:
"49"
,
// 0x31
"MUL"
:
"2"
,
"LOAD"
:
"54"
,
// 0x36
"SUB"
:
"3"
,
"DIV"
:
"4"
,
/* OLD VM OPCODES
"SDIV"
:
"5"
,
"ADD": "16", // 0x10
"MOD"
:
"6"
,
"SUB": "17", // 0x11
"SMOD"
:
"7"
,
"MUL": "18", // 0x12
"EXP"
:
"8"
,
"DIV": "19", // 0x13
"NEG"
:
"9"
,
"SDIV": "20", // 0x14
"LT"
:
"10"
,
"MOD": "21", // 0x15
"LE"
:
"11"
,
"SMOD": "22", // 0x16
"GT"
:
"12"
,
"EXP": "23", // 0x17
"GE"
:
"13"
,
"NEG": "24", // 0x18
"EQ"
:
"14"
,
"LT": "32", // 0x20
"NOT"
:
"15"
,
"LE": "33", // 0x21
"MYADDRESS"
:
"16"
,
"GT": "34", // 0x22
"TXSENDER"
:
"17"
,
"GE": "35", // 0x23
"EQ": "36", // 0x24
"NOT": "37", // 0x25
"PUSH"
:
"48"
,
"SHA256": "48", // 0x30
"POP"
:
"49"
,
"RIPEMD160": "49", // 0x31
"LOAD"
:
"54"
,
"ECMUL": "50", // 0x32
"ECADD": "51", // 0x33
"SIGN": "52", // 0x34
"RECOVER": "53", // 0x35
"COPY": "64", // 0x40
"ST": "65", // 0x41
"LD": "66", // 0x42
"SET": "67", // 0x43
"JMP": "80", // 0x50
"JMPI": "81", // 0x51
"IND": "82", // 0x52
"EXTRO": "96", // 0x60
"BALANCE": "97", // 0x61
"MKTX": "112", // 0x70
"DATA": "128", // 0x80
"DATAN": "129", // 0x81
"MYADDRESS": "144", // 0x90
"BLKHASH": "145", // 0x91
"COINBASE": "146", // 0x92
"SUICIDE": "255", // 0xff
*/
}
}
...
...
vm.go
View file @
2d3c3674
This diff is collapsed.
Click to expand it.
vm_test.go
View file @
2d3c3674
...
@@ -7,23 +7,66 @@ import (
...
@@ -7,23 +7,66 @@ import (
func
TestVm
(
t
*
testing
.
T
)
{
func
TestVm
(
t
*
testing
.
T
)
{
InitFees
()
db
,
_
:=
NewMemDatabase
()
db
,
_
:=
NewMemDatabase
()
Db
=
db
Db
=
db
ctrct
:=
NewTransaction
(
""
,
20
,
[]
string
{
ctrct
:=
NewTransaction
(
""
,
200000000
,
[]
string
{
"PUSH"
,
"PUSH"
,
"1a2f2e"
,
"1a2f2e"
,
"PUSH"
,
"hallo"
,
"PUSH"
,
"hallo"
,
"POP"
,
// POP hallo
"POP"
,
// POP hallo
"PUSH"
,
"PUSH"
,
"3"
,
"3"
,
"LOAD"
,
// Load hallo back on the stack
"LOAD"
,
// Load hallo back on the stack
"PUSH"
,
"1"
,
"PUSH"
,
"2"
,
"ADD"
,
"PUSH"
,
"2"
,
"PUSH"
,
"1"
,
"SUB"
,
"PUSH"
,
"100000000000000000000000"
,
"PUSH"
,
"10000000000000"
,
"SDIV"
,
"PUSH"
,
"105"
,
"PUSH"
,
"200"
,
"MOD"
,
"PUSH"
,
"100000000000000000000000"
,
"PUSH"
,
"10000000000000"
,
"SMOD"
,
"PUSH"
,
"5"
,
"PUSH"
,
"10"
,
"LT"
,
"PUSH"
,
"5"
,
"PUSH"
,
"5"
,
"LE"
,
"PUSH"
,
"50"
,
"PUSH"
,
"5"
,
"GT"
,
"PUSH"
,
"5"
,
"PUSH"
,
"5"
,
"GE"
,
"PUSH"
,
"10"
,
"PUSH"
,
"10"
,
"NOT"
,
"MYADDRESS"
,
"TXSENDER"
,
"STOP"
,
"STOP"
,
})
})
tx
:=
NewTransaction
(
"1e8a42ea8cce13"
,
100
,
[]
string
{})
tx
:=
NewTransaction
(
"1e8a42ea8cce13"
,
100
,
[]
string
{})
block
:=
CreateBlock
(
""
,
0
,
""
,
""
,
0
,
0
,
""
,
[]
*
Transaction
{
ctrct
,
tx
})
block
:=
CreateBlock
(
""
,
0
,
""
,
"
c014ba53
"
,
0
,
0
,
""
,
[]
*
Transaction
{
ctrct
,
tx
})
db
.
Put
(
block
.
Hash
(),
block
.
MarshalRlp
())
db
.
Put
(
block
.
Hash
(),
block
.
MarshalRlp
())
bm
:=
NewBlockManager
()
bm
:=
NewBlockManager
()
...
...
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