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
86103149
Commit
86103149
authored
Jun 03, 2015
by
Jeffrey Wilcke
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1167 from Gustav-Simonsson/check_ec_recover_err
Add missing err checks on From()
parents
71d9367e
147a699c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
18 deletions
+25
-18
admin.go
cmd/geth/admin.go
+0
-1
state_transition.go
core/state_transition.go
+20
-15
transaction_pool.go
core/transaction_pool.go
+1
-1
types.go
xeth/types.go
+4
-1
No files found.
cmd/geth/admin.go
View file @
86103149
...
@@ -160,7 +160,6 @@ func (js *jsre) pendingTransactions(call otto.FunctionCall) otto.Value {
...
@@ -160,7 +160,6 @@ func (js *jsre) pendingTransactions(call otto.FunctionCall) otto.Value {
//ltxs := make([]*tx, len(txs))
//ltxs := make([]*tx, len(txs))
var
ltxs
[]
*
tx
var
ltxs
[]
*
tx
for
_
,
tx
:=
range
txs
{
for
_
,
tx
:=
range
txs
{
// no need to check err
if
from
,
_
:=
tx
.
From
();
accountSet
.
Has
(
from
)
{
if
from
,
_
:=
tx
.
From
();
accountSet
.
Has
(
from
)
{
ltxs
=
append
(
ltxs
,
newTx
(
tx
))
ltxs
=
append
(
ltxs
,
newTx
(
tx
))
}
}
...
...
core/state_transition.go
View file @
86103149
...
@@ -62,7 +62,6 @@ type Message interface {
...
@@ -62,7 +62,6 @@ type Message interface {
func
AddressFromMessage
(
msg
Message
)
common
.
Address
{
func
AddressFromMessage
(
msg
Message
)
common
.
Address
{
from
,
_
:=
msg
.
From
()
from
,
_
:=
msg
.
From
()
return
crypto
.
CreateAddress
(
from
,
msg
.
Nonce
())
return
crypto
.
CreateAddress
(
from
,
msg
.
Nonce
())
}
}
...
@@ -109,9 +108,12 @@ func NewStateTransition(env vm.Environment, msg Message, coinbase *state.StateOb
...
@@ -109,9 +108,12 @@ func NewStateTransition(env vm.Environment, msg Message, coinbase *state.StateOb
func
(
self
*
StateTransition
)
Coinbase
()
*
state
.
StateObject
{
func
(
self
*
StateTransition
)
Coinbase
()
*
state
.
StateObject
{
return
self
.
state
.
GetOrNewStateObject
(
self
.
coinbase
)
return
self
.
state
.
GetOrNewStateObject
(
self
.
coinbase
)
}
}
func
(
self
*
StateTransition
)
From
()
*
state
.
StateObject
{
func
(
self
*
StateTransition
)
From
()
(
*
state
.
StateObject
,
error
)
{
f
,
_
:=
self
.
msg
.
From
()
f
,
err
:=
self
.
msg
.
From
()
return
self
.
state
.
GetOrNewStateObject
(
f
)
if
err
!=
nil
{
return
nil
,
err
}
return
self
.
state
.
GetOrNewStateObject
(
f
),
nil
}
}
func
(
self
*
StateTransition
)
To
()
*
state
.
StateObject
{
func
(
self
*
StateTransition
)
To
()
*
state
.
StateObject
{
if
self
.
msg
==
nil
{
if
self
.
msg
==
nil
{
...
@@ -140,7 +142,10 @@ func (self *StateTransition) AddGas(amount *big.Int) {
...
@@ -140,7 +142,10 @@ func (self *StateTransition) AddGas(amount *big.Int) {
func
(
self
*
StateTransition
)
BuyGas
()
error
{
func
(
self
*
StateTransition
)
BuyGas
()
error
{
var
err
error
var
err
error
sender
:=
self
.
From
()
sender
,
err
:=
self
.
From
()
if
err
!=
nil
{
return
err
}
if
sender
.
Balance
()
.
Cmp
(
MessageGasValue
(
self
.
msg
))
<
0
{
if
sender
.
Balance
()
.
Cmp
(
MessageGasValue
(
self
.
msg
))
<
0
{
return
fmt
.
Errorf
(
"insufficient ETH for gas (%x). Req %v, has %v"
,
sender
.
Address
()
.
Bytes
()[
:
4
],
MessageGasValue
(
self
.
msg
),
sender
.
Balance
())
return
fmt
.
Errorf
(
"insufficient ETH for gas (%x). Req %v, has %v"
,
sender
.
Address
()
.
Bytes
()[
:
4
],
MessageGasValue
(
self
.
msg
),
sender
.
Balance
())
}
}
...
@@ -159,10 +164,11 @@ func (self *StateTransition) BuyGas() error {
...
@@ -159,10 +164,11 @@ func (self *StateTransition) BuyGas() error {
}
}
func
(
self
*
StateTransition
)
preCheck
()
(
err
error
)
{
func
(
self
*
StateTransition
)
preCheck
()
(
err
error
)
{
var
(
msg
:=
self
.
msg
msg
=
self
.
msg
sender
,
err
:=
self
.
From
()
sender
=
self
.
From
()
if
err
!=
nil
{
)
return
err
}
// Make sure this transaction's nonce is correct
// Make sure this transaction's nonce is correct
if
sender
.
Nonce
()
!=
msg
.
Nonce
()
{
if
sender
.
Nonce
()
!=
msg
.
Nonce
()
{
...
@@ -185,10 +191,8 @@ func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, er
...
@@ -185,10 +191,8 @@ func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, er
return
return
}
}
var
(
msg
:=
self
.
msg
msg
=
self
.
msg
sender
,
_
:=
self
.
From
()
// err checked in preCheck
sender
=
self
.
From
()
)
// Pay intrinsic gas
// Pay intrinsic gas
if
err
=
self
.
UseGas
(
IntrinsicGas
(
self
.
msg
));
err
!=
nil
{
if
err
=
self
.
UseGas
(
IntrinsicGas
(
self
.
msg
));
err
!=
nil
{
...
@@ -212,7 +216,7 @@ func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, er
...
@@ -212,7 +216,7 @@ func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, er
}
else
{
}
else
{
// Increment the nonce for the next transaction
// Increment the nonce for the next transaction
self
.
state
.
SetNonce
(
sender
.
Address
(),
sender
.
Nonce
()
+
1
)
self
.
state
.
SetNonce
(
sender
.
Address
(),
sender
.
Nonce
()
+
1
)
ret
,
err
=
vmenv
.
Call
(
se
lf
.
From
()
,
self
.
To
()
.
Address
(),
self
.
msg
.
Data
(),
self
.
gas
,
self
.
gasPrice
,
self
.
value
)
ret
,
err
=
vmenv
.
Call
(
se
nder
,
self
.
To
()
.
Address
(),
self
.
msg
.
Data
(),
self
.
gas
,
self
.
gasPrice
,
self
.
value
)
}
}
if
err
!=
nil
&&
IsValueTransferErr
(
err
)
{
if
err
!=
nil
&&
IsValueTransferErr
(
err
)
{
...
@@ -226,7 +230,8 @@ func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, er
...
@@ -226,7 +230,8 @@ func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, er
}
}
func
(
self
*
StateTransition
)
refundGas
()
{
func
(
self
*
StateTransition
)
refundGas
()
{
coinbase
,
sender
:=
self
.
Coinbase
(),
self
.
From
()
coinbase
:=
self
.
Coinbase
()
sender
,
_
:=
self
.
From
()
// err already checked
// Return remaining gas
// Return remaining gas
remaining
:=
new
(
big
.
Int
)
.
Mul
(
self
.
gas
,
self
.
msg
.
GasPrice
())
remaining
:=
new
(
big
.
Int
)
.
Mul
(
self
.
gas
,
self
.
msg
.
GasPrice
())
sender
.
AddBalance
(
remaining
)
sender
.
AddBalance
(
remaining
)
...
...
core/transaction_pool.go
View file @
86103149
...
@@ -271,7 +271,7 @@ func (pool *TxPool) Stop() {
...
@@ -271,7 +271,7 @@ func (pool *TxPool) Stop() {
}
}
func
(
self
*
TxPool
)
queueTx
(
tx
*
types
.
Transaction
)
{
func
(
self
*
TxPool
)
queueTx
(
tx
*
types
.
Transaction
)
{
from
,
_
:=
tx
.
From
()
from
,
_
:=
tx
.
From
()
// already validated
self
.
queue
[
from
]
=
append
(
self
.
queue
[
from
],
tx
)
self
.
queue
[
from
]
=
append
(
self
.
queue
[
from
],
tx
)
}
}
...
...
xeth/types.go
View file @
86103149
...
@@ -139,6 +139,10 @@ type Transaction struct {
...
@@ -139,6 +139,10 @@ type Transaction struct {
}
}
func
NewTx
(
tx
*
types
.
Transaction
)
*
Transaction
{
func
NewTx
(
tx
*
types
.
Transaction
)
*
Transaction
{
sender
,
err
:=
tx
.
From
()
if
err
!=
nil
{
return
nil
}
hash
:=
tx
.
Hash
()
.
Hex
()
hash
:=
tx
.
Hash
()
.
Hex
()
var
receiver
string
var
receiver
string
...
@@ -147,7 +151,6 @@ func NewTx(tx *types.Transaction) *Transaction {
...
@@ -147,7 +151,6 @@ func NewTx(tx *types.Transaction) *Transaction {
}
else
{
}
else
{
receiver
=
core
.
AddressFromMessage
(
tx
)
.
Hex
()
receiver
=
core
.
AddressFromMessage
(
tx
)
.
Hex
()
}
}
sender
,
_
:=
tx
.
From
()
createsContract
:=
core
.
MessageCreatesContract
(
tx
)
createsContract
:=
core
.
MessageCreatesContract
(
tx
)
var
data
string
var
data
string
...
...
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