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
d764bd05
Commit
d764bd05
authored
Jul 06, 2015
by
Jeffrey Wilcke
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1423 from obscuren/gasused-receipt-fix
core, eth, rpc: proper gas used. Closes #1422
parents
45618d5f
666a7dda
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
9 deletions
+13
-9
block_processor.go
core/block_processor.go
+1
-0
transaction_util.go
core/transaction_util.go
+1
-1
receipt.go
core/types/receipt.go
+4
-2
gasprice.go
eth/gasprice.go
+3
-1
eth.go
rpc/api/eth.go
+0
-1
parsing.go
rpc/api/parsing.go
+4
-4
No files found.
core/block_processor.go
View file @
d764bd05
...
@@ -82,6 +82,7 @@ func (self *BlockProcessor) ApplyTransaction(coinbase *state.StateObject, stated
...
@@ -82,6 +82,7 @@ func (self *BlockProcessor) ApplyTransaction(coinbase *state.StateObject, stated
usedGas
.
Add
(
usedGas
,
gas
)
usedGas
.
Add
(
usedGas
,
gas
)
receipt
:=
types
.
NewReceipt
(
statedb
.
Root
()
.
Bytes
(),
usedGas
)
receipt
:=
types
.
NewReceipt
(
statedb
.
Root
()
.
Bytes
(),
usedGas
)
receipt
.
TxHash
=
tx
.
Hash
()
receipt
.
TxHash
=
tx
.
Hash
()
receipt
.
GasUsed
=
new
(
big
.
Int
)
.
Set
(
gas
)
if
MessageCreatesContract
(
tx
)
{
if
MessageCreatesContract
(
tx
)
{
from
,
_
:=
tx
.
From
()
from
,
_
:=
tx
.
From
()
receipt
.
ContractAddress
=
crypto
.
CreateAddress
(
from
,
tx
.
Nonce
())
receipt
.
ContractAddress
=
crypto
.
CreateAddress
(
from
,
tx
.
Nonce
())
...
...
core/transaction_util.go
View file @
d764bd05
...
@@ -64,7 +64,7 @@ func GetReceipt(db common.Database, txHash common.Hash) *types.Receipt {
...
@@ -64,7 +64,7 @@ func GetReceipt(db common.Database, txHash common.Hash) *types.Receipt {
var
receipt
types
.
Receipt
var
receipt
types
.
Receipt
err
:=
rlp
.
DecodeBytes
(
data
,
&
receipt
)
err
:=
rlp
.
DecodeBytes
(
data
,
&
receipt
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
V
(
logger
.
Error
)
.
Infoln
(
"GetReceipt err:"
,
err
)
glog
.
V
(
logger
.
Core
)
.
Infoln
(
"GetReceipt err:"
,
err
)
}
}
return
&
receipt
return
&
receipt
}
}
...
...
core/types/receipt.go
View file @
d764bd05
...
@@ -18,6 +18,7 @@ type Receipt struct {
...
@@ -18,6 +18,7 @@ type Receipt struct {
TxHash
common
.
Hash
TxHash
common
.
Hash
ContractAddress
common
.
Address
ContractAddress
common
.
Address
logs
state
.
Logs
logs
state
.
Logs
GasUsed
*
big
.
Int
}
}
func
NewReceipt
(
root
[]
byte
,
cumalativeGasUsed
*
big
.
Int
)
*
Receipt
{
func
NewReceipt
(
root
[]
byte
,
cumalativeGasUsed
*
big
.
Int
)
*
Receipt
{
...
@@ -44,11 +45,12 @@ func (self *Receipt) DecodeRLP(s *rlp.Stream) error {
...
@@ -44,11 +45,12 @@ func (self *Receipt) DecodeRLP(s *rlp.Stream) error {
TxHash
common
.
Hash
TxHash
common
.
Hash
ContractAddress
common
.
Address
ContractAddress
common
.
Address
Logs
state
.
Logs
Logs
state
.
Logs
GasUsed
*
big
.
Int
}
}
if
err
:=
s
.
Decode
(
&
r
);
err
!=
nil
{
if
err
:=
s
.
Decode
(
&
r
);
err
!=
nil
{
return
err
return
err
}
}
self
.
PostState
,
self
.
CumulativeGasUsed
,
self
.
Bloom
,
self
.
TxHash
,
self
.
ContractAddress
,
self
.
logs
=
r
.
PostState
,
r
.
CumulativeGasUsed
,
r
.
Bloom
,
r
.
TxHash
,
r
.
ContractAddress
,
r
.
Logs
self
.
PostState
,
self
.
CumulativeGasUsed
,
self
.
Bloom
,
self
.
TxHash
,
self
.
ContractAddress
,
self
.
logs
,
self
.
GasUsed
=
r
.
PostState
,
r
.
CumulativeGasUsed
,
r
.
Bloom
,
r
.
TxHash
,
r
.
ContractAddress
,
r
.
Logs
,
r
.
GasUsed
return
nil
return
nil
}
}
...
@@ -60,7 +62,7 @@ func (self *ReceiptForStorage) EncodeRLP(w io.Writer) error {
...
@@ -60,7 +62,7 @@ func (self *ReceiptForStorage) EncodeRLP(w io.Writer) error {
for
i
,
log
:=
range
self
.
logs
{
for
i
,
log
:=
range
self
.
logs
{
storageLogs
[
i
]
=
(
*
state
.
LogForStorage
)(
log
)
storageLogs
[
i
]
=
(
*
state
.
LogForStorage
)(
log
)
}
}
return
rlp
.
Encode
(
w
,
[]
interface
{}{
self
.
PostState
,
self
.
CumulativeGasUsed
,
self
.
Bloom
,
self
.
TxHash
,
self
.
ContractAddress
,
storageLogs
})
return
rlp
.
Encode
(
w
,
[]
interface
{}{
self
.
PostState
,
self
.
CumulativeGasUsed
,
self
.
Bloom
,
self
.
TxHash
,
self
.
ContractAddress
,
storageLogs
,
self
.
GasUsed
})
}
}
func
(
self
*
Receipt
)
RlpEncode
()
[]
byte
{
func
(
self
*
Receipt
)
RlpEncode
()
[]
byte
{
...
...
eth/gasprice.go
View file @
d764bd05
...
@@ -134,7 +134,9 @@ func (self *GasPriceOracle) lowestPrice(block *types.Block) *big.Int {
...
@@ -134,7 +134,9 @@ func (self *GasPriceOracle) lowestPrice(block *types.Block) *big.Int {
receipts
:=
self
.
eth
.
BlockProcessor
()
.
GetBlockReceipts
(
block
.
Hash
())
receipts
:=
self
.
eth
.
BlockProcessor
()
.
GetBlockReceipts
(
block
.
Hash
())
if
len
(
receipts
)
>
0
{
if
len
(
receipts
)
>
0
{
gasUsed
=
receipts
[
len
(
receipts
)
-
1
]
.
CumulativeGasUsed
if
cgu
:=
receipts
[
len
(
receipts
)
-
1
]
.
CumulativeGasUsed
;
cgu
!=
nil
{
gasUsed
=
receipts
[
len
(
receipts
)
-
1
]
.
CumulativeGasUsed
}
}
}
if
new
(
big
.
Int
)
.
Mul
(
gasUsed
,
big
.
NewInt
(
100
))
.
Cmp
(
new
(
big
.
Int
)
.
Mul
(
block
.
GasLimit
(),
if
new
(
big
.
Int
)
.
Mul
(
gasUsed
,
big
.
NewInt
(
100
))
.
Cmp
(
new
(
big
.
Int
)
.
Mul
(
block
.
GasLimit
(),
...
...
rpc/api/eth.go
View file @
d764bd05
...
@@ -615,7 +615,6 @@ func (self *ethApi) GetTransactionReceipt(req *shared.Request) (interface{}, err
...
@@ -615,7 +615,6 @@ func (self *ethApi) GetTransactionReceipt(req *shared.Request) (interface{}, err
v
:=
NewReceiptRes
(
rec
)
v
:=
NewReceiptRes
(
rec
)
v
.
BlockHash
=
newHexData
(
bhash
)
v
.
BlockHash
=
newHexData
(
bhash
)
v
.
BlockNumber
=
newHexNum
(
bnum
)
v
.
BlockNumber
=
newHexNum
(
bnum
)
v
.
GasUsed
=
newHexNum
(
tx
.
Gas
()
.
Bytes
())
v
.
TransactionIndex
=
newHexNum
(
txi
)
v
.
TransactionIndex
=
newHexNum
(
txi
)
return
v
,
nil
return
v
,
nil
}
}
...
...
rpc/api/parsing.go
View file @
d764bd05
...
@@ -421,11 +421,11 @@ func NewReceiptRes(rec *types.Receipt) *ReceiptRes {
...
@@ -421,11 +421,11 @@ func NewReceiptRes(rec *types.Receipt) *ReceiptRes {
var
v
=
new
(
ReceiptRes
)
var
v
=
new
(
ReceiptRes
)
v
.
TransactionHash
=
newHexData
(
rec
.
TxHash
)
v
.
TransactionHash
=
newHexData
(
rec
.
TxHash
)
// v.TransactionIndex = newHexNum(input)
if
rec
.
GasUsed
!=
nil
{
// v.BlockNumber = newHexNum(input
)
v
.
GasUsed
=
newHexNum
(
rec
.
GasUsed
.
Bytes
()
)
// v.BlockHash = newHexData(input)
}
v
.
CumulativeGasUsed
=
newHexNum
(
rec
.
CumulativeGasUsed
)
v
.
CumulativeGasUsed
=
newHexNum
(
rec
.
CumulativeGasUsed
)
// v.GasUsed = newHexNum(input)
// If the ContractAddress is 20 0x0 bytes, assume it is not a contract creation
// If the ContractAddress is 20 0x0 bytes, assume it is not a contract creation
if
bytes
.
Compare
(
rec
.
ContractAddress
.
Bytes
(),
bytes
.
Repeat
([]
byte
{
0
},
20
))
!=
0
{
if
bytes
.
Compare
(
rec
.
ContractAddress
.
Bytes
(),
bytes
.
Repeat
([]
byte
{
0
},
20
))
!=
0
{
v
.
ContractAddress
=
newHexData
(
rec
.
ContractAddress
)
v
.
ContractAddress
=
newHexData
(
rec
.
ContractAddress
)
...
...
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