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: Creating a unified mechanism to generate blocklists for ckBTC and ckETH #3401

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

THLO
Copy link
Contributor

@THLO THLO commented Jan 10, 2025

This PR adds a Python script to generate blocklists for ckBTC and ckETH based on the OFAC SDN list.

There are some differences in the produced blocklist files compared to the current files:

Differences to the current ckBTC blocklist file:

  1. The new blocklist file has a comment at the beginning about the script that was used to generate it.
  2. The new blocklist file has a more concise error message for the invalid Bitcoin address in the OFAC SDN list.

Differences to the current ckETH blocklist file:

  1. The new blocklist file has a comment at the beginning about the script that was used to generate it, replacing the old comment.
  2. Since Ethereum addresses are case-insensitive, all addresses are now consistently in lower case.
  3. The parameter from_address in the function is_blocked has been changed to address to make it consistent with the corresponding function for ckBTC.

Corresponding ticket: https://dfinity.atlassian.net/browse/XC-250

@THLO THLO requested a review from a team as a code owner January 10, 2025 14:22
@github-actions github-actions bot added the chore label Jan 10, 2025
Copy link
Member

@gregorydemay gregorydemay left a comment

Choose a reason for hiding this comment

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

Thanks a lot @THLO for making this script! Some minor comments and python newbie questions.

rs/cross-chain/scripts/generate_blocklist.py Outdated Show resolved Hide resolved
rs/cross-chain/scripts/generate_blocklist.py Show resolved Hide resolved
rs/cross-chain/scripts/generate_blocklist.py Outdated Show resolved Hide resolved
rs/cross-chain/scripts/generate_blocklist.py Outdated Show resolved Hide resolved
rs/cross-chain/scripts/generate_blocklist.py Outdated Show resolved Hide resolved
rs/cross-chain/scripts/generate_blocklist.py Outdated Show resolved Hide resolved
rs/cross-chain/scripts/generate_blocklist.py Outdated Show resolved Hide resolved
# Remove duplicates.
addresses = list(set(addresses))
# Sort the addresses.
addresses.sort()
Copy link
Member

Choose a reason for hiding this comment

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

There is a problem with the sorting for ETH addresses. To reproduce:

  1. Update ETH blocklist
    python rs/cross-chain/scripts/generate_blocklist.py ETH ./SDN.XML rs/ethereum/cketh/minter/src/blocklist.rs
    
  2. Run the unit tests
    bazel test //rs/ethereum/cketh/minter:lib_tests
    

The test check_blocklist_is_sorted fails. This is because the sorting of the ETH blocklist is based on the 20-bytes corresponding to an address and not on its textual representation so we probably need here a different sorting algorithm for the EthereumBlocklistHandler that first does hex decoding of its elements before sorting.

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

Successfully merging this pull request may close these issues.

4 participants