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

Adds deterministic testing for Ethereum #399

Open
wants to merge 41 commits into
base: develop
Choose a base branch
from

Conversation

mikewcasale
Copy link
Contributor

Handles issue #398

@mikewcasale mikewcasale added the enhancement New feature or request label Mar 1, 2024
@mikewcasale mikewcasale self-assigned this Mar 1, 2024
@mikewcasale mikewcasale marked this pull request as draft March 1, 2024 03:01
@mikewcasale mikewcasale linked an issue Mar 1, 2024 that may be closed by this pull request
@mikewcasale
Copy link
Contributor Author

Note that prior to changing "Draft" status on this PR, I still need to add the corresponding updates to the Github Actions, test it, &etc. In the meantime however it would be helpful to get your feedback on the core code changes.

@mikewcasale mikewcasale changed the base branch from main to develop March 4, 2024 12:32
fastlane_bot/config/multicaller.py Outdated Show resolved Hide resolved
fastlane_bot/tests/deterministic/dtest_constants.py Outdated Show resolved Hide resolved
fastlane_bot/tests/deterministic/dtest_pool.py Outdated Show resolved Hide resolved
fastlane_bot/tests/deterministic/dtest_token.py Outdated Show resolved Hide resolved
return (
[[self.token.address], self.hex_balance]
if self.token.is_eth
else [self.token.address, wallet_address, self.hex_balance]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why such a different output structure for eth vs for non-eth?
Wouldn't that cause havoc on the caller function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does not cause havoc, as the implementation fundamentally works as expected. However, to a large extent my efforts here were to cleanup and improve upon @NIXBNT 's original solution, while not altering the underlying logic to any great extent - thus, I would defer to Nick on your first question...

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would concur with Barak here that returning a length 2 / length 3 list that really should be a dict or dataclass can be problematic; not a show stopper given that it fits in the current design but should probably be raised as an overall cleanup issue

Copy link
Contributor Author

@mikewcasale mikewcasale Mar 28, 2024

Choose a reason for hiding this comment

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

The return value of the faucet_params( ) method is immediately used to make a request to Tenderly, as you can see in the following code:

params = token_balance.faucet_params(wallet_address=self.pool_address)
method_name = RPCEndpoint(
    "tenderly_setBalance"
    if token_balance.token.is_eth
    else "tenderly_setErc20Balance"
)
w3.provider.make_request(method=method_name, params=params)

Thus, I refer you to the Tenderly documentation for reference, so you can see the expected structure of ETH vs ERC20 requests:

So, while I can see your point of concern, in this case, the reason behind it is strictly 3rd party api's, and IMO changing the handling would add complexity and offer no benefit, and possibly introduce bugs in the process.

@mikewcasale mikewcasale marked this pull request as ready for review March 11, 2024 13:59
@mikewcasale mikewcasale requested a review from NIXBNT March 12, 2024 19:11
Lesigh-3100
Lesigh-3100 previously approved these changes Mar 12, 2024
fastlane_bot/config/multicaller.py Outdated Show resolved Hide resolved
fastlane_bot/tests/deterministic/dtest_constants.py Outdated Show resolved Hide resolved
fastlane_bot/tests/deterministic/dtest_token.py Outdated Show resolved Hide resolved
return (
[[self.token.address], self.hex_balance]
if self.token.is_eth
else [self.token.address, wallet_address, self.hex_balance]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would concur with Barak here that returning a length 2 / length 3 list that really should be a dict or dataclass can be problematic; not a show stopper given that it fits in the current design but should probably be raised as an overall cleanup issue

run_deterministic_tests.py Outdated Show resolved Hide resolved
run_deterministic_tests.py Outdated Show resolved Hide resolved
run_deterministic_tests.py Outdated Show resolved Hide resolved
run_deterministic_tests.py Outdated Show resolved Hide resolved
run_deterministic_tests.py Outdated Show resolved Hide resolved
"wallet": "0x28C6c06298d514Db089934071355E5743bf21d60"
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Best to maintain all floating point values as strings, and convert them to Decimal in the code, so as to avoid accuracy loss.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

can you be more specific about which values you're referring to? as of now, the tests pass in the sense of finding the expected values, and what you're suggesting seems like it could mean converting all float and int types to Decimal, which is a fairly risky effort in terms of introducing bugs -- which in this case means attempting to fix what isn't broken

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm saying that in data files (JSONs CSVs, etc), we should generally represent non-integer values with strings.

fastlane_bot/tests/deterministic/dtest_strategy.py Outdated Show resolved Hide resolved
@NIXBNT NIXBNT force-pushed the deterministic-testing-integration2 branch from 58905a1 to c97312f Compare May 23, 2024 05:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Deterministic Testing Infrastructure
6 participants