rename 'txContext' to 'setupTxContext'

This commit is contained in:
andri lim 2020-01-21 00:59:15 +07:00 committed by zah
parent 933b2dad78
commit d656f7f701
6 changed files with 7 additions and 10 deletions

View File

@ -36,13 +36,11 @@ template balance(addressDb: ReadOnlyStateDb, address: EthAddress): GasInt =
proc binarySearchGas(vmState: var BaseVMState, transaction: Transaction, sender: EthAddress, gasPrice: GasInt, tolerance = 1): GasInt =
proc dummyComputation(vmState: var BaseVMState, transaction: Transaction, sender: EthAddress): Computation =
let recipient = transaction.getRecipient()
# Note that vmState may be altered
setupComputation(
vmState,
transaction,
sender,
recipient,
vmState.blockNumber.toFork)
proc dummyTransaction(gasLimit, gasPrice: GasInt, destination: EthAddress, value: UInt256): Transaction =
@ -287,11 +285,10 @@ proc setupEthRpc*(node: EthereumNode, chain: BaseChainDB, rpcsrv: RpcServer) =
contractAddress: destination,
codeAddress: CREATE_CONTRACT_ADDRESS,
value: value,
data: data,
code: vmState.readOnlyStateDB.getCode(destination).toSeq
data: data
)
vmState.txContext(
vmState.setupTxContext(
origin = sender,
gasPrice = gasPrice
)

View File

@ -43,7 +43,7 @@ proc newBaseVMState*(prevStateRoot: Hash256, header: BlockHeader,
new result
result.init(prevStateRoot, header, chainDB, tracerFlags)
proc txContext*(vmState: BaseVMState, origin: EthAddress, gasPrice: GasInt, forkOverride=none(Fork)) =
proc setupTxContext*(vmState: BaseVMState, origin: EthAddress, gasPrice: GasInt, forkOverride=none(Fork)) =
## this proc will be called each time a new transaction
## is going to be executed
vmState.txOrigin = origin

View File

@ -33,7 +33,7 @@ proc setupComputation*(vmState: BaseVMState, tx: Transaction, sender: EthAddress
debug "not enough gas to perform calculation", gas=gas
return
vmState.txContext(
vmState.setupTxContext(
origin = sender,
gasPrice = tx.gasPrice,
forkOverride = some(fork)

View File

@ -205,7 +205,7 @@ proc initComputation(vmState: BaseVMState, tx: Transaction, sender: EthAddress,
let gasUsed = 0 #tx.payload.intrinsicGas.GasInt + gasFees[fork][GasTXCreate]
vmState.txContext(
vmState.setupTxContext(
origin = sender,
gasPrice = tx.gasPrice,
forkOverride = some(fork)

View File

@ -30,7 +30,7 @@ template doTest(fixture: JsonNode, address: byte, action: untyped): untyped =
sender: EthAddress
toAddress = initAddress(address)
vmState.txContext(
vmState.setupTxContext(
origin = sender,
gasPrice = gasPrice
)

View File

@ -45,7 +45,7 @@ proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus) =
setupStateDB(fixture{"pre"}, db)
let address = fexec{"address"}.getStr.parseAddress
vmState.txContext(
vmState.setupTxContext(
origin = fexec{"origin"}.getStr.parseAddress,
gasPrice = fexec{"gasPrice"}.getHexadecimalInt
)