Skip to content

Commit 9c0d8b9

Browse files
committed
add doc for gas setting
1 parent 18ce436 commit 9c0d8b9

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

precompiles/src/ed25519.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ impl<A> LinearCostPrecompile for Ed25519Verify<A>
2121
where
2222
A: From<[u8; 32]>,
2323
{
24+
// https://eips.ethereum.org/EIPS/eip-665#gas-costs
25+
// According to the EIP, the base cost should be 2000 gas, less than ECDSA/secp256k1 which is 3000.
26+
// Reality: Ed25519 verification is ~2.3x more computationally expensive than ECDSA/secp256k1
27+
// So we set the base cost to 6000 gas, which is 3x of the EIP's base cost.
2428
const BASE: u64 = 6000;
2529
const WORD: u64 = 0;
2630

precompiles/src/sr25519.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ impl<A> LinearCostPrecompile for Sr25519Verify<A>
2222
where
2323
A: From<[u8; 32]>,
2424
{
25+
// There is no EIP for SR25519, so we use the same base cost as Ed25519.
2526
const BASE: u64 = 6000;
2627
const WORD: u64 = 0;
2728

0 commit comments

Comments
 (0)