-
Notifications
You must be signed in to change notification settings - Fork 1
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: apply filtering policy #116
Conversation
New dependencies detected. Learn more about Socket for GitHub ↗︎
|
c0e5881
to
e1ae9ce
Compare
b9f3c6c
to
4a1e087
Compare
Just approved, can't reason about these changes |
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.
Is there any reason why this is limited to being applied to run-multi
, and hasn't been implemented for the run
subcommand case?
const action = | ||
owners.get(owner) || handlers.get(conditionalOrderParams.handler); |
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.
As a suggestion, are we sure we want to consider the individual owner case first? This may open up attacks if there's a public list with an owner explicitly whitelisted, in which case, one can create a bad handler and target that owner address with fake events being emitted.
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.
For now don't make sense, as the default is to ACCEPT. It makes sense if we allow to change the default to DROP or SKIP (by the way, good feature and easy to add)
However, if we change it in the future, we might not remember this, so changing it just in case.
The |
Description
This PR implements a basic filtering policy for Programmable Orders.
Configuration
You can define your own policy by defining your own file with the rules.
The format allows you to SKIP or DROP orders who match some criteria:
Initial config
The initial config lives now in:
https://github.com/cowprotocol/watch-tower/blob/config
There there's one file per network.
This branch is just temporal. The plan is to have the config done in https://github.com/cowprotocol/watch-tower-config which is a private repository, but it was remove from the scope of this PR.
Filter Policy
In charge of the filtering. For now, I added only
pre-filters
but i could have postfilters in the future.Also the rules are pretty simplistic, but future versions of the config could really have more advance filtering.
It can filter by
owner
andhandler
.Workflow
ACCEPT
: Will let the order be processed (normal flow)SKIP
: Will skip the order. Next block, we will decide again based on the configuration by the time is processed, if it's stillSKIP
will keep not processing the order.DROP
: Will skip the order for this run and any future blocks.Params for the CLI
The filtering is OPTIONAL, so by default no filtering will be done.
EDIT: Removed the config param, now it uses the
--chain-config
(new way after the merge of #112)You can pass optionally the URL of the configuration you want to use, for example:
--filterPolicyConfig https://raw.githubusercontent.com/cowprotocol/watch-tower/config/filter-policy-100.json
You can specify the config as the 5th argument in
--chain-config
argumentIt also works for the multi-network run.
Test
config
branch:LOG_LEVEL=DEBUG,checkForAndPlaceOrder=DEBUG yarn ts-node ./src/index.ts run --rpc <rpc> --deployment-block 29389123 --page-size 5000 --filterPolicyConfig https://raw.githubusercontent.com/cowprotocol/watch-tower/config/filter-policy-100.json
Out of scope
Add auth for the HTTPS request of the config file