Skip to content

Block malicous users #1434

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

Merged
merged 7 commits into from
Oct 14, 2019
Merged

Block malicous users #1434

merged 7 commits into from
Oct 14, 2019

Conversation

HoOngEe
Copy link
Contributor

@HoOngEe HoOngEe commented Apr 2, 2019

It closes #1414

@HoOngEe HoOngEe changed the title [WIP] Ban accounts [WIP] Block malicous users Apr 3, 2019
@HoOngEe HoOngEe changed the title [WIP] Block malicous users Block malicous users Apr 3, 2019
@sgkim126
Copy link
Contributor

sgkim126 commented Apr 5, 2019

And what about the RPCs?

@HoOngEe
Copy link
Contributor Author

HoOngEe commented Apr 9, 2019

I Implemented five RPCs requested in the issue#1414 with the name
account_getBannedAccounts, account_unbanAccounts, account_banAccounts, account_getImmuneAccounts, account_registerImmuneAccounts

@sgkim126
Copy link
Contributor

Why do you implement them on the account while I designed it on the mempool?

@HoOngEe
Copy link
Contributor Author

HoOngEe commented Apr 11, 2019

I changed wrongly implemented account RPCs to intended mempool RPCs.

@sgkim126
Copy link
Contributor

@HoOngEe Please give a reason if your implementation is different from the spec.

@HoOngEe
Copy link
Contributor Author

HoOngEe commented Apr 15, 2019

I renamed the mempool_registerAccounts to mempool_registerImmuneAccounts and mempool_getAccounts to mempool_getImmuneAccounts.I think it helps understanding because the purpose of registering accounts here is to make some accounts immune to banning so that the transactions from those accounts would never be rejected by the reason they are malicious users.

@HoOngEe HoOngEe requested a review from ScarletBlue April 16, 2019 06:11
@sgkim126 sgkim126 added the do-not-merge Do not merge (for mergify.io) label Apr 16, 2019
@sgkim126
Copy link
Contributor

LGTM. But let me merge it after the next release.

sgkim126
sgkim126 previously approved these changes Apr 17, 2019
@HoOngEe HoOngEe force-pushed the ban-accounts branch 4 times, most recently from b969477 to 5565f6b Compare October 1, 2019 09:34
@HoOngEe HoOngEe requested review from foriequal0 and majecty October 1, 2019 09:35
.read()
.is_local_transaction(hash)
.expect("The tx is clearly fetched from the mem pool") => {}
_ => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Other errors are safe to ban the error creators?
And what can we do to reduce some bugs when we add a new RuntimeError?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently I cannot sure that the left runtime errors are considered as malicious behaviors. It's better to use the blacklist method when some errors are problematic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I picked the two problematic runtime errors RuntimeError::AssetSupplyOverflow and RuntimeError::InvalidScript and blacklisted them.

Copy link
Contributor

Choose a reason for hiding this comment

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

@foriequal0 @sgkim126 What do you think about judging a malicious user only if the user's transaction failed with the blacklisted error?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it can be fixed later.

self.importer.miner.register_immune_users(immune_user_vec)
}

fn get_network_id(&self) -> NetworkId {
Copy link
Contributor

Choose a reason for hiding this comment

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

Network id can be retrieved with EngineInfo::common_params(Latest)?.network_id()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Modified.

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant that get_network_id() is unnecessary.

self.importer.miner.get_malicious_users()
}

fn release_trusty_users(&self, trusty_vec: Vec<Address>) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The objective trusty user is not matching with the malicious user.
It is actually a method that releases a malicious user before.
And it doesn't match with the RPC method name unban_accounts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed the name of release_trusty_users to release_malicious_users. For internal function names, I used "imprison" and "release" in a pair unlike the rpc name "ban" and "unban". Hence, I kept the verb "release" here. Is it better to unify the rpc name and the name of the internally called function?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think unifying it would be better.

@HoOngEe HoOngEe force-pushed the ban-accounts branch 2 times, most recently from b8e9911 to e50b9ed Compare October 4, 2019 07:00
@HoOngEe
Copy link
Contributor Author

HoOngEe commented Oct 10, 2019

I judged the two runtime errors RuntimeError::AssetSupplyOverflow and RuntimeError::InvalidScrip as malicious ones and blacklisted them.

@HoOngEe HoOngEe requested review from foriequal0 and majecty October 10, 2019 05:00
@HoOngEe HoOngEe merged commit 3d2afd7 into CodeChain-io:master Oct 14, 2019
@HoOngEe HoOngEe deleted the ban-accounts branch October 14, 2019 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge Do not merge (for mergify.io) mempool
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make the mempool block accounts who send many invalid transactions
4 participants