-
Notifications
You must be signed in to change notification settings - Fork 32
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
Add Sanction List #30
Conversation
It takes around 35s to update fetch the latest OFAC list and extract all addresses from XML to the in memory hashmap. The logic runs in a separate non-blocking thread so it should not cause any issues. Also, they update the list every few days so it's gonna run that often |
I believe we should start this thread when we run the orchestrator. It should wait for the fist sync of the OFAC list before it starts |
BTW let me know when this is ready for review (looks like CI doesn't pass atm) |
Fixed the lint issues. You can review this :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is amazing :) thanks so much again for these PRs!
One thing that'd be great to have is a test just to easily see what the sanction list is, how big it is, and how much time it takes to sync
} | ||
} | ||
|
||
/// Handles bob request from A to Z. | ||
pub async fn handle_request(&self, bob_request: &BobRequest) -> Result<BobResponse> { | ||
// Validate transaction before forwarding it, and get smart contract | ||
bob_request | ||
.check_compliance(Arc::clone(&self.compliance)) | ||
.await?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wondering: should individual nodes perform that check as well? What would be the rational for not performing that check at the node level (and would node be liable if something bad happens there...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could, but we've got orchestrator as a centralized entity that coordinates the entire process.
} | ||
|
||
impl Compliance { | ||
const BTC_ID: &'static str = "344"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you document where you got that value from? (if it's possible)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I couldn't find any documentation. This is a gov document, didn't expect anything better to be honest. I had to look into the XML file and find that number.
let last_update = Arc::clone(&self.last_update); | ||
|
||
spawn(async move { | ||
let mut interval = interval(Duration::from_secs(600)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should hardcode that value somewhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes I will do that
); | ||
|
||
// Sync sanction list in a parallel thread | ||
compliance.start(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't you have to use the joinhandle returned?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not if you don't want to wait for it to complete
I've added a comment regarding this. It's an XML file and is 92MB big. |
Add sanction list based to the discussion here #5.
The logic goes like this:
is_sanctioned
method that returns true if the address is in the sanction list.