Moved and unstubbed intrinsicGas from vm_state_transactions

This commit is contained in:
coffeepots 2018-12-03 19:47:20 +00:00 committed by Ștefan Talpalaru
parent c2fae69318
commit 20933f494b
No known key found for this signature in database
GPG Key ID: CBF7934204F1B6F9
2 changed files with 9 additions and 9 deletions

View File

@ -20,11 +20,19 @@ proc initTransaction*(nonce: AccountNonce, gasPrice, gasLimit: GasInt, to: EthAd
result.S = S result.S = S
result.isContractCreation = isContractCreation result.isContractCreation = isContractCreation
func intrinsicGas*(data: openarray[byte]): GasInt =
result = 21_000 # GasTransaction
for i in data:
if i == 0:
result += 4 # GasTXDataZero
else:
result += 68 # GasTXDataNonZero
proc intrinsicGas*(t: Transaction): GasInt = proc intrinsicGas*(t: Transaction): GasInt =
# Compute the baseline gas cost for this transaction. This is the amount # Compute the baseline gas cost for this transaction. This is the amount
# of gas needed to send this transaction (but that is not actually used # of gas needed to send this transaction (but that is not actually used
# for computation) # for computation)
raise newException(ValueError, "not implemented intrinsicGas") result = t.payload.intrinsicGas
proc validate*(t: Transaction) = proc validate*(t: Transaction) =
# Hook called during instantiation to ensure that all transaction # Hook called during instantiation to ensure that all transaction

View File

@ -12,14 +12,6 @@ import
./transaction, ./vm_types, ./vm_state, ./block_types, ./db/[db_chain, state_db], ./utils/header, ./transaction, ./vm_types, ./vm_state, ./block_types, ./db/[db_chain, state_db], ./utils/header,
./vm/interpreter, ./vm/interpreter/gas_costs, ./utils/addresses ./vm/interpreter, ./vm/interpreter/gas_costs, ./utils/addresses
func intrinsicGas*(data: openarray[byte]): GasInt =
result = 21_000
for i in data:
if i == 0:
result += 4
else:
result += 68
proc validateTransaction*(vmState: BaseVMState, transaction: Transaction, sender: EthAddress): bool = proc validateTransaction*(vmState: BaseVMState, transaction: Transaction, sender: EthAddress): bool =
# XXX: https://github.com/status-im/nimbus/issues/35#issuecomment-391726518 # XXX: https://github.com/status-im/nimbus/issues/35#issuecomment-391726518
# XXX: lots of avoidable u256 construction # XXX: lots of avoidable u256 construction