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

fix: use keccak chain ID #62

Merged
merged 4 commits into from
Oct 16, 2024
Merged

fix: use keccak chain ID #62

merged 4 commits into from
Oct 16, 2024

Conversation

0xyaco
Copy link
Collaborator

@0xyaco 0xyaco commented Oct 14, 2024

🤖 Linear

Closes GRT-212, GRT-89

Description

  • On-chain contracts are storing chain IDs as their respective keccak256 hashes (not raw chain ID strings). Whenever reading the RequestCreated event that comes with the chain ID hash, we need to find which no-hashed chain ID is the correct one by comparing all chain ID hashes with the one received via event.
  • Moved Caip2 related functionality to shared package

Copy link

linear bot commented Oct 14, 2024

Comment on lines 58 to 65
public static findByHash(
hashedChainId: Hex,
chainIds: Caip2ChainId[],
): Caip2ChainId | undefined {
return chainIds.find(
(id) => keccak256(toHex(id)).toLowerCase() === hashedChainId.toLowerCase(),
);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

it's not a general solution, but since you use the constant EBO_SUPPORTED_CHAIN_IDS, isn't it possible to have a map (hash => Caip2ChainId) ? it's more efficient

@0xyaco 0xyaco requested a review from 0xnigir1 October 14, 2024 18:37
@@ -1,6 +1,7 @@
import { EboActorsManager, EboProcessor, ProtocolProvider } from "@ebo-agent/automated-dispute";
import { BlockNumberService, Caip2ChainId } from "@ebo-agent/blocknumber";
import { Logger } from "@ebo-agent/shared";
import { DiscordNotifier } from "@ebo-agent/automated-dispute/dist/services/discordNotifier.js";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you mean to import from dist?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nice catch!

@0xyaco 0xyaco requested a review from jahabeebs October 15, 2024 09:12
@0xyaco 0xyaco merged commit b6d55eb into dev Oct 16, 2024
5 checks passed
@0xyaco 0xyaco deleted the fix/use-keccak-chain-id branch October 16, 2024 10:10
Copy link

linear bot commented Oct 28, 2024

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