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: address filter and chain config #112

Merged
merged 10 commits into from
Nov 20, 2023
Merged

chore: address filter and chain config #112

merged 10 commits into from
Nov 20, 2023

Conversation

mfw78
Copy link
Contributor

@mfw78 mfw78 commented Oct 15, 2023

Description

This PR tweaks some configuration options for easing deployment on dappnode.

Changes

  • rpc, deploymentBlock, watchdogTimeout, and orderBookApi collapsed down into chain-config
  • Added ChainConfig option parser
  • Added user-defined address filter (only process conditional orders from specific addresses)
  • Fixes a calculation issue with the watchdog

How to test

  1. Follow the readme instructions for quickly running
  2. Observe no errors

Related Issues

Fixes: #72

@mfw78 mfw78 added the E:1.2: Watch Tower Service https://github.com/cowprotocol/pm/issues/8 label Oct 15, 2023
@mfw78 mfw78 requested review from anxolin and a team October 15, 2023 05:54
@mfw78 mfw78 self-assigned this Oct 15, 2023
@mfw78 mfw78 linked an issue Oct 15, 2023 that may be closed by this pull request
4 tasks
src/index.ts Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
src/types/index.ts Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Base automatically changed from allow-set-your-own-orderbook to main October 18, 2023 05:14
@mfw78 mfw78 force-pushed the config-address-filter branch from 989b24f to 7766934 Compare October 18, 2023 05:19
src/types/index.ts Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
@@ -33,14 +33,22 @@ As an example, to run the latest version of the watch-tower via `docker`:
docker run --rm -it \
ghcr.io/cowprotocol/watch-tower:latest \
run \
--rpc <rpc-url> \
--deployment-block <deployment-block> \
--chain-config <rpc>,<deployment-block> \
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure this is a good change. It just couple the RPC and block

I still think the block should be independent and should have a default with the deployment block of the contracts.

Then users can override.

Although probably im missing the why this was necesarry, i guess has to do that in dappnode it was not simple to specify the params?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In either which case, then the deployment block in that case would be optional in the chain-config tuple. Agreed that eventually just publish a composable-cow NPM package that packages up all this info, that can then be re-exported by the cow-sdk. I don't think this is a high priority at the moment and would be better served when iterative work is done on the composable-cow repo with any new order types / interface revision. cowprotocol/composable-cow#60 was created to specifically track this.

The reason to merge them together is to support multi-chain monitoring on DAppNode. Contrary to how the watch-tower is deployed on CoW infra in Kubernetes (where spinning up different deployments is trivial), writing a DAppNode package requires the exact number of containers to be specified for the docker-compose. Once the package is published, the number of containers is not configurable / changeable. So one cannot dynamically select which networks they want to run, and have DAppNode add / remove containers from the docker-compose stack.

Alternatives to this include:

  1. Expand the configuration options to allow for specific chains such as --mainnet-rpc etc.
  2. Create a separate DAppNode package per chain.

Neither of the above alternatives are a maintainable solution. Both cause maintenance issues if new networks are added, and (2) incurs 3x the costs (each time a package is published to the DAppNode registry, it costs a transaction on Ethereum Mainnet).

Copy link
Contributor

@anxolin anxolin Oct 19, 2023

Choose a reason for hiding this comment

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

Expand the configuration options to allow for specific chains such as --mainnet-rpc etc.

This seems nicer, at least keeps the independence of the fields. Its possible that you will keep adding more fields of config per network, and i feel is a red flag to add them as comma separated list

what about, for multi-netork support we add:

First the list of networks:

# Either
---network 1 \
---network 2 \
---network 3 \

Or, a bit less nice
---network 1,2.3

Then the params per network

-- rpc-1 RPC1 \
-- rpc-2 RPC2 \
-- rpc-3 RPC3

# or using the name
-- rpc-mainnet RPC1 \
-- rpc-gc RPC2 \
-- rpc-goerli RPC3

This way, adding new params per network feels more natural.

Imaine if we keep this change, and then we add another parameter.
then we will have --chain-config 1,123456,false,asdfg,

If some are mandatory, and some are not, this will be even more painful.

Copy link
Contributor Author

@mfw78 mfw78 Oct 19, 2023

Choose a reason for hiding this comment

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

Having relationships between fields like this is a bit of a nightmare, and IMO is a great reason for a tuple. It's smelly, but I think there may be a more idiomatic way to do this. Isn't this essentially what is communicated by a URL? (ie. <protocol>://<domain>:<port>/<location>).

So, in which case, I think I may actually prefer to use a URL with optional query parameters to indicate fields that are optional. Something like:

<rpc>/<deploymentBlock>?watchdogTimeout=30&orderBookApiUrl=urlencodedField

For example, in DAppNode this would be:

http://erigon.dappnode:8545/17883049&watchdogTimeout=60&orderBookApiUrl=https%3A%2F%2Fapi.cow.fi%2Fmainnet

src/types/index.ts Show resolved Hide resolved
src/domain/checkForAndPlaceOrder.ts Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
@mfw78 mfw78 merged commit 4f91712 into main Nov 20, 2023
4 checks passed
@mfw78 mfw78 deleted the config-address-filter branch November 20, 2023 17:54
@github-actions github-actions bot locked and limited conversation to collaborators Nov 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
E:1.2: Watch Tower Service https://github.com/cowprotocol/pm/issues/8
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: dappnode package
3 participants