Skip to content

Add ace to pool hook#1593

Merged
matYang merged 41 commits intodevelopfrom
add-ace-to-pool-hook
Feb 6, 2026
Merged

Add ace to pool hook#1593
matYang merged 41 commits intodevelopfrom
add-ace-to-pool-hook

Conversation

@matYang
Copy link
Collaborator

@matYang matYang commented Jan 22, 2026

No description provided.

@matYang matYang changed the base branch from main to develop January 22, 2026 17:02
@matYang matYang requested review from 0xsuryansh and RensR January 28, 2026 09:49
/**
* @title IPolicyEngine
* @dev Interface for the policy engine.
*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment structure doesn't follow the style guide, but this is a completely internal project right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

latest version of IPolicyEngine.sol has almost finished audit and will be ported to a public repo and published in an npm package in the coming week, we'll eventually consume from there, let's keep the source as is for now

@@ -0,0 +1,378 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.20;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unusual pragma for something with no imports

Copy link
Collaborator Author

@matYang matYang Jan 30, 2026

Choose a reason for hiding this comment

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

ditto

Copy link
Collaborator

Choose a reason for hiding this comment

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

This isn't resolved? What do you mean ditto?

/// @param data The bytes to slice.
/// @param start The index starting from which to return the sub array.
/// @return Bytes sub array starting from start index.
function _slice(
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is only used to cut off the first 4 bytes.

Can't you just add this function to AdvancedPoolHooksSetup, and maybe just make it external, make data calldata and use [4:]?


Pool.LockOrBurnInV1 memory lockOrBurnIn = _createLockOrBurnIn();

vm.stopPrank();
Copy link
Collaborator

Choose a reason for hiding this comment

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

When you're doing this in almost every test you can probably make it part of the setup and just do it in the few tests that need another prank

}
}

contract AdvancedPoolHooks_setPolicyEngineAllowFailedDetach is AdvancedPoolHooksSetup {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this a different contract?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

technically setPolicyEngineAllowFailedDetach is a standalone method so warranted its own test contract, but it was so simple I was thinking maybe just include in the same file; nvm, extracting it into its own

@matYang matYang marked this pull request as ready for review January 29, 2026 01:07
@matYang matYang requested a review from a team as a code owner January 29, 2026 01:07
});
bytes memory policyData =
abi.encodeWithSelector(CCIPPolicyEnginePayloads.POOL_HOOK_OUTBOUND_POLICY_DATA_V1_TAG, outboundData);
policyEngine.run(
Copy link

@masha256 masha256 Jan 30, 2026

Choose a reason for hiding this comment

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

I dont think we want to have this intermediate PoolHookOutboundPolicyDataV1. It would be cleaner if we just directly pass the calldata to the policy engine as the payload and have the extractor explicity decode these parameters into usable policy parameters. We also want to use tokenArgs as the "context" (ie, where something like the offchain permit can be passed to the policy engine). For example, the preflightCheck could be as simple as:

  function preflightCheck(
    Pool.LockOrBurnInV1 calldata lockOrBurnIn,
    uint16 blockConfirmationRequested,
    bytes calldata tokenArgs
  ) external {
    if (i_authorizedCallersEnabled) {
      _validateCaller();
    }
    checkAllowList(lockOrBurnIn.originalSender);

    if (address(s_policyEngine) != address(0)) {
      s_policyEngine.run(
        IPolicyEngine.Payload({selector: msg.sig, sender: msg.sender, data: msg.data[4:], context: tokenArgs})
      );
    }
  }

And postFlightCheck:

  function postFlightCheck(
    Pool.ReleaseOrMintInV1 calldata releaseOrMintIn,
    uint256 localAmount,
    uint16 blockConfirmationRequested
  ) external {
    if (i_authorizedCallersEnabled) {
      _validateCaller();
    }

    if (address(s_policyEngine) != address(0)) {
      s_policyEngine.run(
        IPolicyEngine.Payload({selector: msg.sig, sender: msg.sender, data: msg.data[4:], context: releaseOrMintIn.offchainTokenData})
      );
    }
  }

masha256
masha256 previously approved these changes Feb 4, 2026
poolAddr := common.HexToAddress(tpDeployReport.Output.Address)
hooksAddr := common.HexToAddress(hooksDeployReport.Output.Address)

applyAuthorizedCallerUpdatesReport, err := cldf_ops.ExecuteOperation(b, advanced_pool_hooks.ApplyAuthorizedCallerUpdates, chain, evm_contract.FunctionInput[advanced_pool_hooks.AuthorizedCallerArgs]{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should you not check if it's already configured?


function testFuzz_postflightCheck_WithPolicyEngine(
bytes memory sourcePoolData,
bytes memory offchainTokenData
Copy link
Collaborator

@RensR RensR Feb 5, 2026

Choose a reason for hiding this comment

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

nit: not sure this is worth fuzz testing as no edge cases are tested, just input passing. Fuzz tests take >100 times longer to run

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah questionable fuzzing value, changed to regular tests


function test_postflightCheck_RevertWhen_PolicyEngineRejects() public {
s_advancedPoolHooks.setPolicyEngine(address(s_mockPolicyEngine));
s_mockPolicyEngine.setShouldRevert(true, "Policy rejected");
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: cleaner as var instead of duplicating magic values

RensR
RensR previously approved these changes Feb 5, 2026
# Conflicts:
#	ccv/chains/evm/deployment/go.mod
#	ccv/chains/evm/deployment/go.sum
#	ccv/chains/evm/gobindings/generated/latest/advanced_pool_hooks/advanced_pool_hooks.go
#	chains/evm/.gas-snapshot
#	chains/evm/contracts/pools/AdvancedPoolHooks.sol
#	chains/evm/gobindings/generation/generated-wrapper-dependency-versions-do-not-edit.txt
@RensR RensR dismissed stale reviews from masha256 and themself via 726d565 February 5, 2026 16:57
@RensR RensR requested a review from a team as a code owner February 5, 2026 16:58
@matYang matYang requested review from RensR and masha256 February 6, 2026 08:47
@matYang matYang enabled auto-merge (squash) February 6, 2026 09:15
RensR
RensR previously approved these changes Feb 6, 2026
masha256
masha256 previously approved these changes Feb 6, 2026
@matYang matYang dismissed stale reviews from masha256 and RensR via 811a6a6 February 6, 2026 16:48
@github-actions
Copy link

github-actions bot commented Feb 6, 2026

Metric add-ace-to-pool-hook develop
Coverage 69.8% 69.5%

@matYang matYang merged commit f1613c6 into develop Feb 6, 2026
26 of 28 checks passed
@matYang matYang deleted the add-ace-to-pool-hook branch February 6, 2026 18:15
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.

5 participants