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
1c85d8c6
Commit
1c85d8c6
authored
Apr 23, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor improvements and bug fixes
* Fixed VM base bug
parent
0651af9d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
8 deletions
+12
-8
state.go
ethchain/state.go
+2
-2
state_manager.go
ethchain/state_manager.go
+2
-0
transaction_pool.go
ethchain/transaction_pool.go
+4
-4
vm.go
ethchain/vm.go
+4
-2
No files found.
ethchain/state.go
View file @
1c85d8c6
...
@@ -34,12 +34,12 @@ func (s *State) Reset() {
...
@@ -34,12 +34,12 @@ func (s *State) Reset() {
// Syncs the trie and all siblings
// Syncs the trie and all siblings
func
(
s
*
State
)
Sync
()
{
func
(
s
*
State
)
Sync
()
{
s
.
trie
.
Sync
()
// Sync all nested states
// Sync all nested states
for
_
,
state
:=
range
s
.
states
{
for
_
,
state
:=
range
s
.
states
{
state
.
Sync
()
state
.
Sync
()
}
}
s
.
trie
.
Sync
()
}
}
// Purges the current trie.
// Purges the current trie.
...
...
ethchain/state_manager.go
View file @
1c85d8c6
...
@@ -117,6 +117,7 @@ func (sm *StateManager) ApplyTransactions(block *Block, txs []*Transaction) {
...
@@ -117,6 +117,7 @@ func (sm *StateManager) ApplyTransactions(block *Block, txs []*Transaction) {
contract
:=
sm
.
MakeContract
(
tx
)
contract
:=
sm
.
MakeContract
(
tx
)
if
contract
!=
nil
{
if
contract
!=
nil
{
sm
.
EvalScript
(
contract
.
Init
(),
contract
,
tx
,
block
)
sm
.
EvalScript
(
contract
.
Init
(),
contract
,
tx
,
block
)
fmt
.
Printf
(
"state root of contract %x
\n
"
,
contract
.
State
()
.
Root
())
}
else
{
}
else
{
ethutil
.
Config
.
Log
.
Infoln
(
"[STATE] Unable to create contract"
)
ethutil
.
Config
.
Log
.
Infoln
(
"[STATE] Unable to create contract"
)
}
}
...
@@ -332,4 +333,5 @@ func (sm *StateManager) EvalScript(script []byte, object *StateObject, tx *Trans
...
@@ -332,4 +333,5 @@ func (sm *StateManager) EvalScript(script []byte, object *StateObject, tx *Trans
// Update the account (refunds)
// Update the account (refunds)
sm
.
procState
.
UpdateStateObject
(
caller
)
sm
.
procState
.
UpdateStateObject
(
caller
)
sm
.
procState
.
UpdateStateObject
(
object
)
}
}
ethchain/transaction_pool.go
View file @
1c85d8c6
...
@@ -100,6 +100,10 @@ func (pool *TxPool) ProcessTransaction(tx *Transaction, block *Block, toContract
...
@@ -100,6 +100,10 @@ func (pool *TxPool) ProcessTransaction(tx *Transaction, block *Block, toContract
// Get the sender
// Get the sender
sender
:=
block
.
state
.
GetAccount
(
tx
.
Sender
())
sender
:=
block
.
state
.
GetAccount
(
tx
.
Sender
())
if
sender
.
Nonce
!=
tx
.
Nonce
{
return
fmt
.
Errorf
(
"[TXPL] Invalid account nonce, state nonce is %d transaction nonce is %d instead"
,
sender
.
Nonce
,
tx
.
Nonce
)
}
// Make sure there's enough in the sender's account. Having insufficient
// Make sure there's enough in the sender's account. Having insufficient
// funds won't invalidate this transaction but simple ignores it.
// funds won't invalidate this transaction but simple ignores it.
totAmount
:=
new
(
big
.
Int
)
.
Add
(
tx
.
Value
,
new
(
big
.
Int
)
.
Mul
(
TxFee
,
TxFeeRat
))
totAmount
:=
new
(
big
.
Int
)
.
Add
(
tx
.
Value
,
new
(
big
.
Int
)
.
Mul
(
TxFee
,
TxFeeRat
))
...
@@ -107,10 +111,6 @@ func (pool *TxPool) ProcessTransaction(tx *Transaction, block *Block, toContract
...
@@ -107,10 +111,6 @@ func (pool *TxPool) ProcessTransaction(tx *Transaction, block *Block, toContract
return
fmt
.
Errorf
(
"[TXPL] Insufficient amount in sender's (%x) account"
,
tx
.
Sender
())
return
fmt
.
Errorf
(
"[TXPL] Insufficient amount in sender's (%x) account"
,
tx
.
Sender
())
}
}
if
sender
.
Nonce
!=
tx
.
Nonce
{
return
fmt
.
Errorf
(
"[TXPL] Invalid account nonce, state nonce is %d transaction nonce is %d instead"
,
sender
.
Nonce
,
tx
.
Nonce
)
}
// Get the receiver
// Get the receiver
receiver
:=
block
.
state
.
GetAccount
(
tx
.
Recipient
)
receiver
:=
block
.
state
.
GetAccount
(
tx
.
Recipient
)
sender
.
Nonce
+=
1
sender
.
Nonce
+=
1
...
...
ethchain/vm.go
View file @
1c85d8c6
...
@@ -82,14 +82,15 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
...
@@ -82,14 +82,15 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
pc
:=
big
.
NewInt
(
0
)
pc
:=
big
.
NewInt
(
0
)
// Current step count
// Current step count
step
:=
0
step
:=
0
// The base for all big integer arithmetic
base
:=
new
(
big
.
Int
)
if
ethutil
.
Config
.
Debug
{
if
ethutil
.
Config
.
Debug
{
ethutil
.
Config
.
Log
.
Debugf
(
"# op
\n
"
)
ethutil
.
Config
.
Log
.
Debugf
(
"# op
\n
"
)
}
}
for
{
for
{
// The base for all big integer arithmetic
base
:=
new
(
big
.
Int
)
step
++
step
++
// Get the memory location of pc
// Get the memory location of pc
val
:=
closure
.
Get
(
pc
)
val
:=
closure
.
Get
(
pc
)
...
@@ -390,6 +391,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
...
@@ -390,6 +391,7 @@ 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
.
Printf
(
"load %x = %v
\n
"
,
loc
.
Bytes
(),
val
.
BigInt
())
stack
.
Push
(
val
.
BigInt
())
stack
.
Push
(
val
.
BigInt
())
case
oSSTORE
:
case
oSSTORE
:
require
(
2
)
require
(
2
)
...
...
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