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

Feature/graphman test run #3079

Merged
merged 6 commits into from
Jan 14, 2022

Conversation

sduchesneau
Copy link
Contributor

@sduchesneau sduchesneau commented Dec 17, 2021

graphman test-run

  • add graphman test-run command (implements stop-block mechanism to stop when the subgraph's end block is reached)

(github implementation pushed to next PR)

@sduchesneau
Copy link
Contributor Author

Requires some discussion about how the comparison tests should be run. Maybe they could be hooked to releases (not build graphman in the action to make it faster), maybe they could be in a different repository, maybe they could start a bigger matrix of runs, in parallel.

@maoueh maoueh marked this pull request as draft December 17, 2021 03:55
@sduchesneau sduchesneau force-pushed the feature/graphman-test-run branch from cc0a767 to e21a011 Compare December 20, 2021 20:45
maoueh added a commit that referenced this pull request Dec 20, 2021
This PR is a first step in merging #3079. In this upcoming, we had copied a bunch of methods from `main.rs`, mainly those around instantiating elements to connect to chains and prepare them.

In this PR, we moved
- `create_ipfs_clients`
- `create_ethereum_networks` (formely `create_networks`)
- `create_firehose_networks`
- `connect_ethereum_networks`
- `connect_firehose_networks`

To a common module `chain` under `graph-node` crate.

There is no functionality changed in this PR, only moving code around. Small differences are the renamed of `create_networks` and its `config` argument that is now received as a reference to `Config` (instead of a owned `Config`).
maoueh pushed a commit that referenced this pull request Dec 22, 2021
* graph-node: factorize some methods inside a shared component

This PR is a first step in merging #3079. In this upcoming, we had copied a bunch of methods from `main.rs`, mainly those around instantiating elements to connect to chains and prepare them.

In this PR, we moved
- `create_ipfs_clients`
- `create_ethereum_networks` (formely `create_networks`)
- `create_firehose_networks`
- `connect_ethereum_networks`
- `connect_firehose_networks`

To a common module `chain` under `graph-node` crate.

There is no functionality changed in this PR, only moving code around. Small differences are the renamed of `create_networks` and its `config` argument that is now received as a reference to `Config` (instead of a owned `Config`).
@maoueh maoueh force-pushed the feature/graphman-test-run branch from 8de8594 to 56b602f Compare December 22, 2021 04:09
@maoueh maoueh changed the title Feature/graphman test run (IN PROGRESS) Feature/graphman test run Dec 22, 2021
kamilkisiela pushed a commit that referenced this pull request Jan 5, 2022
* graph-node: factorize some methods inside a shared component

This PR is a first step in merging #3079. In this upcoming, we had copied a bunch of methods from `main.rs`, mainly those around instantiating elements to connect to chains and prepare them.

In this PR, we moved
- `create_ipfs_clients`
- `create_ethereum_networks` (formely `create_networks`)
- `create_firehose_networks`
- `connect_ethereum_networks`
- `connect_firehose_networks`

To a common module `chain` under `graph-node` crate.

There is no functionality changed in this PR, only moving code around. Small differences are the renamed of `create_networks` and its `config` argument that is now received as a reference to `Config` (instead of a owned `Config`).
@maoueh maoueh marked this pull request as ready for review January 6, 2022 17:15
@sduchesneau sduchesneau force-pushed the feature/graphman-test-run branch from b6640dc to 2a1b0c4 Compare January 10, 2022 13:28
@sduchesneau
Copy link
Contributor Author

@mangas ^ I've just removed the Github Actions part of this PR (by force-pushing rebased version over my feature-branch)
This here is only the implementation of graphman 'test-run' command, allowing the following:

bin/graphman --config eth-mainnet-firehose.toml test-run eth-mainnet {IPFS_HASH} {STOP_BLOCK}

@@ -582,6 +605,30 @@ async fn main() {
sleep,
)
}
TestRun {
Copy link
Contributor

Choose a reason for hiding this comment

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

Any objection to calling this Run and having stop block as an optional flag?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just see the possible confusion about the purpose of this (the purpose is to do a test run, no to run production on this! it does not work in parallel with a graph-node writing on the same database, etc.)
@maoueh ?

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 with @mangas, graphman run feels better.

About your concerns @sduchesneau , graphman is a tool that is deemed for "management of graph-node" instances, so I don't think it will be confused as production means to run a graph node.

@lutter What do you think about this, do you think there could be some confusions if we use graphman run?

Copy link
Collaborator

@leoyvens leoyvens Jan 10, 2022

Choose a reason for hiding this comment

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

I'm +1 on run, but we can keep the stop block as a required flag if that's how it's meant to be used

Copy link
Collaborator

Choose a reason for hiding this comment

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

I am also +1 on run - I think we should just say in the help message that this is for test purposes only. Another option would be to call this exec which to me already sounds a bit more dangerous than run

@mangas mangas requested a review from leoyvens January 10, 2022 14:40
@mangas
Copy link
Contributor

mangas commented Jan 10, 2022

Adding @leoyvens for review as well as I don't really trust my reviews yet 😄

Matthieu Vachon and others added 5 commits January 10, 2022 16:25
…r on

- Copied a bunch of stuff that can be shared with `main.rs`
- Can refactor even more `main.rs` to be shared with stuff made for `test-run`
- Implement some form of stop mechanism (block_count, stop block, time based, etc)
@maoueh maoueh force-pushed the feature/graphman-test-run branch from 3b93149 to 3c247c1 Compare January 10, 2022 21:26
}
_ => {}
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems a little weird that we stop after getting the block but before processing it - that way, the last block we'll actually process (and have entities for) will be stop_block - 1. It's probably fine, but will need to be documented in graphman run

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The instance manager stops after seeing (and before processing) the block HIGHER THAN the stop block:
if block_ptr.number > stop_block

So the behavior is to process up to stop_block INCLUSIVE, as you would expect (well, it Works on My Machine ™️)

subgraph: String,

/// Number of block to process
stop_block: i32,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This needs to say that the latest entities we'll have in the database will be for stop_block - 1.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not needed if my previous claim is right 😃

@@ -582,6 +605,30 @@ async fn main() {
sleep,
)
}
TestRun {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am also +1 on run - I think we should just say in the help message that this is for test purposes only. Another option would be to call this exec which to me already sounds a bit more dangerous than run

@@ -411,6 +434,10 @@ impl Context {
pools
}

async fn store_builder(self) -> StoreBuilder {
StoreBuilder::new(&self.logger, &self.node_id, &self.config, self.registry).await
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Heh .. the whole point of this Context struct was so that we wouldn't have to pass the StoreBuilder around because that obscures what exactly a command might be doing with the store. It would be better to add a utility method to the Context that returns the NetworkStore, the primary pool, and the chain head listener and pass those into commands::run

Also, StoreBuilder::new will run migrations - avoiding that is a big reason why there are all these other methods on StoreBuilder so that using the wrong graphman version won't screw up the database schema.

I would change this method to call Self::store_and_primary and then copy the few lines that create a ChainHeadUpdateListener from StoreBuilder::new to here

Copy link
Contributor

Choose a reason for hiding this comment

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

We changed it exactly to be able to run ... migrations :D I notice the differences indeed. Migrations was required first for CI since it always starts fresh but it's also quite good when using it for development purposes as I often starts from a fresh database.

The best will be to discuss that over a video chat to see what you be the best course of action here. Two things come to mind:

  • Run only on pristine database
  • Run only when specific flag is provided

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lutter Need to chat more about this, indeed, we are using this command mostly on a completely empty database (in dev/test flow), so we need all the migrations bells and whistles...

kamilkisiela pushed a commit that referenced this pull request Jan 12, 2022
* graph-node: factorize some methods inside a shared component

This PR is a first step in merging #3079. In this upcoming, we had copied a bunch of methods from `main.rs`, mainly those around instantiating elements to connect to chains and prepare them.

In this PR, we moved
- `create_ipfs_clients`
- `create_ethereum_networks` (formely `create_networks`)
- `create_firehose_networks`
- `connect_ethereum_networks`
- `connect_firehose_networks`

To a common module `chain` under `graph-node` crate.

There is no functionality changed in this PR, only moving code around. Small differences are the renamed of `create_networks` and its `config` argument that is now received as a reference to `Config` (instead of a owned `Config`).
@mangas mangas merged commit 2f8bc1d into graphprotocol:master Jan 14, 2022
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.

5 participants