fixes `getRecipient`: using `sender` param instead of calculating sender itself
usually, there is always a sender around `getRecipient` call. no need to recalculate sender. and more important, in some of JSON-RPC/GraphQL call, the sender is come from `rpcCallData`, not from `tx.getSender`. or in ohter situation when the tx is an unsigned tx, without `r,s,v` fields to calculate sender.
This commit is contained in:
parent
c46b7186ca
commit
39ce2390ae
|
@ -109,7 +109,7 @@ proc traceTransaction*(chainDB: BaseChainDB, header: BlockHeader,
|
|||
|
||||
for idx, tx in body.transactions:
|
||||
let sender = tx.getSender
|
||||
let recipient = tx.getRecipient
|
||||
let recipient = tx.getRecipient(sender)
|
||||
|
||||
if idx == txIndex:
|
||||
vmState.enableTracing()
|
||||
|
@ -167,7 +167,7 @@ proc dumpBlockState*(db: BaseChainDB, header: BlockHeader, body: BlockBody, dump
|
|||
|
||||
for idx, tx in body.transactions:
|
||||
let sender = tx.getSender
|
||||
let recipient = tx.getRecipient
|
||||
let recipient = tx.getRecipient(sender)
|
||||
before.captureAccount(stateBefore, sender, senderName & $idx)
|
||||
before.captureAccount(stateBefore, recipient, recipientName & $idx)
|
||||
|
||||
|
@ -182,7 +182,7 @@ proc dumpBlockState*(db: BaseChainDB, header: BlockHeader, body: BlockBody, dump
|
|||
|
||||
for idx, tx in body.transactions:
|
||||
let sender = tx.getSender
|
||||
let recipient = tx.getRecipient
|
||||
let recipient = tx.getRecipient(sender)
|
||||
after.captureAccount(stateAfter, sender, senderName & $idx)
|
||||
after.captureAccount(stateAfter, recipient, recipientName & $idx)
|
||||
vmState.removeTracedAccounts(sender, recipient)
|
||||
|
|
|
@ -69,9 +69,8 @@ proc getSender*(transaction: Transaction): EthAddress =
|
|||
if not transaction.getSender(result):
|
||||
raise newException(ValidationError, "Could not derive sender address from transaction")
|
||||
|
||||
proc getRecipient*(tx: Transaction): EthAddress =
|
||||
proc getRecipient*(tx: Transaction, sender: EthAddress): EthAddress =
|
||||
if tx.isContractCreation:
|
||||
let sender = tx.getSender()
|
||||
result = generateAddress(sender, tx.accountNonce)
|
||||
else:
|
||||
result = tx.to
|
||||
|
|
|
@ -165,7 +165,7 @@ proc txSetupComputation(tx: Transaction, sender: EthAddress, vmState: BaseVMStat
|
|||
depth: 0,
|
||||
gas: gas,
|
||||
sender: sender,
|
||||
contractAddress: tx.getRecipient(),
|
||||
contractAddress: tx.getRecipient(sender),
|
||||
codeAddress: tx.to,
|
||||
value: tx.value,
|
||||
data: tx.payload
|
||||
|
@ -189,7 +189,7 @@ proc txInitialAccessListEIP2929(tx: Transaction, sender: EthAddress, vmState: Ba
|
|||
# For contract creations the EVM will add the contract address to the
|
||||
# access list itself, after calculating the new contract address.
|
||||
if not tx.isContractCreation:
|
||||
db.accessList(tx.getRecipient())
|
||||
db.accessList(tx.getRecipient(sender))
|
||||
for c in activePrecompiles():
|
||||
db.accessList(c)
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ proc setupComputation*(vmState: BaseVMState, tx: Transaction, sender: EthAddress
|
|||
depth: 0,
|
||||
gas: gas,
|
||||
sender: sender,
|
||||
contractAddress: tx.getRecipient(),
|
||||
contractAddress: tx.getRecipient(sender),
|
||||
codeAddress: tx.to,
|
||||
value: tx.value,
|
||||
data: tx.payload
|
||||
|
|
|
@ -68,10 +68,11 @@ proc generatePremixData*(nimbus, geth: JsonNode) =
|
|||
var data = "var premixData = " & premixData.pretty & "\n"
|
||||
writeFile(getFileDir("index.html") / "premixData.js", data)
|
||||
|
||||
proc hasInternalTx(tx: Transaction, blockNumber: Uint256): bool =
|
||||
proc hasInternalTx(tx: Transaction, blockNumber: Uint256, sender: EthAddress): bool =
|
||||
let
|
||||
number = %(blockNumber.prefixHex)
|
||||
code = request("eth_getCode", %[%tx.getRecipient.prefixHex, number])
|
||||
recipient = tx.getRecipient(sender)
|
||||
code = request("eth_getCode", %[%recipient.prefixHex, number])
|
||||
recipientHasCode = code.getStr.len > 2 # "0x"
|
||||
|
||||
if tx.isContractCreation:
|
||||
|
@ -146,16 +147,17 @@ proc requestPostState*(premix, n: JsonNode, blockNumber: Uint256) =
|
|||
for t in txs:
|
||||
var txKind = TxKind.Regular
|
||||
let tx = parseTransaction(t)
|
||||
let sender = tx.getSender
|
||||
if tx.isContractCreation: txKind = TxKind.ContractCreation
|
||||
if hasInternalTx(tx, blockNumber):
|
||||
if hasInternalTx(tx, blockNumber, sender):
|
||||
let txTrace = requestInternalTx(t["hash"], tracer)
|
||||
for address, account in txTrace:
|
||||
updateAccount(address, account, blockNumber)
|
||||
premix.add account
|
||||
if not tx.isContractCreation: txKind = TxKind.ContractCall
|
||||
else:
|
||||
premix.requestAccount(blockNumber, tx.getRecipient)
|
||||
premix.requestAccount(blockNumber, tx.getSender)
|
||||
premix.requestAccount(blockNumber, tx.getRecipient(sender))
|
||||
premix.requestAccount(blockNumber, sender)
|
||||
|
||||
t["txKind"] = %($txKind)
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ proc dumpAccount(accountDb: ReadOnlyStateDB, address: EthAddress, name: string):
|
|||
}
|
||||
|
||||
proc dumpDebugData(tester: Tester, vmState: BaseVMState, sender: EthAddress, gasUsed: GasInt, success: bool) =
|
||||
let recipient = tester.tx.getRecipient()
|
||||
let recipient = tester.tx.getRecipient(sender)
|
||||
let miner = tester.header.coinbase
|
||||
var accounts = newJObject()
|
||||
|
||||
|
|
Loading…
Reference in New Issue