Update precompile gas costs case (cosmetic change)

This commit is contained in:
coffeepots 2018-10-03 17:59:41 +01:00
parent 3249c3e048
commit 6a4cd4ec67
2 changed files with 17 additions and 17 deletions

View File

@ -588,14 +588,14 @@ proc forkToSchedule*(fork: Fork): GasCosts =
const
## Precompile costs
GAS_SHA256* = 60
GAS_SHA256WORD* = 12
GAS_RIPEMD160* = 600
GAS_RIPEMD160WORD* = 120
GAS_IDENTITY* = 15
GAS_IDENTITYWORD* = 3
GAS_ECRECOVER* = 3000
GAS_ECADD* = 500
GAS_ECMUL* = 40000
GAS_ECPAIRING_BASE* = 100000
GAS_ECPAIRING_PER_POINT* = 80000
GasSHA256* = 60
GasSHA256Word* = 12
GasRIPEMD160* = 600
GasRIPEMD160Word* = 120
GasIdentity* = 15
GasIdentityWord* = 3
GasECRecover* = 3000
GasECAdd* = 500
GasECMul* = 40000
GasECPairingBase* = 100000
GasECPairingPerPoint* = 80000

View File

@ -24,7 +24,7 @@ proc getSignature*(computation: BaseComputation): Signature =
proc ecRecover*(computation: var BaseComputation) =
computation.gasMeter.consumeGas(
GAS_ECRECOVER,
GasECRecover,
reason="ECRecover Precompile")
# TODO: Check endian
@ -43,7 +43,7 @@ proc ecRecover*(computation: var BaseComputation) =
proc sha256*(computation: var BaseComputation) =
let
wordCount = computation.msg.data.len div 32
gasFee = GAS_SHA256 + wordCount * GAS_SHA256WORD
gasFee = GasSHA256 + wordCount * GasSHA256Word
computation.gasMeter.consumeGas(gasFee, reason="SHA256 Precompile")
computation.rawOutput = @(keccak_256.digest(computation.msg.data).data)
@ -52,7 +52,7 @@ proc sha256*(computation: var BaseComputation) =
proc ripemd160(computation: var BaseComputation) =
let
wordCount = computation.msg.data.len div 32
gasFee = GAS_RIPEMD160 + wordCount * GAS_RIPEMD160WORD
gasFee = GasRIPEMD160 + wordCount * GasRIPEMD160Word
computation.gasMeter.consumeGas(gasFee, reason="RIPEMD160 Precompile")
computation.rawOutput = @(nimcrypto.ripemd160.digest(computation.msg.data).data)
@ -61,9 +61,9 @@ proc ripemd160(computation: var BaseComputation) =
proc identity*(computation: var BaseComputation) =
let
wordCount = computation.msg.data.len div 32
gasFee = GAS_IDENTITY + wordCount * GAS_IDENTITYWORD
gasFee = GasIdentity + wordCount * GasIdentityWord
computation.gasMeter.consumeGas(gas_fee, reason="Identity Precompile")
computation.gasMeter.consumeGas(gasFee, reason="Identity Precompile")
computation.rawOutput = computation.msg.data
debug "Identity precompile", output = computation.rawOutput
@ -77,7 +77,7 @@ proc execPrecompiles*(computation: var BaseComputation): bool {.inline.} =
let lb = computation.msg.codeAddress[bOffset]
if lb < 9:
if lb in PrecompileAddresses.low.byte .. PrecompileAddresses.high.byte:
result = true
let precompile = PrecompileAddresses(lb)
debug "Call precompile ", precompile = precompile, codeAddr = computation.msg.codeAddress