Skip to content

fix(sdk): check a share's expiry in checkAccess against the latest block - #500

Open
olric3015 wants to merge 1 commit into
FhenixProtocol:masterfrom
olric3015:fix/sdk-check-access-chain-clock
Open

olric3015 wants to merge 1 commit into
FhenixProtocol:masterfrom
olric3015:fix/sdk-check-access-chain-clock

Conversation

@olric3015

@olric3015 olric3015 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

client.acp.checkAccess checks the issuer copy of a share (type sharing, no handle) for expiry with ACPUtils.isExpired(acp), which uses the local clock. The ACL rejects an ACP when acp.expiration < block.timestamp (Permissioned.sol:164), and every other path of checkAccess asks the chain. #417 moved the client's own expiry checks (get-or-create reuse, importSharedAndSign) to the latest block, and this one was not part of it.

Impact

With a chain clock ahead of the local one (a Hardhat test after time.increase), an issuer's share that the ACL already treats as expired is reported valid. The reverse also happens: when the local clock is ahead of the chain, a share that is still usable on chain is reported expired.

Fix

The handle-less sharing branch passes the latest block timestamp to ACPUtils.isExpired through getLatestBlockTimestamp, the same helper #417 uses for the defaults. This adds one getBlock request to that branch. The revocation check and the on-chain branch are unchanged.

The existing test was named "reports expiry locally" and noted the check needs no RPC. I read #388 and #417 and found no reason given for keeping this check on the local clock (the wall-clock exception in #417 is about React display code). If the local-clock check here is intended, I'm happy to close this.

Test plan

  • core/test/acps.test.ts: the two existing checkAccess sharing tests now use a stubbed latest block; added one test with the chain 2 hours ahead (expects expired) and one with the local clock 2 hours ahead (expects valid)
  • Mutation-verified: reverting core/acps.ts makes only the two new tests fail (expected 'valid' to be 'expired', expected 'expired' to be 'valid'); restored → pass
  • vitest run --project node in packages/sdk: 628 passed, 22 skipped; lint, check:types; prettier on the changed files
  • Changeset added (@cofhe/sdk: patch)

Competitor check

Searched checkAccess, isExpired, latest block, block timestamp, ACP expiration, local clock: no open PR or issue covers this. #498 touches ACP expiry in @cofhe/react hooks only.


Note

Medium Risk
Changes when issuer-side shares are reported valid vs expired, which can affect UI and client logic before on-chain use; behavior now matches ACL rules rather than introducing new permissions.

Overview
client.acp.checkAccess for an issuer’s sharing ACP (no handle) now treats expiry like the on-chain ACL: it compares acp.expiration to the latest block timestamp via getLatestBlockTimestamp, instead of the local clock.

That closes a skew bug—e.g. after Hardhat time.increase, a share the ACL already rejects could still look valid, or the opposite when the wall clock runs ahead of the chain. The handle-less branch adds one getBlock; revocation and other checkAccess paths are unchanged.

Tests stub the chain clock and add cases for chain-ahead vs local-ahead expiry; a patch changeset documents the fix for @cofhe/sdk.

Reviewed by Cursor Bugbot for commit 149c221. Bugbot is set up for automated code reviews on this repo. Configure here.

@changeset-bot

changeset-bot Bot commented Nov 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 149c221

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@cofhe/sdk Patch
@cofhe/abi Patch
@cofhe/hardhat-3-plugin Patch
@cofhe/hardhat-plugin Patch
@cofhe/mock-contracts Patch
@cofhe/react Patch
@cofhe/site Patch
@cofhe/example-react Patch
@cofhe/foundry-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

This branch has not been deployed

No deployments
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