A brief reminder what gas parameters we are using for precompiles and what role they play:
- intrinsic gas = storage cost * tx size + base gas
if transaction can’t cover intrinsic gas it is ineffective, won’t be executed and will be dropped from a block during construction.
- base gas
fixed amount of gas set for every template. should cover verification cost (in precompiles case 1-3 ed25519 signatures)
- fixed gas
cost to execute a transaction. in precompiles all transactions are doing basic arithmetic and loading/storing state.
Single ed25519 verify takes between 20-200 us per edd25519 signature. Mid range cpu would take about 100 us, this is what i will be using as a reference for estimation below.
Every other cpu operation in precompiles is negligible in comparison, such as arithmetic for Spend transactions.
As a reference cpu cost i take 2 cents per hour, based on cheap vcpu on gcp. In an hour single core can run 36000000 ed25519 instructions. So by dividing 2 cents by 36000000 we get:
CPU_PRICE = 5.5e-10 USD
To define byte price i took a price of cheap 1TB ssd device, 50 USD. Assuming that it lasts for 10 years, we also take electricity cost to be approximately 100 USD for that device.
BYTE_PRICE = 150 / 1073741824 = 1.4e-07 USD
USD to smidges
Total issuence is 2_400_000_000_000_000_000 smidges.
I assume random market cap of 600_000_000_000. I think optimistic makes sense, as the total cost can be always scaled with gas price.
For computation below single smidge is 2.5e-07 USD.
BASE_GAS = N * CPU_PRICE
N - is a number of ed25519 signatures. Precompiled templates will use between 1-3 signatures.
INTRINSIC_GAS = BYTE_PRICE * TX_SIZE + BASE_GAS
Besides storing transaction itself - every transaction writes something to the state itself. For comparison on ethereum SSTORE costs 20000 gas per 32 bytes, and storing calldata costs 512 gas per 32 bytes. Below i will use a factor of 30 for the difference in price between updating state and storing transactions.
FIXED_GAS = N * (30 * BYTE_PRICE * STATE_UPDATE_SIZE + BYTE_PRICE * LOAD_STATE_SIZE / 10)
STATE_UPDATE_SIZE for spawn transactions will include immutable state + balance + nonce, for spend transactions only balance + nonce.
N in FIXED_GAS is the number of loaded accounts, it will be between 1 and 3 for different transactions types.
Spawn transaction size - 150 bytes
INTRINSIC_GAS = 1.4e-07 * 150 + 5.5e-10 = 2.1e-05 USD = 84 smidges.
FIXED_GAS = 30 * 1.4e-07 * 48 = 2e-04 USD = 800 smidges
TOTAL_GAS = 884 smidges
Spend transaction size - 120 bytes.
INTRINSIC_GAS = 1.4e-07 * 120 + 5.5e-10 = 1.68-05 USD = 67 smidges
FIXED_GAS = 30 * 1.4e-07 * 16 + 1.4e-08 * 48 = 6.78e-05 = 271 smidges
TOTAL_GAS = 338
Multi sig 3/5
Spawn transaction size - 410 bytes.
INTRINSIC_GAS = 1.4e-07 * 410 + 5.5e-10 * 3 = 5.74e-05 USD= = 271 smidges
FIXED_GAS = 30 * 1.4e-07 * 176 = 7e-04 = 2800 smidges
TOTAL_GAS = 3071 smidges
Fixed gas includes payment for 5 public key that are stored as an immutable state, and balance/nonce.
Spend transaction size - 250 bytes
INTRINSIC_GAS = 1.4e-07 * 250 + 5.5e-10 * 3 = 3.5e-05 USD = 140 smidges
FIXED_GAS = 30 * 1.4e-07 * 16 + 1.4e-08 * 176 = 7e-05 USD = 278 smidges
TOTAL_GAS = 418 smidges