Skip to content

Commit d18b509

Browse files
authored
Merge pull request #14441 from karalabe/receipt-data-regression
core: fix processing regression during receipt import
2 parents 2e4d23a + 6029382 commit d18b509

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

‎core/blockchain.go‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -665,10 +665,11 @@ func SetReceiptsData(config *params.ChainConfig, block *types.Block, receipts ty
665665
// The transaction hash can be retrieved from the transaction itself
666666
receipts[j].TxHash = transactions[j].Hash()
667667

668-
tx, _ := transactions[j].AsMessage(signer)
669668
// The contract address can be derived from the transaction itself
670-
if MessageCreatesContract(tx) {
671-
receipts[j].ContractAddress = crypto.CreateAddress(tx.From(), tx.Nonce())
669+
if transactions[j].To() == nil {
670+
// Deriving the signer is expensive, only do if it's actually needed
671+
from, _ := types.Sender(signer, transactions[j])
672+
receipts[j].ContractAddress = crypto.CreateAddress(from, transactions[j].Nonce())
672673
}
673674
// The used gas can be calculated based on previous receipts
674675
if j == 0 {

‎core/state_transition.go‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,6 @@ type Message interface {
7878
Data() []byte
7979
}
8080

81-
func MessageCreatesContract(msg Message) bool {
82-
return msg.To() == nil
83-
}
84-
8581
// IntrinsicGas computes the 'intrinsic gas' for a message
8682
// with the given data.
8783
//
@@ -220,7 +216,7 @@ func (self *StateTransition) TransitionDb() (ret []byte, requiredGas, usedGas *b
220216
sender := self.from() // err checked in preCheck
221217

222218
homestead := self.evm.ChainConfig().IsHomestead(self.evm.BlockNumber)
223-
contractCreation := MessageCreatesContract(msg)
219+
contractCreation := msg.To() == nil
224220
// Pay intrinsic gas
225221
// TODO convert to uint64
226222
intrinsicGas := IntrinsicGas(self.data, contractCreation, homestead)

0 commit comments

Comments
 (0)