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
34c8045d
Commit
34c8045d
authored
10 years ago
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed issue where JUMPI would do an equally check with 1 instead of GT
parent
a90ffe1a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
34 deletions
+47
-34
state.go
ethchain/state.go
+2
-0
state_transition.go
ethchain/state_transition.go
+2
-20
transaction.go
ethchain/transaction.go
+1
-1
vm.go
ethchain/vm.go
+9
-5
trie_test.go
ethutil/trie_test.go
+33
-8
No files found.
ethchain/state.go
View file @
34c8045d
...
@@ -120,6 +120,8 @@ func (self *State) GetOrNewStateObject(addr []byte) *StateObject {
...
@@ -120,6 +120,8 @@ func (self *State) GetOrNewStateObject(addr []byte) *StateObject {
}
}
func
(
self
*
State
)
NewStateObject
(
addr
[]
byte
)
*
StateObject
{
func
(
self
*
State
)
NewStateObject
(
addr
[]
byte
)
*
StateObject
{
ethutil
.
Config
.
Log
.
Printf
(
ethutil
.
LogLevelInfo
,
"(+) %x
\n
"
,
addr
)
stateObject
:=
NewStateObject
(
addr
)
stateObject
:=
NewStateObject
(
addr
)
self
.
stateObjects
[
string
(
addr
)]
=
stateObject
self
.
stateObjects
[
string
(
addr
)]
=
stateObject
...
...
This diff is collapsed.
Click to expand it.
ethchain/state_transition.go
View file @
34c8045d
...
@@ -97,7 +97,6 @@ func (self *StateTransition) BuyGas() error {
...
@@ -97,7 +97,6 @@ func (self *StateTransition) BuyGas() error {
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
//self.state.UpdateStateObject(coinbase)
self
.
AddGas
(
self
.
tx
.
Gas
)
self
.
AddGas
(
self
.
tx
.
Gas
)
sender
.
SubAmount
(
self
.
tx
.
GasValue
())
sender
.
SubAmount
(
self
.
tx
.
GasValue
())
...
@@ -115,7 +114,7 @@ func (self *StateTransition) RefundGas() {
...
@@ -115,7 +114,7 @@ func (self *StateTransition) RefundGas() {
}
}
func
(
self
*
StateTransition
)
TransitionState
()
(
err
error
)
{
func
(
self
*
StateTransition
)
TransitionState
()
(
err
error
)
{
//snapshot := st.state.Snapshot(
)
ethutil
.
Config
.
Log
.
Printf
(
ethutil
.
LogLevelInfo
,
"(~) %x
\n
"
,
self
.
tx
.
Hash
()
)
/*
/*
defer func() {
defer func() {
...
@@ -132,8 +131,6 @@ func (self *StateTransition) TransitionState() (err error) {
...
@@ -132,8 +131,6 @@ func (self *StateTransition) TransitionState() (err error) {
receiver
*
StateObject
receiver
*
StateObject
)
)
ethutil
.
Config
.
Log
.
Printf
(
ethutil
.
LogLevelInfo
,
"(~) %x
\n
"
,
tx
.
Hash
())
// Make sure this transaction's nonce is correct
// Make sure this transaction's nonce is correct
if
sender
.
Nonce
!=
tx
.
Nonce
{
if
sender
.
Nonce
!=
tx
.
Nonce
{
return
NonceError
(
tx
.
Nonce
,
sender
.
Nonce
)
return
NonceError
(
tx
.
Nonce
,
sender
.
Nonce
)
...
@@ -146,26 +143,11 @@ func (self *StateTransition) TransitionState() (err error) {
...
@@ -146,26 +143,11 @@ func (self *StateTransition) TransitionState() (err error) {
// XXX Transactions after this point are considered valid.
// XXX Transactions after this point are considered valid.
defer
func
()
{
defer
self
.
RefundGas
()
self
.
RefundGas
()
/*
if sender != nil {
self.state.UpdateStateObject(sender)
}
if receiver != nil {
self.state.UpdateStateObject(receiver)
}
self.state.UpdateStateObject(self.Coinbase())
*/
}()
// Increment the nonce for the next transaction
// Increment the nonce for the next transaction
sender
.
Nonce
+=
1
sender
.
Nonce
+=
1
// Get the receiver (TODO fix this, if coinbase is the receiver we need to save/retrieve)
receiver
=
self
.
Receiver
()
receiver
=
self
.
Receiver
()
// Transaction gas
// Transaction gas
...
...
This diff is collapsed.
Click to expand it.
ethchain/transaction.go
View file @
34c8045d
...
@@ -65,7 +65,7 @@ func (tx *Transaction) CreatesContract() bool {
...
@@ -65,7 +65,7 @@ func (tx *Transaction) CreatesContract() bool {
return
tx
.
contractCreation
return
tx
.
contractCreation
}
}
/* Depr
i
cated */
/* Depr
e
cated */
func
(
tx
*
Transaction
)
IsContract
()
bool
{
func
(
tx
*
Transaction
)
IsContract
()
bool
{
return
tx
.
CreatesContract
()
return
tx
.
CreatesContract
()
}
}
...
...
This diff is collapsed.
Click to expand it.
ethchain/vm.go
View file @
34c8045d
...
@@ -120,7 +120,9 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
...
@@ -120,7 +120,9 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
var
newMemSize
uint64
=
0
var
newMemSize
uint64
=
0
switch
op
{
switch
op
{
case
STOP
:
case
STOP
:
gas
.
Set
(
ethutil
.
Big0
)
case
SUICIDE
:
case
SUICIDE
:
gas
.
Set
(
ethutil
.
Big0
)
case
SLOAD
:
case
SLOAD
:
gas
.
Set
(
GasSLoad
)
gas
.
Set
(
GasSLoad
)
case
SSTORE
:
case
SSTORE
:
...
@@ -296,6 +298,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
...
@@ -296,6 +298,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
case
EQ
:
case
EQ
:
require
(
2
)
require
(
2
)
x
,
y
:=
stack
.
Popn
()
x
,
y
:=
stack
.
Popn
()
fmt
.
Printf
(
"%x == %x
\n
"
,
x
,
y
)
// x == y
// x == y
if
x
.
Cmp
(
y
)
==
0
{
if
x
.
Cmp
(
y
)
==
0
{
stack
.
Push
(
ethutil
.
BigTrue
)
stack
.
Push
(
ethutil
.
BigTrue
)
...
@@ -365,12 +368,14 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
...
@@ -365,12 +368,14 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
offset
:=
stack
.
Pop
()
.
Int64
()
offset
:=
stack
.
Pop
()
.
Int64
()
var
data
[]
byte
var
data
[]
byte
if
len
(
closure
.
Args
)
>=
int
(
offset
+
32
)
{
if
len
(
closure
.
Args
)
>=
int
(
offset
)
{
data
=
closure
.
Args
[
offset
:
offset
+
32
]
l
:=
int64
(
math
.
Min
(
float64
(
offset
+
32
),
float64
(
len
(
closure
.
Args
))))
data
=
closure
.
Args
[
offset
:
offset
+
l
]
}
else
{
}
else
{
data
=
[]
byte
{
0
}
data
=
[]
byte
{
0
}
}
}
fmt
.
Println
(
"CALLDATALOAD"
,
string
(
data
),
len
(
data
),
"=="
,
len
(
closure
.
Args
))
stack
.
Push
(
ethutil
.
BigD
(
data
))
stack
.
Push
(
ethutil
.
BigD
(
data
))
case
CALLDATASIZE
:
case
CALLDATASIZE
:
stack
.
Push
(
big
.
NewInt
(
int64
(
len
(
closure
.
Args
))))
stack
.
Push
(
big
.
NewInt
(
int64
(
len
(
closure
.
Args
))))
...
@@ -452,12 +457,11 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
...
@@ -452,12 +457,11 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
require
(
1
)
require
(
1
)
loc
:=
stack
.
Pop
()
loc
:=
stack
.
Pop
()
val
:=
closure
.
GetMem
(
loc
)
val
:=
closure
.
GetMem
(
loc
)
//fmt.Println("get", val.BigInt(), "@", loc)
stack
.
Push
(
val
.
BigInt
())
stack
.
Push
(
val
.
BigInt
())
case
SSTORE
:
case
SSTORE
:
require
(
2
)
require
(
2
)
val
,
loc
:=
stack
.
Popn
()
val
,
loc
:=
stack
.
Popn
()
//fmt.Println("storing", val, "@", loc
)
fmt
.
Println
(
"storing"
,
string
(
val
.
Bytes
()),
"@"
,
string
(
loc
.
Bytes
())
)
closure
.
SetStorage
(
loc
,
ethutil
.
NewValue
(
val
))
closure
.
SetStorage
(
loc
,
ethutil
.
NewValue
(
val
))
// Add the change to manifest
// Add the change to manifest
...
@@ -471,7 +475,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
...
@@ -471,7 +475,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
case
JUMPI
:
case
JUMPI
:
require
(
2
)
require
(
2
)
cond
,
pos
:=
stack
.
Popn
()
cond
,
pos
:=
stack
.
Popn
()
if
cond
.
Cmp
(
ethutil
.
BigTrue
)
=
=
0
{
if
cond
.
Cmp
(
ethutil
.
BigTrue
)
>
=
0
{
pc
=
pos
pc
=
pos
//pc.Sub(pc, ethutil.Big1)
//pc.Sub(pc, ethutil.Big1)
continue
continue
...
...
This diff is collapsed.
Click to expand it.
ethutil/trie_test.go
View file @
34c8045d
package
ethutil
package
ethutil
import
(
import
(
"bytes"
"encoding/json"
"fmt"
"fmt"
"io"
"io/ioutil"
"net/http"
"reflect"
"reflect"
"testing"
"testing"
)
)
...
@@ -171,14 +176,34 @@ func TestTriePurge(t *testing.T) {
...
@@ -171,14 +176,34 @@ func TestTriePurge(t *testing.T) {
}
}
}
}
type
TestItem
struct
{
Name
string
Inputs
[][]
string
Expectations
string
}
func
TestTrieIt
(
t
*
testing
.
T
)
{
func
TestTrieIt
(
t
*
testing
.
T
)
{
_
,
trie
:=
New
()
//_, trie := New()
trie
.
Update
(
"c"
,
LONG_WORD
)
resp
,
err
:=
http
.
Get
(
"https://raw.githubusercontent.com/ethereum/tests/master/trietest.json"
)
trie
.
Update
(
"ca"
,
LONG_WORD
)
if
err
!=
nil
{
trie
.
Update
(
"cat"
,
LONG_WORD
)
t
.
Fail
()
}
it
:=
trie
.
NewIterator
()
defer
resp
.
Body
.
Close
()
it
.
Each
(
func
(
key
string
,
node
*
Value
)
{
body
,
err
:=
ioutil
.
ReadAll
(
resp
.
Body
)
fmt
.
Println
(
key
,
":"
,
node
.
Str
())
if
err
!=
nil
{
})
t
.
Fail
()
}
dec
:=
json
.
NewDecoder
(
bytes
.
NewReader
(
body
))
for
{
var
test
TestItem
if
err
:=
dec
.
Decode
(
&
test
);
err
==
io
.
EOF
{
break
}
else
if
err
!=
nil
{
t
.
Error
(
"Fail something"
,
err
)
break
}
fmt
.
Println
(
test
)
}
}
}
This diff is collapsed.
Click to expand it.
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