Skip to content

Chain: Remove base_per_transaction_net_usage consensus parameter#519

Merged
heifner merged 2 commits into
masterfrom
cleanup/remove-base-per-transaction-net-usage
Jul 15, 2026
Merged

Chain: Remove base_per_transaction_net_usage consensus parameter#519
heifner merged 2 commits into
masterfrom
cleanup/remove-base-per-transaction-net-usage

Conversation

@heifner

@heifner heifner commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Removes the base_per_transaction_net_usage chain config parameter. Since #111 replaced the per-transaction base NET charge with the computed per-action overhead (billable_net_per_action_overhead), the parameter has been dead weight: only read by chain_config::validate() and echoed through SHiP and contract ABIs. A silently-unused consensus parameter invites confusion -- governance could vote the value and nothing would happen.

Consensus impact

  • The field packs into genesis_state, so the chain id of every genesis changes: this is a regenesis-level change and a running network cannot adopt it in place (the reference snap_v1 chain id is now 087244f65e31c0106a58554b8f855e30ae657efb98c6c40348bb14db8bdb3f8e).
  • The id-tagged set_parameters_packed/get_parameters_packed protocol renumbers: ids above 3 shift down by one, PARAMS_COUNT 20 -> 19. sysio.system::setparams and the params_test/action_results test contracts are renumbered to match.
  • Packed chain_config_v0 shrinks 80 -> 76 bytes (system_host_tests stability check updated).
  • SHiP chain_config_v0 loses the field in both the ABI and the global_property serializer; old SHiP streams and old snapshots are incompatible, which regenesis covers.

Lockstep

Regenerated reference data

Deep-mind log, snapshot compatibility files (blocks.*, snap_v1.*), consensus_blockchain, and the sys-util snapshot info expectations.

After PR #111 replaced the per-transaction base NET charge with the
computed per-action overhead (billable_net_per_action_overhead), this
parameter was only read by chain_config::validate() and echoed through
SHiP and contract ABIs. A silently-unused on-chain parameter invites
confusion -- governance could vote the value and nothing would happen --
so remove it entirely:

- chain_config_v0: drop the field, enum id, comparison, logging,
  FC_REFLECT entry and the id-tagged pack/unpack cases; ids above it
  shift down by one (PARAMS_COUNT 20 -> 19, packed size 80 -> 76)
- config: drop default_base_per_transaction_net_usage and the
  min_net_usage_delta_between_base_and_max_for_trx validation that
  existed only to bound it
- genesis_state: drop the initializer; the field packed into
  genesis_state, so the chain_id of every genesis changes (regenesis
  required)
- state_history: drop the field from the ship ABI and the
  global_property serializer
- sysio.system: renumber the set_parameters_packed ids in setparams
- renumber the hardcoded parameter ids in the params_test and
  action_results test contracts
- rebuild sysio.bios/sysio.system/params_test/action_results against
  the matching wire-cdt blockchain_parameters removal
- regenerate reference data for the new chain id: deep-mind log,
  snapshot compatibility files, consensus_blockchain, and the sys-util
  snapshot info expectations

Pairs with the wire-cdt blockchain_parameters removal: the host unpacks
the packed blob directly into chain_config_v0, so the CDT struct must
match its fc::raw layout field-for-field.
action_validate_exception,
"max transaction net usage must be at least {} bytes larger than base net usage per transaction",
config::min_net_usage_delta_between_base_and_max_for_trx );
SYS_ASSERT( context_free_discount_net_usage_den > 0, action_validate_exception,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Preserve a minimum transaction NET limit

Removing the base field also removes the only lower-bound validation for max_transaction_net_usage. A value of zero now passes validation whenever max_block_net_usage is positive. transaction_context then caps every non-read-only transaction at this value and rejects every billable action—including a corrective setparams transaction—leaving the chain recoverable only by hard fork. Please preserve a base-independent minimum transaction NET limit and add rejection tests for zero and undersized values.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2603982: validate() now enforces a base-independent floor, config::min_max_transaction_net_usage = 10 KiB (matching the old effective bound from the delta check), with the recovery rationale documented on the constant. system_host_tests covers zero and floor-1 (both rejected) and the floor value (accepted).

Review follow-up: removing base_per_transaction_net_usage also removed
the delta check that was the only lower bound on
max_transaction_net_usage. A zero or tiny value would pass validation
and then cap every billable transaction -- including the corrective
setparams -- wedging the chain. Enforce a base-independent floor
(config::min_max_transaction_net_usage, 10 KiB, matching the old
effective bound) and cover zero, floor-1, and floor values with tests.
@heifner
heifner requested a review from huangminghuang July 15, 2026 21:22
@heifner
heifner merged commit 9ef50f4 into master Jul 15, 2026
13 checks passed
@heifner
heifner deleted the cleanup/remove-base-per-transaction-net-usage branch July 15, 2026 21:31
heifner added a commit that referenced this pull request Jul 15, 2026
Reconciles the depot header/chain enforcement with the #519 base_per_transaction_net_usage removal and the #506 SEC-102 protos now on master. msgch.wasm recompiled with the post-#519 CDT (byte-identical — msgch does not serialize blockchain_parameters); ABI unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants