Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: refactor MessagIdHook/ISM tests into a common ExternalBridgeTest contract #4490

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

aroralanuk
Copy link
Contributor

@aroralanuk aroralanuk commented Sep 16, 2024

Description

We currently have 6 different versions of ISMs derived from AbstractMessageIdAuthorizedIsm:

  • OPL2ToL1
  • ArbL2ToL1
  • OPStack (L1->L2)
  • ERC5164
  • LayerZero
  • PolygonPOS

But all of them have their own custom test suite right now, with widely overlapping testing areas. For standardizing the tests, I've created a base test contract ExternalBridgeTest that handles the common tests. This has a few benefits:

  • harder to miss tests for known pitfalls like msg.value or asynchronicity assumption for verifyMessageId
  • less code duplication with each additional Ism

I have moved OPL2ToL1, ArbL2ToL1, OPStack, and ERC5164 to the new base test, and I'll forgo the rest for now because of the time sensitivity of audit remediations. I've created an issue tracking the remaining work here: https://github.com/hyperlane-xyz/issues/issues/1384

Drive-by changes

None

Related issues

Related to https://github.com/chainlight-io/2024-08-hyperlane/issues/3

Backward compatibility

Yes

Testing

Unit

Copy link

changeset-bot bot commented Sep 16, 2024

⚠️ No Changeset found

Latest commit: fb66306

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link

codecov bot commented Sep 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.01%. Comparing base (291c5fe) to head (4d293ea).
Report is 18 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4490      +/-   ##
==========================================
+ Coverage   81.37%   82.01%   +0.63%     
==========================================
  Files         100      100              
  Lines        1412     1412              
  Branches      178      178              
==========================================
+ Hits         1149     1158       +9     
+ Misses        263      254       -9     
Components Coverage Δ
core 96.92% <ø> (ø)
hooks 85.23% <ø> (+2.85%) ⬆️
isms 93.80% <ø> (+1.32%) ⬆️
token 93.05% <ø> (ø)
middlewares 86.52% <ø> (ø)

@aroralanuk aroralanuk marked this pull request as ready for review September 17, 2024 15:20
@aroralanuk aroralanuk changed the title feat: refactor MessagIdHook/ISM tests into a common ExternalBridgeTest contract chore: refactor MessagIdHook/ISM tests into a common ExternalBridgeTest contract Sep 17, 2024
solidity/test/isms/ExternalBridgeTest.sol Show resolved Hide resolved
solidity/test/isms/ExternalBridgeTest.sol Outdated Show resolved Hide resolved
solidity/test/isms/ExternalBridgeTest.sol Outdated Show resolved Hide resolved
solidity/test/isms/ExternalBridgeTest.sol Outdated Show resolved Hide resolved
solidity/test/isms/ExternalBridgeTest.sol Outdated Show resolved Hide resolved
solidity/test/isms/ExternalBridgeTest.sol Outdated Show resolved Hide resolved
Comment on lines 194 to 197
// async call - native bridges might have try catch block to prevent revert
try
this.externalBridgeDestinationCallWrapper(externalCalldata, 0)
{} catch {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I dont understand this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

optimism has a try catch in their l2Messenger.relayMessage() so it doesn't revert.

solidity/test/isms/ExternalBridgeTest.sol Outdated Show resolved Hide resolved
solidity/test/isms/ExternalBridgeTest.sol Outdated Show resolved Hide resolved
);
}

// try catch block to prevent revert
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 not descriptive enough to be useful

Copy link
Contributor Author

Choose a reason for hiding this comment

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

add more detail here:

"wrapper function needed for _externalBridgeDestinationCall because try catch cannot call an internal function"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

2 participants