Repository navigation
fix(runtime): price Substrate weight and bytes like EVM gas (50_000 wei per ref_time, 16 gwei per byte) — transfers cost ~1.6e-5 ORB instead of ~3e-10, so account and block spam are no longer free (spec 20) - #178
Merged
Conversation
…ei per ref_time, 16 gwei per byte) — transfers cost ~1.6e-5 ORB instead of ~3e-10, so account and block spam are no longer free (spec 20)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Substrate extrinsic fees were almost zero.
WeightToFeeandLengthToFeewereIdentityFee, so one unit ofref_timeor one byte cost 1 wei (1e-18 ORB). A balance transfer cost about 3e-10 ORB: creating a million accounts cost 0.0003 ORB, and filling every block for a day about 0.03 ORB. The same transfer over EVM costs about 1.6e-5 ORB.Substrate fees now price weight and bytes like EVM gas, so an extrinsic costs what the same work costs as an EVM transaction. Ships in spec 20.
Changes
configs/system.rs:WeightToFee = ConstantMultiplier<WeightFee>, whereWeightFee = DefaultBaseFeePerGas / WeightPerGas= 1 gwei / 20_000 = 50_000 wei per unit ofref_time.LengthToFee = ConstantMultiplier<LengthFee>, whereLengthFee= 16 gas per byte at the base fee = 16 gwei per byte, EVM's calldata price.runtime_tests/weights.rs:substrate_fees_match_evm_gaspins both constants and checks that the weight of 21_000 gas costs 21_000 × base fee.RUNTIME_VERSIONS.md: spec 20 entry.Unchanged: unsigned shielded spends (they pay
MinSpendFee, 0.01 ORB), Root calls (Pays::No), and theSlowAdjustingFeeUpdatemultiplier.Why
ExistentialDepositstays 0Raising it was tested on a dev node with ED = 0.001 ORB, against an ED = 0 control. It does stop 1-planck accounts, but it breaks three things:
transfer_all(keep_alive = false)signed with its own key is reaped and its nonce returns to 0. An earlier signed EVM transaction can then be sent again and moves funds again.Fees are what made spam free, so fees are what this changes.
Testing
TransactionFeePaid):transfer_keep_aliveeth_gasPrice)system.remark, 1 KiBsystem.remark, 64 KiBshieldedPool.shieldshieldedPool.claim_feesunshield(unsigned)sudo(..)Notes
shieldnow pays about 0.0008 ORB in Substrate fees on top of the amount shielded. Faucet amounts and the app's balance checks may need a look.