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

E2E: wallet, transaction and chain improvements #7875

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

Conversation

loocapro
Copy link
Contributor

@loocapro loocapro commented Apr 25, 2024

E2E improvements:

  • Wallet generator: Inspired from foundry, each wallet can create different type of transactions via the TransactionTestContext
  • TransactionTestContext: refactored naming and the way the transaction was built
  • TestNodeGenerator and TestNetworkBuilder abstractions: helpers to easily create nodes and perform actions on them (connecting)
  • ActionRunner: implement a Stream like the tokio stream mock to push an action, await it and check it

@loocapro loocapro changed the title feat: wallet and transaction improvements E2E: wallet,transaction and chain improvements Apr 25, 2024
@loocapro loocapro changed the title E2E: wallet,transaction and chain improvements E2E: wallet, transaction and chain improvements Apr 25, 2024
@mattsse mattsse requested a review from joshieDo April 25, 2024 13:48
@mattsse mattsse added the C-test A change that impacts how or what we test label Apr 25, 2024
@loocapro loocapro force-pushed the e2e-imp branch 2 times, most recently from da27471 to 14a7704 Compare April 25, 2024 15:18
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

okay, I can see how this will look like,

the ChainRunner and action trait need a bit more fine tuning wrt what's being stored etc.

the core logic should just be abstracted over the trait's types.

where the magic then comes in is with impls ov ChainRunner for certain Action/Ctx types, this is where we then can add sugar for things like FnOnce() -> Future etc

crates/e2e-test-utils/src/runner.rs Outdated Show resolved Hide resolved
crates/e2e-test-utils/src/runner.rs Outdated Show resolved Hide resolved
crates/e2e-test-utils/src/runner.rs Outdated Show resolved Hide resolved
crates/e2e-test-utils/src/runner.rs Outdated Show resolved Hide resolved
crates/e2e-test-utils/src/runner.rs Outdated Show resolved Hide resolved
@loocapro loocapro requested a review from mattsse April 30, 2024 17:40
@loocapro loocapro marked this pull request as ready for review May 2, 2024 14:49
@loocapro loocapro requested a review from joshieDo May 2, 2024 14:50
@joshieDo
Copy link
Collaborator

joshieDo commented May 2, 2024

looks real good overall!

i guess this can be an opinated topic, with no right or wrong way, so I'll just leave my opinion.

  • Scenarios should have as little boilerplate as possible. I want to be able to read it, without being "polluted" with boilerplate/setup code. If something is repeated in both optimism, and ethereum it should be moved to e2e-utils. If something is repeated across scenarios of the same node, then it should be abstracted away in the same node utils. That's why I had added setup & advance_many before. I've even thought about static functions for generation of nodes just so we don't do the ugly nodes.pop().

Things like this are being repeated over and over, in all scenarios across all nodes which in my opinion is unnecessary

(...)
    let tasks = TaskManager::current();
    let exec = tasks.executor();
(...)

I'd be curious on how you'd implement the scenario from 7552 PR which will (hopefully) be merged into main soon

@loocapro
Copy link
Contributor Author

loocapro commented May 3, 2024

looks real good overall!

Thank you, Josh, and I appreciate the time you’ve invested in the reviews—it's incredibly helpful!

i guess this can be an opinated topic, with no right or wrong way, so I'll just leave my opinion.

  • Scenarios should have as little boilerplate as possible. I want to be able to read it, without being "polluted" with boilerplate/setup code. If something is repeated in both optimism, and ethereum it should be moved to e2e-utils. If something is repeated across scenarios of the same node, then it should be abstracted away in the same node utils. That's why I had added setup & advance_many before. I've even thought about static functions for generation of nodes just so we don't do the ugly nodes.pop().

Things like this are being repeated over and over, in all scenarios across all nodes which in my opinion is unnecessary

(...)
    let tasks = TaskManager::current();
    let exec = tasks.executor();
(...)

Since the TaskManager manages the current tokio main task, it must remain in scope throughout the test; otherwise, if it gets dropped, the entire environment would be affected as well. Previously, we handled this with code like:

let (mut nodes, _tasks, _wallet) = setup(2).await?;

Here, we returned the _tasks and effectively ignored them. I also wasn’t keen on the implicit naming of the setup function, which, while avoiding code duplication, obscures the underlying operations with a generic name, leaving unclear what it specifically does.

So, I explored a different design, which admittedly leaves some boilerplate:

let tasks = TaskManager::current();
let exec = tasks.executor();

However, this approach is more explicit and clarifies exactly what is happening during setup:

let mut nodes = TestNetworkBuilder::<OptimismNode>::new(2, chain_spec, exec).build().await?;

While I strive to apply the DRY (Don’t Repeat Yourself) principle wherever practical, I generally prefer explicit coding over obscuring details just to avoid duplicating logic. This stance is simply my personal preference, and I’m always eager to learn from differing viewpoints.

I'd be curious on how you'd implement the scenario from 7552 PR which will (hopefully) be merged into main soon

I guess we'll find out soon! I plan to rebase this PR on your commits once they are merged into the main branch. 🙃

@joshieDo
Copy link
Collaborator

joshieDo commented May 3, 2024

I generally prefer explicit coding over obscuring details just to avoid duplicating logic

I feel like there must be nuance here. Any abstraction is obscuring details by default. However, we are "obscuring" boilerplate code. In the context of building a readable test scenario, it adds no value being explicit like this imo. I'm horrible at naming, maybe setup is not the best.

Here, we returned the _tasks and effectively ignored them

It needs to be in scope like you mentioned.

@loocapro loocapro force-pushed the e2e-imp branch 3 times, most recently from 042aa29 to e417648 Compare May 8, 2024 13:13
@loocapro loocapro force-pushed the e2e-imp branch 3 times, most recently from 25f650b to bd37d52 Compare May 10, 2024 14:05
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

this is great!

have a few nits and this needs a rebase because some types changed, should be trivial though

crates/e2e-test-utils/src/lib.rs Outdated Show resolved Hide resolved
crates/e2e-test-utils/src/lib.rs Outdated Show resolved Hide resolved
crates/e2e-test-utils/src/lib.rs Outdated Show resolved Hide resolved
crates/e2e-test-utils/src/network.rs Outdated Show resolved Hide resolved
crates/e2e-test-utils/src/node.rs Outdated Show resolved Hide resolved
crates/e2e-test-utils/src/runner.rs Outdated Show resolved Hide resolved
crates/e2e-test-utils/src/runner.rs Outdated Show resolved Hide resolved
crates/e2e-test-utils/src/transaction.rs Show resolved Hide resolved
loocapro and others added 9 commits May 30, 2024 13:44
chore: lint

fix: tests

fix: tx req accesslist none

fix: mut tx req

fix: setup returns tasks so it doesnt get dropped

fix: optimism test

fix: optimism gas
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
chore: lint

fix: tests

fix: tx req accesslist none

fix: mut tx req

fix: setup returns tasks so it doesnt get dropped

fix: optimism test

fix: optimism gas

feat: TestNodeGenerator and TestNetworkBuilder and refactored a bit

fix: type alias

feat: chain builder

feat: chain runner wip

review: returing chained payloads from advance_many

feat: runner using blanket impl

feat: runner generic to N and removed action trait

feat: pushing ctx to next futures storing the full clojure

feat: action runner and action stream

fix: doctest no run

clippy

fix: using type alias to

chore: remove old file

chore: ignore doctest

fix: reducing time to sleep from 1 sec to 5 ms on blob test

fix: rebase mistake
rebase corrections

adding span to logs

clippy

troubleshooting

still

removed logs

clippy

fix: log

clippy

fix: test

review

omitting let binding

smol fix

fix: clippy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-test A change that impacts how or what we test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants