Commit Graph

43 Commits

Author SHA1 Message Date
Tamara
eaca47479b feat: Simulate txs against RPC (#261)
* feat: (WIP) Simulate txs against RPC

* fix: include test_executor_addresses.json

We should probably fetch this from execution instead. Will do later

* feat: (WIP) Attempt to use TokenProxyOverwriteFactory

* feat: (WIP) Attempt to use TokenProxyOverwriteFactory

* feat: Add simulating execution using debug_traceCall

Decoded amount out from execution and compared with the one from simulation
Allow for printing the execution traces
Moved all execution methods into execution.rs
Created traces.rs (heavily clauded) that prints the traces nicely and gets the function selectors frm 4byte (I decided not to use EtherscanIdentifier from foundry because adding foundry as a dependency is really heavy and I expect problems because of it)

Temporary: hardcoded storage slots for test_weighted_pool_v4 to pass

#time 1h 55m

* feat: Use BalanceSlotDetector and AllowanceSlotDetector from tycho_ethereum

#time 1h 14m

* fix: Improve traces.rs

#time 2m

* feat: Add skip_execution

Also get tycho router bytecode at compile time

#time 22m

* test: Skip tests that are before the Shanghai upgrade

Remove unnecessary TODOs

#time 35m

* feat: Point tycho dependencies to specific commits

#time 9m

* fix: Set historical_trade to true in TychoRouterEncoderBuilder

#time 41m


#time 0m

* feat: Improve traces.rs (use foundry instead of 4bytes)

Improved the format of the printed trace as well

#time 1h 7m

* fix: After merge fixes

#time 3m

* feat: Use new executors_addresses in tycho-execution and read it at startup

#time 1h 25m

* feat: Create a new flag to enable execution_traces

#time 9m

* fix: Small code, log and trace improvements

Add trying to decode method's calldatas in tracing

#time 1m

* fix: Simplify simulate_transactions_with_tracing by introducing a new method: bytes_to_fixed_32

#time 13m

* fix: After merge fixes

#time 1m

* fix: Include executor's bytecode at compile time

#time 11m

---------

Co-authored-by: TAMARA LIPOWSKI <data.lipowski@extaccount.com>
Co-authored-by: Diana Carvalho <diana@propellerheads.xyz>
2025-09-23 15:57:43 +01:00
TAMARA LIPOWSKI
dbabda84f2 chore: improved logging and comment 2025-09-23 00:42:23 -04:00
TAMARA LIPOWSKI
2c0c4d97fb refactor: Move module_name to integration test yaml
It's not good to keep this in the test_runner because then we have multiple points that we need to edit the test config, which can be hard to find.

We need this because the module name for uniswap_v2 is so far different from the rest of the protocols.
2025-09-23 00:42:23 -04:00
TAMARA LIPOWSKI
99c8a32d23 feat: Add test for PancakeswapV2
- There are some ugly hardcodings here that I hope to improve.
2025-09-23 00:42:23 -04:00
TAMARA LIPOWSKI
12e6e48a78 feat: Add test for UniswapV2
- Used a random post-Shanghai-created USV2 pool state with enough liquidity for the test

Necessary fixes:
- Don't hardcode to EVMPoolState
- Don't expect adapter to always be set.
- UniswapV2 names its module differently for some reason... this seems like a special case so instead of updating all integration test yamls, I'm just hardcoding it in test_runner.rs. Perhaps not the best decision?
- Log the static attributes if not found.
- Get the substreams yaml path from config instead of hardcoding it.
2025-09-23 00:42:23 -04:00
adrian
9f4ff71b70 refactor: remove skip_balance_check from run_test signature
This field is redundant, as it can be read directly from `config`
2025-09-18 20:00:06 +02:00
adrian
323063da23 fix: move adapter contract building/finding after filtering components 2025-09-18 20:00:06 +02:00
TAMARA LIPOWSKI
0226bda482 fix: Compare lowercase component IDs
- This was failing. Make this more lenient so the user can specify component id in the test file in a non-case-sensitive manner.
- Also switched around a wrong token order which was causing a failure (not sure we care about token order but we may in the future? Python didn't care...)
2025-09-18 11:18:25 -04:00
adrian
e684a64002 fix: logs handling 2025-09-16 11:31:19 +02:00
adrian
3332a88e6f fix: version handling in protocol-testing 2025-09-16 11:31:19 +02:00
dianacarvalho1
89b56e2d42 fix: Pass vm_traces to DecoderContext (#264)
#time 2h 39m
2025-09-12 16:51:19 +01:00
adrian
92336df9bb feat: skip tests run if the config is invalid 2025-09-12 10:59:17 +02:00
adrian
2a0af6c733 feat: upgrade tycho deps in protocol-testing 2025-09-12 10:59:17 +02:00
adrian
fc56311a81 refactor: add a root-path argument to build the necessary paths ouf of it, instead of passing them separately 2025-09-11 16:27:01 +02:00
dianacarvalho1
22843cfd3b feat: Add encoding to test suite (#259)
* feat: Add encoding to test suite

Use execution from simulation
Add protocol_system to all test files and pass it to run tycho
Add encoding_utils.rs

#time 5h 0m

#time 1m

#time 7m

* refactor: Move encoding swap to its own method to simplify main code

Rename encoding_utils.rs to encoding.rs

#time 20m


#time 0m

#time 0m
2025-09-11 14:30:49 +01:00
adrian
db5c418e57 feat: test-runner return error if one of the tests failed 2025-09-11 10:59:00 +02:00
adrian
894b169e6f feat: add --evm-path argument to test CLI 2025-09-11 10:59:00 +02:00
adrian
805447f82b feat: install foundry binaries into run.Dockerfile 2025-09-11 10:59:00 +02:00
TAMARA LIPOWSKI
1d8a0069e2 fix: Use permutations to get token directions
- This is needed for pools which have >2 tokens.
2025-09-10 11:44:16 -04:00
TAMARA LIPOWSKI
e121f86ff1 feat: get amount out for both directions
Basically same as before but now in a loop - once per direction - to match the python test suite.
2025-09-10 11:44:16 -04:00
TAMARA LIPOWSKI
76c9461eb0 feat: Clear PreCachedDB account storage btw tests
[copied from tycho-simulation commit msg]

Main issue:
- This was causing a big issue in the SDK testing, since accounts were being leaked between test cases. Adding this functionality provides an easy way to clear storage on the rust side, by calling .clear() between subsequent tests.

How this manifested:
- Incorrect pool balances were being loaded in the BalancerV2SwapAdapter if tests were run altogether.
- Pool balances were correct if tests were run in isolation.
- We checked that tycho-indexer returned correct pool balances, and we checked pool balances for that block on-chain to be double-sure
- In the python test suite, which was passing, there was code which dropped the whole database between subsequent tests, which was not being duplicated in the rust suite.
2025-09-10 11:44:16 -04:00
TAMARA LIPOWSKI
d75e62ed3d feat: Fetch proper block header for simulation
- Similarly to the way it was done in the python package.
2025-09-10 11:44:16 -04:00
TAMARA LIPOWSKI
dc288bcf29 fix: Skip simulation if skip_simulation = True
This is why we weren't getting BAL510 for `test_erc4626_linear_pool_creation` in python - simulation was being skipped, though not skipped in the rust porting. The simulation is skipped here since no liquidity has been added in more than 100k blocks.
2025-09-10 11:44:16 -04:00
TAMARA LIPOWSKI
02ed0fe216 feat: Improved error handling
This was previously showing that the test passed even when it failed.

TODO:
- This still fails with "Insufficient balance". Need to debug why.
2025-09-10 11:44:16 -04:00
TAMARA LIPOWSKI
f5bcd31d66 feat: Rust testing SDK - implement get_amount_out simulation 2025-09-10 11:44:16 -04:00
TAMARA LIPOWSKI
5f8dccb729 feat: Pass adapter contract to decoder
This was the most elegant solution we could come up with at the moment for having the proper adapter in the builder.

Notes:
- The default adapter bytecode in tycho-simulation is still loaded at compile time.
- If the adapter bytecode is passed to the decoder, it will be loaded dynamically at runtime and used instead the bytecodes in tycho-simulation.
- The adapter bytecode is used in the builder to get capabilities and thus spot prices before returning the state, so just overwriting the adapter in the state is way too cumbersome. We went with this solution since it was the lesser evil, even though we know it leaks VM-specific info to non-vm protocols (which was already being done anyway with the balances).
2025-09-10 11:44:16 -04:00
adrian
62f0cc3060 chore: move separator to print it before anything else at the start 2025-09-10 16:36:08 +02:00
adrian
b1db641c31 fix: docker entrypoint handle correctly passing a single argument as a string 2025-09-10 16:36:08 +02:00
adrian
580a8822a5 feat: add match-test argument to test cli 2025-09-10 16:36:08 +02:00
adrian
24504d0f94 feat: add docker image to build binaries used in tests 2025-09-10 16:36:08 +02:00
Tamara
93b969e41f feat(Testing SDK): Pass adapter path to decoder (#249)
* feat: Pass adapter contract to decoder

This was the most elegant solution we could come up with at the moment for having the proper adapter in the builder.

Notes:
- The default adapter bytecode in tycho-simulation is still loaded at compile time.
- If the adapter bytecode is passed to the decoder, it will be loaded dynamically at runtime and used instead the bytecodes in tycho-simulation.
- The adapter bytecode is used in the builder to get capabilities and thus spot prices before returning the state, so just overwriting the adapter in the state is way too cumbersome. We went with this solution since it was the lesser evil, even though we know it leaks VM-specific info to non-vm protocols (which was already being done anyway with the balances).

* feat: Take a struct of vm_attributes instead of just adapter path

So that we don't need to change the interface in the future

* chore: remove comment - we are no longer blocked

This is fixed with the latest change to pass adapter contract to decoder

* feat: Use DecoderContext instead of VMAttributes

- More easily extendable
- Doesn't break the existing decoder interface

---------

Co-authored-by: TAMARA LIPOWSKI <data.lipowski@extaccount.com>
2025-09-08 14:34:27 -04:00
adrian
eac74450bc test: add test for the token balances validation 2025-09-04 17:46:27 +02:00
adrian
ae6f5e0a12 feat: return errors instead of doing asserts 2025-09-03 08:55:29 -04:00
adrian
87c9a8b60f test: check that all the existing substreams integration test files can be parsed 2025-09-03 08:55:29 -04:00
TAMARA LIPOWSKI
c12affb3ca docs: Add README and logging to match python package
- The readme is useful for us during development. This should be eventually removed and replaced with gitbook docs.
2025-09-03 08:55:29 -04:00
adrian
8205c2a8d5 feat: handle errors in protocol-testing 2025-09-03 08:55:29 -04:00
adrian
f3500dff44 feat: update tycho deps and upgrade code 2025-09-03 08:55:29 -04:00
Thales
def49e7ddf feat: fix test runner. Working version to get_amount_out 2025-09-03 08:55:29 -04:00
Thales Lima
afd5527b15 feat: Start simulation by calling get_amount_out 2025-09-03 08:55:29 -04:00
Thales
c9b2c655dd feat: build snapshot message from rpc requests 2025-09-03 08:55:29 -04:00
Thales Lima
052d11b759 feat: Add tokens balance check and component diff 2025-09-03 08:55:29 -04:00
Thales Lima
2c8e349280 feat: Add methods to fetch state from Tycho RPC 2025-09-03 08:55:29 -04:00
Thales Lima
160523a888 feat: add test runner structure 2025-09-03 08:55:29 -04:00