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
f30b809f
Commit
f30b809f
authored
Mar 01, 2016
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2215 from bas-vk/estimategas
core: improved check for contract creation
parents
7d598af4
0ff2adb2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
35 deletions
+32
-35
state_transition.go
core/state_transition.go
+1
-1
api.go
eth/api.go
+31
-34
No files found.
core/state_transition.go
View file @
f30b809f
...
@@ -78,7 +78,7 @@ func MessageCreatesContract(msg Message) bool {
...
@@ -78,7 +78,7 @@ func MessageCreatesContract(msg Message) bool {
return
msg
.
To
()
==
nil
return
msg
.
To
()
==
nil
}
}
// IntrinsicGas computes the 'intrisic gas' for a message
// IntrinsicGas computes the 'intri
n
sic gas' for a message
// with the given data.
// with the given data.
func
IntrinsicGas
(
data
[]
byte
,
contractCreation
,
homestead
bool
)
*
big
.
Int
{
func
IntrinsicGas
(
data
[]
byte
,
contractCreation
,
homestead
bool
)
*
big
.
Int
{
igas
:=
new
(
big
.
Int
)
igas
:=
new
(
big
.
Int
)
...
...
eth/api.go
View file @
f30b809f
...
@@ -621,7 +621,7 @@ func (m callmsg) Data() []byte { return m.data }
...
@@ -621,7 +621,7 @@ func (m callmsg) Data() []byte { return m.data }
type
CallArgs
struct
{
type
CallArgs
struct
{
From
common
.
Address
`json:"from"`
From
common
.
Address
`json:"from"`
To
common
.
Address
`json:"to"`
To
*
common
.
Address
`json:"to"`
Gas
rpc
.
HexNumber
`json:"gas"`
Gas
rpc
.
HexNumber
`json:"gas"`
GasPrice
rpc
.
HexNumber
`json:"gasPrice"`
GasPrice
rpc
.
HexNumber
`json:"gasPrice"`
Value
rpc
.
HexNumber
`json:"value"`
Value
rpc
.
HexNumber
`json:"value"`
...
@@ -653,7 +653,7 @@ func (s *PublicBlockChainAPI) doCall(args CallArgs, blockNr rpc.BlockNumber) (st
...
@@ -653,7 +653,7 @@ func (s *PublicBlockChainAPI) doCall(args CallArgs, blockNr rpc.BlockNumber) (st
// Assemble the CALL invocation
// Assemble the CALL invocation
msg
:=
callmsg
{
msg
:=
callmsg
{
from
:
from
,
from
:
from
,
to
:
&
args
.
To
,
to
:
args
.
To
,
gas
:
args
.
Gas
.
BigInt
(),
gas
:
args
.
Gas
.
BigInt
(),
gasPrice
:
args
.
GasPrice
.
BigInt
(),
gasPrice
:
args
.
GasPrice
.
BigInt
(),
value
:
args
.
Value
.
BigInt
(),
value
:
args
.
Value
.
BigInt
(),
...
@@ -665,6 +665,7 @@ func (s *PublicBlockChainAPI) doCall(args CallArgs, blockNr rpc.BlockNumber) (st
...
@@ -665,6 +665,7 @@ func (s *PublicBlockChainAPI) doCall(args CallArgs, blockNr rpc.BlockNumber) (st
if
msg
.
gasPrice
.
Cmp
(
common
.
Big0
)
==
0
{
if
msg
.
gasPrice
.
Cmp
(
common
.
Big0
)
==
0
{
msg
.
gasPrice
=
new
(
big
.
Int
)
.
Mul
(
big
.
NewInt
(
50
),
common
.
Shannon
)
msg
.
gasPrice
=
new
(
big
.
Int
)
.
Mul
(
big
.
NewInt
(
50
),
common
.
Shannon
)
}
}
// Execute the call and return
// Execute the call and return
vmenv
:=
core
.
NewEnv
(
stateDb
,
s
.
bc
,
msg
,
block
.
Header
())
vmenv
:=
core
.
NewEnv
(
stateDb
,
s
.
bc
,
msg
,
block
.
Header
())
gp
:=
new
(
core
.
GasPool
)
.
AddGas
(
common
.
MaxBig
)
gp
:=
new
(
core
.
GasPool
)
.
AddGas
(
common
.
MaxBig
)
...
@@ -1013,7 +1014,7 @@ func (s *PublicTransactionPoolAPI) sign(address common.Address, tx *types.Transa
...
@@ -1013,7 +1014,7 @@ func (s *PublicTransactionPoolAPI) sign(address common.Address, tx *types.Transa
type
SendTxArgs
struct
{
type
SendTxArgs
struct
{
From
common
.
Address
`json:"from"`
From
common
.
Address
`json:"from"`
To
common
.
Address
`json:"to"`
To
*
common
.
Address
`json:"to"`
Gas
*
rpc
.
HexNumber
`json:"gas"`
Gas
*
rpc
.
HexNumber
`json:"gas"`
GasPrice
*
rpc
.
HexNumber
`json:"gasPrice"`
GasPrice
*
rpc
.
HexNumber
`json:"gasPrice"`
Value
*
rpc
.
HexNumber
`json:"value"`
Value
*
rpc
.
HexNumber
`json:"value"`
...
@@ -1042,12 +1043,12 @@ func (s *PublicTransactionPoolAPI) SendTransaction(args SendTxArgs) (common.Hash
...
@@ -1042,12 +1043,12 @@ func (s *PublicTransactionPoolAPI) SendTransaction(args SendTxArgs) (common.Hash
}
}
var
tx
*
types
.
Transaction
var
tx
*
types
.
Transaction
contractCreation
:=
(
args
.
To
==
common
.
Address
{}
)
contractCreation
:=
(
args
.
To
==
nil
)
if
contractCreation
{
if
contractCreation
{
tx
=
types
.
NewContractCreation
(
args
.
Nonce
.
Uint64
(),
args
.
Value
.
BigInt
(),
args
.
Gas
.
BigInt
(),
args
.
GasPrice
.
BigInt
(),
common
.
FromHex
(
args
.
Data
))
tx
=
types
.
NewContractCreation
(
args
.
Nonce
.
Uint64
(),
args
.
Value
.
BigInt
(),
args
.
Gas
.
BigInt
(),
args
.
GasPrice
.
BigInt
(),
common
.
FromHex
(
args
.
Data
))
}
else
{
}
else
{
tx
=
types
.
NewTransaction
(
args
.
Nonce
.
Uint64
(),
args
.
To
,
args
.
Value
.
BigInt
(),
args
.
Gas
.
BigInt
(),
args
.
GasPrice
.
BigInt
(),
common
.
FromHex
(
args
.
Data
))
tx
=
types
.
NewTransaction
(
args
.
Nonce
.
Uint64
(),
*
args
.
To
,
args
.
Value
.
BigInt
(),
args
.
Gas
.
BigInt
(),
args
.
GasPrice
.
BigInt
(),
common
.
FromHex
(
args
.
Data
))
}
}
signedTx
,
err
:=
s
.
sign
(
args
.
From
,
tx
)
signedTx
,
err
:=
s
.
sign
(
args
.
From
,
tx
)
...
@@ -1106,7 +1107,7 @@ func (s *PublicTransactionPoolAPI) Sign(address common.Address, data string) (st
...
@@ -1106,7 +1107,7 @@ func (s *PublicTransactionPoolAPI) Sign(address common.Address, data string) (st
type
SignTransactionArgs
struct
{
type
SignTransactionArgs
struct
{
From
common
.
Address
From
common
.
Address
To
common
.
Address
To
*
common
.
Address
Nonce
*
rpc
.
HexNumber
Nonce
*
rpc
.
HexNumber
Value
*
rpc
.
HexNumber
Value
*
rpc
.
HexNumber
Gas
*
rpc
.
HexNumber
Gas
*
rpc
.
HexNumber
...
@@ -1132,7 +1133,7 @@ type Tx struct {
...
@@ -1132,7 +1133,7 @@ type Tx struct {
func
(
tx
*
Tx
)
UnmarshalJSON
(
b
[]
byte
)
(
err
error
)
{
func
(
tx
*
Tx
)
UnmarshalJSON
(
b
[]
byte
)
(
err
error
)
{
req
:=
struct
{
req
:=
struct
{
To
common
.
Address
`json:"to"`
To
*
common
.
Address
`json:"to"`
From
common
.
Address
`json:"from"`
From
common
.
Address
`json:"from"`
Nonce
*
rpc
.
HexNumber
`json:"nonce"`
Nonce
*
rpc
.
HexNumber
`json:"nonce"`
Value
*
rpc
.
HexNumber
`json:"value"`
Value
*
rpc
.
HexNumber
`json:"value"`
...
@@ -1146,9 +1147,7 @@ func (tx *Tx) UnmarshalJSON(b []byte) (err error) {
...
@@ -1146,9 +1147,7 @@ func (tx *Tx) UnmarshalJSON(b []byte) (err error) {
return
err
return
err
}
}
contractCreation
:=
(
req
.
To
==
(
common
.
Address
{}))
tx
.
To
=
req
.
To
tx
.
To
=
&
req
.
To
tx
.
From
=
req
.
From
tx
.
From
=
req
.
From
tx
.
Nonce
=
req
.
Nonce
tx
.
Nonce
=
req
.
Nonce
tx
.
Value
=
req
.
Value
tx
.
Value
=
req
.
Value
...
@@ -1172,12 +1171,10 @@ func (tx *Tx) UnmarshalJSON(b []byte) (err error) {
...
@@ -1172,12 +1171,10 @@ func (tx *Tx) UnmarshalJSON(b []byte) (err error) {
tx
.
GasPrice
=
rpc
.
NewHexNumber
(
int64
(
50000000000
))
tx
.
GasPrice
=
rpc
.
NewHexNumber
(
int64
(
50000000000
))
}
}
contractCreation
:=
(
req
.
To
==
nil
)
if
contractCreation
{
if
contractCreation
{
tx
.
tx
=
types
.
NewContractCreation
(
tx
.
Nonce
.
Uint64
(),
tx
.
Value
.
BigInt
(),
tx
.
GasLimit
.
BigInt
(),
tx
.
GasPrice
.
BigInt
(),
data
)
tx
.
tx
=
types
.
NewContractCreation
(
tx
.
Nonce
.
Uint64
(),
tx
.
Value
.
BigInt
(),
tx
.
GasLimit
.
BigInt
(),
tx
.
GasPrice
.
BigInt
(),
data
)
}
else
{
}
else
{
if
tx
.
To
==
nil
{
return
fmt
.
Errorf
(
"need to address"
)
}
tx
.
tx
=
types
.
NewTransaction
(
tx
.
Nonce
.
Uint64
(),
*
tx
.
To
,
tx
.
Value
.
BigInt
(),
tx
.
GasLimit
.
BigInt
(),
tx
.
GasPrice
.
BigInt
(),
data
)
tx
.
tx
=
types
.
NewTransaction
(
tx
.
Nonce
.
Uint64
(),
*
tx
.
To
,
tx
.
Value
.
BigInt
(),
tx
.
GasLimit
.
BigInt
(),
tx
.
GasPrice
.
BigInt
(),
data
)
}
}
...
@@ -1226,12 +1223,12 @@ func (s *PublicTransactionPoolAPI) SignTransaction(args *SignTransactionArgs) (*
...
@@ -1226,12 +1223,12 @@ func (s *PublicTransactionPoolAPI) SignTransaction(args *SignTransactionArgs) (*
}
}
var
tx
*
types
.
Transaction
var
tx
*
types
.
Transaction
contractCreation
:=
(
args
.
To
==
common
.
Address
{}
)
contractCreation
:=
(
args
.
To
==
nil
)
if
contractCreation
{
if
contractCreation
{
tx
=
types
.
NewContractCreation
(
args
.
Nonce
.
Uint64
(),
args
.
Value
.
BigInt
(),
args
.
Gas
.
BigInt
(),
args
.
GasPrice
.
BigInt
(),
common
.
FromHex
(
args
.
Data
))
tx
=
types
.
NewContractCreation
(
args
.
Nonce
.
Uint64
(),
args
.
Value
.
BigInt
(),
args
.
Gas
.
BigInt
(),
args
.
GasPrice
.
BigInt
(),
common
.
FromHex
(
args
.
Data
))
}
else
{
}
else
{
tx
=
types
.
NewTransaction
(
args
.
Nonce
.
Uint64
(),
args
.
To
,
args
.
Value
.
BigInt
(),
args
.
Gas
.
BigInt
(),
args
.
GasPrice
.
BigInt
(),
common
.
FromHex
(
args
.
Data
))
tx
=
types
.
NewTransaction
(
args
.
Nonce
.
Uint64
(),
*
args
.
To
,
args
.
Value
.
BigInt
(),
args
.
Gas
.
BigInt
(),
args
.
GasPrice
.
BigInt
(),
common
.
FromHex
(
args
.
Data
))
}
}
signedTx
,
err
:=
s
.
sign
(
args
.
From
,
tx
)
signedTx
,
err
:=
s
.
sign
(
args
.
From
,
tx
)
...
@@ -1324,7 +1321,7 @@ func (s *PublicTransactionPoolAPI) Resend(tx *Tx, gasPrice, gasLimit *rpc.HexNum
...
@@ -1324,7 +1321,7 @@ func (s *PublicTransactionPoolAPI) Resend(tx *Tx, gasPrice, gasLimit *rpc.HexNum
}
}
var
newTx
*
types
.
Transaction
var
newTx
*
types
.
Transaction
contractCreation
:=
(
*
tx
.
tx
.
To
()
==
common
.
Address
{}
)
contractCreation
:=
(
tx
.
tx
.
To
()
==
nil
)
if
contractCreation
{
if
contractCreation
{
newTx
=
types
.
NewContractCreation
(
tx
.
tx
.
Nonce
(),
tx
.
tx
.
Value
(),
gasPrice
.
BigInt
(),
gasLimit
.
BigInt
(),
tx
.
tx
.
Data
())
newTx
=
types
.
NewContractCreation
(
tx
.
tx
.
Nonce
(),
tx
.
tx
.
Value
(),
gasPrice
.
BigInt
(),
gasLimit
.
BigInt
(),
tx
.
tx
.
Data
())
}
else
{
}
else
{
...
...
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