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

feat: add L1 indexer to fetch contract logs for the bridge #291

Open
wants to merge 61 commits into
base: main
Choose a base branch
from

Conversation

helciofranco
Copy link
Member

@helciofranco helciofranco commented Apr 4, 2024

Add L1 indexer, it'll sync contract events logs from a given start block number.
After that, it'll keep watching the blockchain for new logs and blocks.

New env vars have been added to the graphql:

  • FUEL_CHAIN_NAME (example fuelBeta5)
  • ETH_CHAIN_NAME (example sepolia)
  • ETH_ALCHEMY_ID (your alchemy key)
  • ETH_INFURA_ID (your infura key – used as fallback to alchemy)
  • ETH_INITIAL_BLOCK (block number that got our contracts)

📷 Indexer demo

pnpm sync:bridge
Screen.Recording.2024-04-04.at.18.04.24.mov

💾 API demo

Query Result
Screenshot 2024-04-04 at 18 01 16 Screenshot 2024-04-04 at 18 01 27

@@ -50,4 +50,4 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
image: ghcr.io/fuellabs/fuel-explorer
dockerfile: deployment/Dockerfile.v2
context: ./packages/graphql-new
context: .
Copy link
Member

Choose a reason for hiding this comment

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

We should not change the root dir here; this makes the image publish all the code from the repo instead of only the graphql package, drastically increasing the image size.

Copy link
Member Author

Choose a reason for hiding this comment

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

@luizstacio indeed :(

I'll need to figure out how to get rid of this – let me find a time to check that today.

I've added this because graphql-new package has a peer dependency on the @fuel-explorer/contract-ids.
(Outside that context)

Does that make sense?

Comment on lines +31 to +37
// Sync the logs
try {
await this.watchLogs();
} catch (e) {
console.error(e);
throw new Error('Failed to watch logs');
}
Copy link
Member

Choose a reason for hiding this comment

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

How watchLogs work? If the socket is closed as example by the server it autoReconnects?

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.

Implement Indexer on the bridge
3 participants