From 5f8dccb729249f378b8dec2e8f052a50969814d6 Mon Sep 17 00:00:00 2001 From: TAMARA LIPOWSKI Date: Fri, 5 Sep 2025 11:36:08 -0400 Subject: [PATCH] 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). --- protocol-testing/Cargo.lock | 3 +-- protocol-testing/src/test_runner.rs | 5 ----- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/protocol-testing/Cargo.lock b/protocol-testing/Cargo.lock index 732b4cf..b2a8f31 100644 --- a/protocol-testing/Cargo.lock +++ b/protocol-testing/Cargo.lock @@ -7821,8 +7821,7 @@ dependencies = [ [[package]] name = "tycho-simulation" -version = "0.156.0" -source = "git+https://github.com/propeller-heads/tycho-simulation.git?tag=0.156.0#1983a787440e8ae757626d808a6e619baffc52f2" +version = "0.155.2" dependencies = [ "alloy", "async-stream", diff --git a/protocol-testing/src/test_runner.rs b/protocol-testing/src/test_runner.rs index e67fa11..75bb944 100644 --- a/protocol-testing/src/test_runner.rs +++ b/protocol-testing/src/test_runner.rs @@ -336,11 +336,6 @@ fn validate_state( decoder_context, ); - // NOTE: Once tycho-simulation is updated, you can use the new API like this: - // use tycho_simulation::protocol::models::DecoderContext; - // let context = DecoderContext::new().vm_adapter_path(adapter_contract_path_str); - // decoder.register_decoder_with_context::>("test_protocol", context); - // Mock a stream message, with only a Snapshot and no deltas let mut states: HashMap = HashMap::new(); for (id, component) in components_by_id {