enviodev / hypersync-client-rust

Rust crate for Envio's HyperSync client
Mozilla Public License 2.0
21 stars 1 forks source link

Incorrect topic generation for event signatures with tuples #50

Open Evan-Kim2028 opened 1 month ago

Evan-Kim2028 commented 1 month ago

Problem

Hypersync logs cannot deal with tuples - can't generate the right topic and can't decode the log correctly either.

web 3 topic generation with the tuple:


topic0 = web3.Web3.keccak(
    # text="FilledV3Relay(address inputToken,address outputToken,uint256 inputAmount,"
    #         "uint256 outputAmount,uint256 repaymentChainId,uint256 indexed originChainId,"
    #         "uint32 indexed depositId,uint32 fillDeadline,uint32 exclusivityDeadline,"
    #         "address exclusiveRelayer,address indexed relayer,address depositor,"
    #         "address recipient,bytes message,V3RelayExecutionEventInfo relayExecutionInfo)"
    text="FilledV3Relay(address,address,uint256,uint256,uint256,uint256,uint32,uint32,uint32,address,address,address,address,bytes,(address,bytes,uint256,uint8))"
)

Returns topic0 = 0x571749edf1d5c9599318cdbc4e28a6475d65e87fd3b2ddbe1e9a8d5e7a0f0ff7 which is correct.

Hypersync topic generator

hypersync.signature_to_topic0(self.signature) with this signature:

 "FilledV3Relay(address inputToken, address outputToken, uint256 inputAmount, "
            "uint256 outputAmount, uint256 repaymentChainId, uint256 indexed originChainId, "
            "uint32 indexed depositId, uint32 fillDeadline, uint32 exclusivityDeadline, "
            "address exclusiveRelayer, address indexed relayer, address depositor, "
            "address recipient, bytes message, tuple relayExecutionInfo)"

Generates a different topic than web3.

Here is the tuple structure in the contract: - https://github.com/across-protocol/contracts/blob/f67b64caff2e68464178ebeadb7d03ce633b50e3/contracts/interfaces/V3SpokePoolInterface.sol#L92

JasoonS commented 3 days ago

Thanks for reporting this @Evan-Kim2028 . Sorry we missed it for so long :sweat_smile:

I've transferred it here to the Rust client since this is the origin of where the issue needs to be fixed.