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

[Proxy colonies] Feat: create proxy chain block ingestor #298

Open
wants to merge 1 commit into
base: feat/proxy-colonies-dev-env
Choose a base branch
from

Conversation

bassgeta
Copy link
Contributor

@bassgeta bassgeta commented Dec 2, 2024

This PR adds the proxy block ingestor pnpm app into the workspace that will be responsible for processing the proxy colonies related events.

CDapp PR

This is basically reinventing NestJS at this point 😅
The line changes seem absolutely severe, but it's a lot of just moving existing code around, but turning it into classes, and imports, so it's a chonker but not that bad!

We had instances of everything done functional before, which worked fine for a single ingestor, but once we started working on the second one, we quickly realized that we're gonna need dependency injection.
For example, eventListener just added handlers to an array, but in order to use it in two apps, we needed to pull it out into a separate package, then instantiate it on each app separately.
The blockListener previously just directly used the running eventListener instance. Now the blockListener has been turned into a reusable class called BlockManager which relies on a renamed eventListener: eventManager. How to solve all of this?
Create the BlockManager with an instance of eventManager, so we can have different instances of BlockManager which all just receive eventManager instances from each app.
This way, each app just creates its own eventManager and then the BlockManager with its instance of eventManager. Then the BlockManager won't care about app proprietary logic, it will just call functions on that instance, getting back data specific to the app it's running in!

Changes

  • Dockerfile stuff to make proxy ingestors buildable
  • decoupled amplifyClient, networkClient and rpcProvider into reusable classes we use across both apps
  • decoupled the blockListener and blockProcessor into a new entity called BlockManager which does the same things as the two before, additionaly it does event matching (so it's easier to call that)
  • decoupled the eventListener into a new class, so we can share instances of it across a running chain
  • decoupled stats too (there's duplication for the stats server, but that's alright for now because the proxy ingestor requires a really basic setup)
  • realigned all imports 🫠
  • realigned some codesnips like using amplifyClient.mutate instead of just mutate

@bassgeta bassgeta force-pushed the feat/proxy-block-ingestors branch from ed068d4 to 93c4514 Compare December 3, 2024 08:09
@bassgeta bassgeta force-pushed the feat/proxy-chain-ingestor branch from 7b0f8f8 to 796783e Compare December 3, 2024 10:51
@mmioana mmioana force-pushed the feat/proxy-chain-ingestor branch 3 times, most recently from ebb05be to d186e90 Compare December 5, 2024 09:07
@mmioana mmioana force-pushed the feat/proxy-chain-ingestor branch from 4b8b18a to 14a9426 Compare December 10, 2024 08:08
Feat: Create proxy chain app, add Docker config and refactoring
@mmioana mmioana force-pushed the feat/proxy-chain-ingestor branch from 14a9426 to d5c077a Compare December 10, 2024 08:19
@mmioana mmioana changed the title [Proxy colonies] feat: create proxy chain block ingestor [Proxy colonies] Feat: create proxy chain block ingestor Dec 10, 2024
@bassgeta bassgeta marked this pull request as ready for review December 11, 2024 12:22
Copy link
Contributor

@iamsamgibbs iamsamgibbs left a comment

Choose a reason for hiding this comment

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

Great job on this! Reviewed alongside the CDapp counterpart.

@@ -50,8 +50,9 @@ export default async (event: ContractEvent): Promise<void> => {
/*
* Add it to the Set
*/
// @NOTE seems to not be working, is it borken on master too?
Copy link
Contributor

Choose a reason for hiding this comment

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

Seemed to work okay for me!

Before creating a new colony (tracked colonies 2)

Screenshot 2024-12-11 at 17 07 46

After (tracked colonies 3!)

Screenshot 2024-12-11 at 17 09 33

Base automatically changed from feat/proxy-block-ingestors to feat/proxy-colonies-dev-env December 12, 2024 09:32
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