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

feat: add ism limit #5567

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

feat: add ism limit #5567

wants to merge 19 commits into from

Conversation

kamiyaa
Copy link
Collaborator

@kamiyaa kamiyaa commented Feb 26, 2025

Description

Add an total ISM limit. This works in addition to the ISM max depth.
If either is reached, we won't build the metadata and drop the message.

  • combined Metadata with MetadataBuildError
    • This fixes an issue where the incorrect error is returned when using AggregationIsm + max ism count error occurs
      • instead of returning MaxIsmCount error, it returns CouldNotFetch
    • This also simplifies error handling and makes it easier for us to respond to errors (see here)
    • This can probably be further simplified to just Result<Vec<u8>, MetadataBuildError> but would require a lot of code changes
// old
pub enum MetadataBuildError {
    UnsupportedModuleType(ModuleType),
    MaxDepthExceeded(u32),
}

pub enum Metadata {
    Found(Vec<u8>),
    CouldNotFetch,
    Refused(String),
}

// new
pub enum MetadataBuildError {
    Refused(String),
    CouldNotFetch,
    UnsupportedModuleType(ModuleType),
    MaxDepthExceeded(u32),
    MaxIsmCountReached(u32),
}

pub enum Metadata {
    Found(Vec<u8>),
    Failed(MetadataBuildError),
}
  • moved previous recursive logic into function: build_message_metadata

    • I wanted to move more of the logic out of the builders and just have functions, but it was harder than I thought. So I just have the recursive function building the Builders.
  • created a new trait BaseMetadataBuilderTrait for BaseMetadataBuilder

    • This way we can create a Mock version for testing
  • Add MockBaseMetadataBuilder, MockInterchainSecurityModule, MockRoutingIsm

    • essentially just a queue of responses we can populate to get the response we want, so we can test logic easier
    • Not sure if mockall has an easy way to do this, but I didn't really look into it

Drive-by changes

  • moved some code into separate files. I find it easier to read multiple files than reading a single long file 👀

Related issues

https://github.com/hyperlane-xyz/issues/issues/1424

Backward compatibility

  • the new error handling might cause different behaviour for errors
    • In the case of UnsupportedModuleType, MaxIsmDepth, MaxIsmCount, we want to reprepare instead of just dropping these messages

Testing

Unit tests

  • depth already reached
  • ism count already reached
  • max depth exceeded
  • max ism count exceeded
  • max ism count exceeded with aggregation ism

Copy link

changeset-bot bot commented Feb 26, 2025

⚠️ No Changeset found

Latest commit: 0fbc467

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 Feb 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.53%. Comparing base (ca96d08) to head (0fbc467).
Report is 8 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5567   +/-   ##
=======================================
  Coverage   77.53%   77.53%           
=======================================
  Files         103      103           
  Lines        2110     2110           
  Branches      190      190           
=======================================
  Hits         1636     1636           
  Misses        453      453           
  Partials       21       21           
Components Coverage Δ
core 87.80% <ø> (ø)
hooks 79.39% <ø> (ø)
isms 83.68% <ø> (ø)
token 91.27% <ø> (ø)
middlewares 79.80% <ø> (ø)
🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kamiyaa kamiyaa force-pushed the jeff/ism-limit-2 branch from c40692e to 5659324 Compare March 4, 2025 21:20
@kamiyaa kamiyaa force-pushed the jeff/ism-limit-2 branch from 5659324 to e69213b Compare March 4, 2025 21:36
@kamiyaa kamiyaa force-pushed the jeff/ism-limit-2 branch from 20d5bb0 to 0fbc467 Compare March 6, 2025 20:17
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.

4 participants