diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-08-10 21:39:43 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-08-14 20:27:44 +0800 |
commit | 6131dd55c5cb6f964a1b8e8d51400f10d545a92e (patch) | |
tree | 3ac0b6667e5e2afbad8f7f5a528bc78f2517e78d /params | |
parent | 7bbdf3e2687ea293b68a7f73c039cbde411217fa (diff) | |
download | dexon-6131dd55c5cb6f964a1b8e8d51400f10d545a92e.tar.gz dexon-6131dd55c5cb6f964a1b8e8d51400f10d545a92e.tar.zst dexon-6131dd55c5cb6f964a1b8e8d51400f10d545a92e.zip |
core/vm: polish precompile contract code, add tests and benches
* Update modexp gas calculation to new version
* Fix modexp modulo 0 special case to return zero
Diffstat (limited to 'params')
-rw-r--r-- | params/protocol_params.go | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/params/protocol_params.go b/params/protocol_params.go index f48bf4992..9c84c7d34 100644 --- a/params/protocol_params.go +++ b/params/protocol_params.go @@ -31,23 +31,16 @@ const ( SstoreSetGas uint64 = 20000 // Once per SLOAD operation. LogDataGas uint64 = 8 // Per byte in a LOG* operation's data. CallStipend uint64 = 2300 // Free gas given at beginning of call. - EcrecoverGas uint64 = 3000 // - Sha256WordGas uint64 = 12 // Sha3Gas uint64 = 30 // Once per SHA3 operation. - Sha256Gas uint64 = 60 // - IdentityWordGas uint64 = 3 // Sha3WordGas uint64 = 6 // Once per word of the SHA3 operation's data. SstoreResetGas uint64 = 5000 // Once per SSTORE operation if the zeroness changes from zero. SstoreClearGas uint64 = 5000 // Once per SSTORE operation if the zeroness doesn't change. SstoreRefundGas uint64 = 15000 // Once per SSTORE operation if the zeroness changes to zero. JumpdestGas uint64 = 1 // Refunded gas, once per SSTORE operation if the zeroness changes to zero. - IdentityGas uint64 = 15 // EpochDuration uint64 = 30000 // Duration between proof-of-work epochs. CallGas uint64 = 40 // Once per CALL operation & message call transaction. CreateDataGas uint64 = 200 // - Ripemd160Gas uint64 = 600 // - Ripemd160WordGas uint64 = 120 // CallCreateDepth uint64 = 1024 // Maximum depth of call/create stack. ExpGas uint64 = 10 // Once per EXP instruction LogGas uint64 = 375 // Per LOG* operation. @@ -60,7 +53,22 @@ const ( MemoryGas uint64 = 3 // Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL. TxDataNonZeroGas uint64 = 68 // Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. - MaxCodeSize = 24576 + MaxCodeSize = 24576 // Maximum bytecode to permit for a contract + + // Precompiled contract gas prices + + EcrecoverGas uint64 = 3000 // Elliptic curve sender recovery gas price + Sha256BaseGas uint64 = 60 // Base price for a SHA256 operation + Sha256PerWordGas uint64 = 12 // Per-word price for a SHA256 operation + Ripemd160BaseGas uint64 = 600 // Base price for a RIPEMD160 operation + Ripemd160PerWordGas uint64 = 120 // Per-word price for a RIPEMD160 operation + IdentityBaseGas uint64 = 15 // Base price for a data copy operation + IdentityPerWordGas uint64 = 3 // Per-work price for a data copy operation + ModExpQuadCoeffDiv uint64 = 100 // Divisor for the quadratic particle of the big int modular exponentiation + Bn256AddGas uint64 = 500 // Gas needed for an elliptic curve addition + Bn256ScalarMulGas uint64 = 2000 // Gas needed for an elliptic curve scalar multiplication + Bn256PairingBaseGas uint64 = 100000 // Base price for an elliptic curve pairing check + Bn256PairingPerPointGas uint64 = 80000 // Per-point price for an elliptic curve pairing check ) var ( |