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

Indexers v2 #132

Merged
merged 37 commits into from
Nov 11, 2024
Merged

Indexers v2 #132

merged 37 commits into from
Nov 11, 2024

Conversation

marcus-snx
Copy link
Contributor

@marcus-snx marcus-snx commented Oct 23, 2024

The new Indexers service is a single image that can be used to created separate indexer containers for each network by generating the necessary subsquid config files and grabbing the ABIs of contracts (specified in networks.yaml) using the Synthetix Python SDK

To run with docker, $RPC_ENDPOINT and $NETWORK_NAME must be set.

TODO:

  • simplify ENTRYPOINT
  • add block ranges

@marcus-snx marcus-snx added the wip Work in progress label Oct 23, 2024
Comment on lines 90 to 91
print(f"Network '{network_name}' not found in {path}/network_config.yaml")
sys.exit(1)
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 using raise Exception("{message}") is a cleaner way to print and exit with code 1

RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt

ENTRYPOINT ["sh", "-c", "python3 main.py --network_name \"$NETWORK_NAME\" --rpc_endpoint \"$RPC_ENDPOINT\" && npm run generate:processor && npm run build && (npm run generate:migration || true) && npm run start"]
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we can simplify this entrypoint, potentially just make a shell script that calls this stuff in order. It would simplify the docker compose commands if we can just call a script with configurations

package: perpsFactory
- name: buyback_snx
package: buyback_snx
contracts_from_abi:
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of doing these separately, we can just include the address in the abi files similar to the cannon ones. This way we can consolidate to one format {'abi': {}, 'address': '0x...'}.

@@ -0,0 +1,9 @@
arbitrum_mainnet:
archive_url: "https://v2.archive.subsquid.io/network/arbitrum-one"
contracts:
Copy link
Contributor

Choose a reason for hiding this comment

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

This format is different from the base one

Comment on lines 120 to 121
if name == "buyback_snx":
name = "BuybackSnx"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this? I know the contract is named something weird, but we don't want to handle that logic here.

Copy link
Contributor

Choose a reason for hiding this comment

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

@marcus-snx still need to fix this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah somehow I managed to discard this change. Thanks for the reminder!

indexers-v2/requirements.txt Outdated Show resolved Hide resolved
Comment on lines 8 to 9
logging.basicConfig(level=logging.INFO)

Copy link
Contributor

Choose a reason for hiding this comment

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

can simplify a bit by leaving this out, and using snx.logger.info

write_yaml(squidgen_config, "squidgen.yaml")

squid_config = create_squid_config(args.network_name)
write_yaml(squid_config, "squid.yaml")

print(
logging.info(
Copy link
Contributor

Choose a reason for hiding this comment

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

use snx.logger.info

indexers-v2/requirements.txt Outdated Show resolved Hide resolved
@marcus-snx marcus-snx removed the wip Work in progress label Nov 11, 2024
@marcus-snx
Copy link
Contributor Author

@Tburm I've removed some stuff that is only needed for postgres targeting since this service will be focusing on parquet. We can re-add that functionality at some later point if we need it again

@Tburm Tburm merged commit 9abc444 into main Nov 11, 2024
2 checks passed
@Tburm Tburm deleted the feat/indexers-v2 branch November 11, 2024 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants