Merge pull request #14441 from karalabe/receipt-data-regression

core: fix processing regression during receipt import
This commit is contained in:
Péter Szilágyi 2017-05-08 12:37:01 +03:00 committed by GitHub
commit d18b509e40
2 changed files with 5 additions and 8 deletions

View File

@ -665,10 +665,11 @@ func SetReceiptsData(config *params.ChainConfig, block *types.Block, receipts ty
// The transaction hash can be retrieved from the transaction itself // The transaction hash can be retrieved from the transaction itself
receipts[j].TxHash = transactions[j].Hash() receipts[j].TxHash = transactions[j].Hash()
tx, _ := transactions[j].AsMessage(signer)
// The contract address can be derived from the transaction itself // The contract address can be derived from the transaction itself
if MessageCreatesContract(tx) { if transactions[j].To() == nil {
receipts[j].ContractAddress = crypto.CreateAddress(tx.From(), tx.Nonce()) // Deriving the signer is expensive, only do if it's actually needed
from, _ := types.Sender(signer, transactions[j])
receipts[j].ContractAddress = crypto.CreateAddress(from, transactions[j].Nonce())
} }
// The used gas can be calculated based on previous receipts // The used gas can be calculated based on previous receipts
if j == 0 { if j == 0 {

View File

@ -78,10 +78,6 @@ type Message interface {
Data() []byte Data() []byte
} }
func MessageCreatesContract(msg Message) bool {
return msg.To() == nil
}
// IntrinsicGas computes the 'intrinsic gas' for a message // IntrinsicGas computes the 'intrinsic gas' for a message
// with the given data. // with the given data.
// //
@ -220,7 +216,7 @@ func (self *StateTransition) TransitionDb() (ret []byte, requiredGas, usedGas *b
sender := self.from() // err checked in preCheck sender := self.from() // err checked in preCheck
homestead := self.evm.ChainConfig().IsHomestead(self.evm.BlockNumber) homestead := self.evm.ChainConfig().IsHomestead(self.evm.BlockNumber)
contractCreation := MessageCreatesContract(msg) contractCreation := msg.To() == nil
// Pay intrinsic gas // Pay intrinsic gas
// TODO convert to uint64 // TODO convert to uint64
intrinsicGas := IntrinsicGas(self.data, contractCreation, homestead) intrinsicGas := IntrinsicGas(self.data, contractCreation, homestead)