Skip to content

Work#93

Closed
JaCoderX wants to merge 18 commits into
mainfrom
work
Closed

Work#93
JaCoderX wants to merge 18 commits into
mainfrom
work

Conversation

@JaCoderX

@JaCoderX JaCoderX commented Mar 3, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Added getAuthorizedWallets() to retrieve wallets for a role.
    • Added getActiveRolePermissions() to query role permissions.
  • Bug Fixes

    • Fixed unsafe function unregistration allowing stale role permissions.
  • Refactor

    • Simplified API naming: renamed getWalletsInRole() to getAuthorizedWallets().
    • Streamlined internal function names for clarity.
    • Updated return structure field names (roleHashReturnhash).
  • Tests

    • Added comprehensive fuzz test for unsafe function unregistration scenarios.

…d EngineBlox

This commit updates parameter names in the BaseStateMachine and EngineBlox libraries to enhance clarity and consistency. Specifically, it renames `roleHashReturn` to `hash` and `enforceProtectedSchemas` to `requireProtected` in the BaseStateMachine contract. In the EngineBlox library, it modifies `_newTimeLockPeriodSec` to `periodSec`, and updates function names for better readability, such as changing `createNewTxRecord` to `createTxRecord` and `addToPendingTransactionsList` to `addPendingTx`. These changes aim to improve code maintainability and understanding for future developers.
…gineBlox

This commit refactors the hook management functions in the BaseStateMachine and EngineBlox libraries to improve clarity and consistency. The function names have been updated to better reflect their actions: `addTargetToFunctionHooks` is now `setHook`, `removeTargetFromFunctionHooks` is now `clearHook`, and `getFunctionHookTargets` is now `getHooks`. These changes enhance the readability of the code and ensure that the function names accurately describe their purpose, contributing to better maintainability for future developers.
…ine and EngineBlox

This commit refactors the wallet update functions in the BaseStateMachine and EngineBlox libraries to improve clarity and consistency. The function names have been updated from `_updateAssignedWallet` to `_updateWallet` and `updateAssignedWallet` to `updateWallet`, better reflecting their purpose of replacing an old wallet with a new one. These changes enhance code readability and maintainability for future developers.
This commit refactors the whitelist management functions in the BaseStateMachine and GuardController contracts to improve clarity and consistency. The function names have been updated from `_addTargetToFunctionWhitelist` to `_addTargetToWhitelist` and from `_removeTargetFromFunctionWhitelist` to `_removeTargetFromWhitelist`. These changes enhance code readability and maintainability, ensuring that the function names accurately reflect their purpose in managing the whitelist of targets.
…seStateMachine and EngineBlox

This commit refactors the function schema management methods in the BaseStateMachine and EngineBlox libraries to improve clarity and consistency. The method `_removeFunctionSchema` has been renamed to `_unregisterFunction`, and the corresponding comments have been updated to reflect this change. These modifications enhance code readability and maintainability, ensuring that the function names accurately describe their purpose in managing function schemas.
…aseStateMachine

This commit refactors the function schema and role management methods in the BaseStateMachine contract to enhance clarity and consistency. The method `_getSecureState()` has been replaced with `_createFunctionSchema()` for creating function schemas, and `_addFunctionToRole()` is now used for adding functions to roles. These changes improve code readability and maintainability, ensuring that the function names accurately reflect their intended actions.
…StateMachine and EngineBlox

This commit refactors the function schema management methods in the BaseStateMachine and EngineBlox libraries to enhance clarity and consistency. The method `_createFunctionSchema` has been renamed to `_registerFunction`, and the corresponding comments have been updated to reflect this change. Additionally, the method `_registerFunction` in the GuardController has been renamed to `_registerGuardedFunction`. These modifications improve code readability and maintainability, ensuring that the function names accurately describe their purpose in managing function schemas.
… EngineBlox

This commit refactors the transaction data preparation function in the EngineBlox library by renaming `prepareTransactionData` to `buildCallData`. This change enhances clarity regarding the function's purpose, which is to construct transaction call data from execution selectors and parameters without executing the transaction. The update improves code readability and maintainability, ensuring that function names accurately reflect their intended actions.
…I files

This commit updates the ABI files for multiple contracts, changing the parameter name `roleHashReturn` to `hash`. This change enhances consistency and clarity in the naming conventions used across the ABI definitions, ensuring that the parameter names accurately reflect their purpose. The update contributes to improved readability and maintainability of the codebase.
…achine and EngineBlox

This commit refactors several state management functions in the BaseStateMachine and EngineBlox libraries to enhance clarity and consistency. The functions `getPendingTransactionsList`, `getWalletsInRole`, `getSupportedOperationTypesList`, `getSupportedRolesList`, and `getSupportedFunctionsList` have been renamed to `getPendingTransactions`, `getAuthorizedWallets`, `getSupportedOperationTypes`, `getSupportedRoles`, and `getSupportedFunctions`, respectively. These changes improve code readability and maintainability, ensuring that the function names accurately reflect their intended actions.
This commit refactors the ABI definitions across multiple contracts by removing the `functionSchemaExists` and `getWalletsInRole` functions, replacing them with the `getAuthorizedWallets` function. This change improves clarity in the naming conventions and ensures that the ABI accurately reflects the intended functionality. The updates contribute to better readability and maintainability of the codebase.
…chine

This commit updates the function names across the RuntimeRBAC and BaseStateMachine documentation and TypeScript SDK to enhance clarity and consistency. The function `getWalletsInRole` has been renamed to `getAuthorizedWallets`, and several other functions have been streamlined to remove the "List" suffix, such as `getPendingTransactionsList` to `getPendingTransactions`, `getSupportedRolesList` to `getSupportedRoles`, and `getSupportedFunctionsList` to `getSupportedFunctions`. These changes improve code readability and maintainability, ensuring that the function names accurately reflect their intended actions.
…clarity

This commit adds a validation check for zero addresses in the `addFunctionTargetHook` function of the EngineBlox library, utilizing the `SharedValidation.validateNotZeroAddress` method. Additionally, it updates the documentation in the StateAbstraction file to clarify the usage of the `_getFunctionsByOperationType` function, ensuring that it is correctly referenced in relation to the `unregisterFunction` and `_validateAnyRole` methods. These changes improve code robustness and documentation accuracy, contributing to better maintainability and understanding of the codebase.
…documentation

This commit adds validation checks in the EngineBlox library to ensure that both execution and handler selectors have registered function schemas, improving the robustness of the function permission checks. Additionally, it updates the TypeScript SDK documentation to reflect the renaming of the `getWalletsInRole` function to `getAuthorizedWallets`, enhancing clarity and consistency in the API. These changes contribute to better maintainability and understanding of the codebase.
…unction unregistration

This commit introduces a new entry in the Attack Vectors Codex detailing the medium severity issue of unsafe function unregistration with stale permissions. It includes a description of the attack scenario, current protections, and related tests. Additionally, the test documentation is updated to include the new `UnregisterFunctionFuzz.t.sol` file, which contains fuzz tests for this specific vulnerability, ensuring comprehensive coverage and validation of the protection mechanisms in place. The final coverage report is also updated to reflect the addition of this test, maintaining clarity and accuracy in the documentation.
…on handling

This commit updates the fuzz tests in `ComprehensiveCompositeFuzz.t.sol` and `ComprehensiveStateMachineFuzz.t.sol` to improve the registration and permission handling of function schemas. It introduces new helper functions for registering and whitelisting targets, ensuring that the appropriate permissions are granted for executing functions. Additionally, the tests now include checks for insufficient balance handling in an authorized context, enhancing the robustness of the security validations. These changes contribute to better coverage and validation of the function permission mechanisms within the EngineBlox framework.
…validation

This commit updates the fuzz tests in `ComprehensiveCompositeFuzz.t.sol` and `UnregisterFunctionFuzz.t.sol` to improve the validation of time-lock execution and function signature consistency. It introduces a critical assertion in the `approveTimeLockExecutionWithMetaTx` test to immediately fail if the function is executed before the designated release time, addressing potential regression issues. Additionally, it adds a check to ensure that the provided function signature matches the derived selector, preventing misleading test setups. These enhancements contribute to better coverage and robustness in the security validations of the EngineBlox framework.
…ta-tx time-lock interactions

This commit revises the Attack Vectors Codex to clarify the use of meta-transactions as a privileged path for approving time-locked transactions, emphasizing the importance of proper RBAC and schema configuration to prevent bypassing time-lock protections. Additionally, it enhances the fuzz tests in `ComprehensiveCompositeFuzz.t.sol` to ensure that meta-transaction approvals are gated by permissions, verifying that unauthorized or misconfigured attempts revert correctly. The final coverage report is updated to reflect the addition of a new test, maintaining comprehensive coverage and validation of security mechanisms within the EngineBlox framework.
@JaCoderX JaCoderX closed this Mar 3, 2026
@coderabbitai

coderabbitai Bot commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9906afd and 3841ccb.

📒 Files selected for processing (55)
  • abi/AccountBlox.abi.json
  • abi/BaseStateMachine.abi.json
  • abi/CopyBlox.abi.json
  • abi/GuardController.abi.json
  • abi/RuntimeRBAC.abi.json
  • abi/SecureOwnable.abi.json
  • abi/SimpleRWA20.abi.json
  • abi/SimpleVault.abi.json
  • contracts/core/base/BaseStateMachine.sol
  • contracts/core/execution/GuardController.sol
  • contracts/core/lib/EngineBlox.sol
  • contracts/core/security/SecureOwnable.sol
  • docs/core/access/RuntimeRBAC.md
  • docs/core/base/BaseStateMachine.md
  • docs/core/lib/StateAbstraction.md
  • scripts/sanity-sdk/guard-controller/base-test.ts
  • scripts/sanity-sdk/guard-controller/erc20-mint-controller-tests.ts
  • scripts/sanity-sdk/guard-controller/whitelist-tests.ts
  • scripts/sanity-sdk/runtime-rbac/rbac-tests.ts
  • scripts/sanity/secure-ownable/broadcaster-update-tests.cjs
  • sdk/typescript/README.md
  • sdk/typescript/abi/AccountBlox.abi.json
  • sdk/typescript/abi/BaseStateMachine.abi.json
  • sdk/typescript/abi/CopyBlox.abi.json
  • sdk/typescript/abi/GuardController.abi.json
  • sdk/typescript/abi/RuntimeRBAC.abi.json
  • sdk/typescript/abi/SecureOwnable.abi.json
  • sdk/typescript/abi/SimpleRWA20.abi.json
  • sdk/typescript/abi/SimpleVault.abi.json
  • sdk/typescript/contracts/core/BaseStateMachine.tsx
  • sdk/typescript/docs/api-reference.md
  • sdk/typescript/docs/bloxchain-architecture.md
  • sdk/typescript/docs/examples-basic.md
  • sdk/typescript/docs/runtime-rbac.md
  • sdk/typescript/interfaces/base.state.machine.index.tsx
  • sdk/typescript/interfaces/core.access.index.tsx
  • sdk/typescript/interfaces/core.security.index.tsx
  • sdk/typescript/types/base.state.machine.index.tsx
  • sdk/typescript/utils/interface-ids.tsx
  • test/foundry/docs/ATTACK_VECTORS_CODEX.md
  • test/foundry/docs/FINAL_COVERAGE_REPORT.md
  • test/foundry/docs/TEST_DOCUMENTATION.md
  • test/foundry/docs/TEST_EXECUTION_GUIDE.md
  • test/foundry/fuzz/ComprehensiveAccessControlFuzz.t.sol
  • test/foundry/fuzz/ComprehensiveCompositeFuzz.t.sol
  • test/foundry/fuzz/ComprehensiveEIP712AndViewFuzz.t.sol
  • test/foundry/fuzz/ComprehensiveGasExhaustionFuzz.t.sol
  • test/foundry/fuzz/ComprehensiveInputValidationFuzz.t.sol
  • test/foundry/fuzz/ComprehensiveStateMachineFuzz.t.sol
  • test/foundry/fuzz/RBACPermissionFuzz.t.sol
  • test/foundry/fuzz/RuntimeRBACFuzz.t.sol
  • test/foundry/fuzz/UnregisterFunctionFuzz.t.sol
  • test/foundry/helpers/PaymentTestHelper.sol
  • test/foundry/unit/BaseStateMachine.t.sol
  • test/foundry/unit/RuntimeRBAC.t.sol

📝 Walkthrough

Walkthrough

Large-scale API refactoring across contracts and interfaces to improve naming conventions. Renames multiple functions to remove redundant suffixes (*List → implicit naming), deprecates functionSchemaExists and isActionSupportedByFunction, renames getWalletsInRole to getAuthorizedWallets, and updates all downstream consumers including ABIs, documentation, and test suites.

Changes

Cohort / File(s) Summary
Core Library Refactoring
contracts/core/lib/EngineBlox.sol
Renamed 15+ public/internal functions for cleaner API: removed *List suffixes, renamed wallet/schema/hook/transaction helpers, changed parameter names (_newTimeLockPeriodSecperiodSec). Added new validation via _validateActionsSupportedByFunction and enhanced permission checking. Removed isActionSupportedByFunction.
Contract Updates
contracts/core/base/BaseStateMachine.sol, contracts/core/security/SecureOwnable.sol, contracts/core/execution/GuardController.sol
Updated function calls to match EngineBlox renames; refactored internal helpers (e.g., _updateAssignedWallet_updateWallet, _createFunctionSchema_registerFunction). SecureOwnable updated 3 wallet-update call sites. GuardController adjusted whitelist/registration naming.
ABI Files
abi/*.abi.json, sdk/typescript/abi/*.abi.json (10 files)
Consistent changes across all contract ABIs: removed functionSchemaExists and isActionSupportedByFunction, renamed getWalletsInRolegetAuthorizedWallets, renamed getRole output field roleHashReturnhash. Some ABIs also added getActiveRolePermissions.
TypeScript SDK
sdk/typescript/contracts/..., sdk/typescript/interfaces/..., sdk/typescript/types/..., sdk/typescript/utils/interface-ids.tsx (7 files)
Updated contract classes and interfaces to reflect API renames: getWalletsInRolegetAuthorizedWallets, removed functionSchemaExists and isActionSupportedByFunction methods. Updated function-selector constants and interface ID calculations.
Documentation
docs/core/.../*.md, sdk/typescript/docs/*.md, README.md (11 files)
Updated all public API documentation and examples to reflect function renames and removals. Changed example code to use getAuthorizedWallets, removed references to deleted functions, updated parameter descriptions and headings.
Foundry Tests - Fuzz
test/foundry/fuzz/*.t.sol (8 files)
Updated existing fuzz tests to use new API names. Added comprehensive UnregisterFunctionFuzz.t.sol test suite with harness to verify unsafe function unregistration prevents new requests. Enhanced ComprehensiveCompositeFuzz.t.sol with explicit guard/config batch operations and permission setup.
Foundry Tests - Unit & Integration
test/foundry/unit/*.t.sol, test/foundry/scripts/*.ts (7 files)
Removed test_IsActionSupportedByFunction_ValidatesActions test. Updated remaining tests to use renamed APIs. Converted pre-check logic from functionSchemaExists to schemaOrSupportedSetPreCheck / getFunctionSchema in sanity-SDK tests.
Test Documentation & Security
test/foundry/docs/*.md, scripts/sanity-sdk/*.ts (7 files)
Updated test coverage reports and documentation: added FS-004 (unsafe function unregistration attack vector), updated ATTACK_VECTORS_CODEX with initialization and function-schema security analysis. Updated test counts (309→308 tests, 37→38 suites). Updated sanity-SDK test console messages and pre-checks.
JSDoc & Comments
scripts/sanity/secure-ownable/broadcaster-update-tests.cjs, test/foundry/fuzz/ComprehensiveGasExhaustionFuzz.t.sol (2 files)
Updated JSDoc and inline comments to reference renamed functions without behavioral changes.

Sequence Diagram(s)

The conditions for generating sequence diagrams are not met. While the changes introduce significant API refactoring, they are primarily renames and reorganization of existing control flows without introducing new sequential interactions between 3+ distinct components. The changes preserve existing functionality and do not alter the fundamental message-passing patterns between system actors.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • PR #22: Both touch function-schema and role management API surfaces, including registration/unregistration routines and functionSchemaExists-related operations.
  • PR #92: Both modify EngineBlox validation logic and add the UnregisterFunctionFuzz test suite around unsafe function unregistration.
  • PR #40: Both modify the same contract/ABI surface and public APIs, including renaming getWalletsInRole→getAuthorizedWallets and removing deprecated function-check utilities.

Poem

🐰 Hop along, dear functions new!
No more "List" in names we knew,
Wallets authorized, bright and clean,
Schemas register, finest seen!
A refactor brave, from dusk to dawn,
Our API shines—old names are gone! 🌟

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch work

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@JaCoderX JaCoderX deleted the work branch March 3, 2026 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant