HookFeeV2 keeps the flat model (100 units per API call, 10 units per drop,
rounded up). HookFeeV3 layers on top of it:
- features.macro: add HookFeeV3 (Supported::yes, DefaultNo)
- getImportWhitelist: every API defaults to hook_api::api_call_cost;
HOOK_API_COST overrides only when HookFeeV3 is enabled, and uses find()
so a cost line can never whitelist an API whose definition is gated off
- hookCostToFee: flat V2 pricing unless HookFeeV3 is enabled, then the
ledger's HookGasPrice applies
- sfHookGasPrice on FeeSettings / SetFee / validations, fee voting,
genesis FeeSettings and server_info / ledger stream output are gated
on HookFeeV3 instead of HookFeeV2
- tests that only avoid the amendment because genesis FeeSettings changes
now subtract HookFeeV3; SetHook cost expectations remain the V3 values
Builds on the flat HookFeeV2 model:
- hook_api.macro: HOOK_API_COST(name, cost, amendment) per API, loaded
into the import whitelist and charged per import call in Guard.h
- sfHookGasPrice on FeeSettings / SetFee / validations, voted through
FeeVote and exposed in server_info, ledger streams and validations
- hook_gas_price config knob (FeeSetup) and genesis FeeSettings value
- hookCostToFee(view, cost) prices cost units with the ledger's gas price
- jtx Env applies features before the app is built so genesis FeeSettings
see them; hash-order dependent tests updated accordingly
Per-API cost tables and the votable HookGasPrice move to the HookFeeV3
branch. V2 charges one cost unit per wasm instruction and 100 units per
hook API call (including _g), with ten units per drop rounded up.
- Guard.h: drop the per-import cost map, charge a fixed api_call_cost on
every import call
- Remove sfHookGasPrice, FeeSettings/SetFee/validation fields, fee voting,
server_info output and the hook_gas_price config knob
- hookCostToFee no longer depends on the ledger view
- Restore genesis ledger, jtx Env and fragile-hash tests to dev
- Update expected hook costs in SetHook_test
Api costs were looked up as import_type_map[callee_idx], but that map is
keyed by wasm type index while callee_idx is a function index. A hook was
charged whichever api happened to occupy the callee's index, or nothing at
all when no type carried that index, and imports sharing a signature
collapsed to a single cost. Reordering imports was enough to call
util_verify, the most expensive api, for free. Costs now come from
import_cost_map, keyed by import function index, and import_type_map is
reduced to the signature checking it is actually used for.
compute_wce() applied the loop multiplier to instruction_count only, so an
api call inside a guarded loop was charged for one iteration no matter how
many the guard allowed. The multiplier now applies to execution_cost as
well, with the same floor instruction_count uses.