Skip to content

Add get_permission_lower_bound intrinsic and expandauth action#253

Merged
heifner merged 4 commits intomasterfrom
feature/get-permission-host
Mar 17, 2026
Merged

Add get_permission_lower_bound intrinsic and expandauth action#253
heifner merged 4 commits intomasterfrom
feature/get-permission-host

Conversation

@heifner
Copy link
Copy Markdown
Contributor

@heifner heifner commented Mar 16, 2026

Summary

  • New get_permission_lower_bound host function allowing contracts to read account permission authorities
  • New expandauth system contract action that adds keys and/or account permissions to an existing authority
  • 9 unit tests including ETH (EM) key signing verification

Details

Host function: Lower-bound search on permission_index<by_owner>, serializes (perm_name, parent, last_updated, authority). Registered across all runtimes (sys-vm, sys-vm-oc, native-module) and the genesis intrinsics whitelist.

expandauth action: Requires system contract auth. Reads the current authority via the new intrinsic, deduplicates and sorts added keys/accounts, then sends an inline updateauth using the account's own permission (privileged contract pattern).

Companion CDT PR: Wire-Network/wire-cdt#37

Add a new host function that allows contracts to read account permission
authorities, and an expandauth system contract action that uses it to
add keys or account permissions to an existing authority.

Host function (get_permission_lower_bound):
- Declared in interface.hpp, implemented in permission.cpp
- Registered in sys-vm.cpp, intrinsic_mapping.hpp, genesis_intrinsics.cpp
- Lower-bound search on permission_index<by_owner>, serializes
  (perm_name, parent_name, last_updated, authority)

System contract (expandauth):
- Requires system contract auth; uses account's own permission to
  authorize the inline updateauth (privileged contract pattern)
- Reads current authority via the new intrinsic, deduplicates and sorts
  added keys/accounts, sends inline updateauth

Tests (9 cases):
- Add K1 key, add ETH (EM) key, add account permission
- Duplicate skipping, auth checks, error cases
- End-to-end ETH key signing verification
Copy link
Copy Markdown
Collaborator

@jglanz jglanz left a comment

Choose a reason for hiding this comment

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

AWESOME

Base automatically changed from feature/rm-wait-weight to master March 16, 2026 18:11
heifner added 3 commits March 16, 2026 13:17
The get_permission_lower_bound intrinsic changed the genesis chain
state, making the pre-built consensus_blockchain snapshot fixture
stale. Regenerated via --save-blockchain to fix
verify_block_compatibitity test.
The new whitelisted intrinsic shifted the intrinsics index, causing
snapshot integrity hash mismatches in test_compatible_versions tests.
@heifner heifner merged commit 9cee50d into master Mar 17, 2026
22 checks passed
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