Skip to content

Conversation

codinghistorian
Copy link
Contributor

@codinghistorian codinghistorian commented Sep 23, 2025

refactor(pool): apply checks-effects-interactions (CEI)
pool/transfer.gno: update internal balances before external SafeGRC20Transfer/SafeGRC20TransferFrom
pool/pool.gno: update balances before external transfers in collectProtocol
Rationale: clearer invariants and consistent ordering; easier to reason about
Behavior: no functional change intended

ci(tlin): support forked PRs
.github/workflows/tlin_check.yml: checkout PR head repo/ref with fetch-depth: 0
Resolves checkout issues when branch isn’t on the base repo

Validation
Compiles and formats cleanly (gno fmt)
All CI checks passed for this PR

Reorder internal state updates before cross-contract calls in:
- safeTransfer: update balances before SafeGRC20Transfer
- safeTransferFrom: update balances before SafeGRC20TransferFrom
- collectProtocol: update balances before token transfers

Applies checks-effects-interactions pattern for better security practices.
Use actions/checkout with PR head repo/ref and fetch-depth: 0
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
Fixes checkout failure when the branch doesn’t exist in the base repo (forked PRs)
No behavior changes to the job; improves CI reliability for external contributors
@codinghistorian codinghistorian changed the title refactor: reorder pool transfers to follow CEI pattern security(pool): apply CEI pattern to transfers; ci: make tlin_check fork-safe Sep 23, 2025
@codinghistorian codinghistorian changed the title security(pool): apply CEI pattern to transfers; ci: make tlin_check fork-safe refactor(pool): apply CEI ordering for transfers; ci: fork-safe tlin_check Sep 23, 2025
@codinghistorian
Copy link
Contributor Author

codinghistorian commented Sep 29, 2025

I tagged refactor to not sound alarming but it's actually a security best practice for smart contract.

https://www.nethermind.io/blog/best-practices-for-writing-secure-smart-contract-code

@notJoon @jinoosss @dongwon8247

Copy link
Member

@notJoon notJoon left a comment

Choose a reason for hiding this comment

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

LGTM 👍 This pattern definitely seems better for managing effects. I'll consider applying this pattern to key functions going forward. thanks for the fix and suggestion.

After meeting, we will merge this PR if possible

Copy link

Copy link
Member

@dongwon8247 dongwon8247 left a comment

Choose a reason for hiding this comment

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

Don't merge it

@codinghistorian
Copy link
Contributor Author

LGTM 👍 This pattern definitely seems better for managing effects. I'll consider applying this pattern to key functions going forward. thanks for the fix and suggestion.

After meeting, we will merge this PR if possible

Thanks for the review! I’m glad the CEI pattern is being considered — even if this PR doesn’t get merged, I’m happy it might help shape future improvements.

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.

3 participants