consensus-shipyard / ipc

🌳 Spawn multi-level trees of customized, scalable, EVM-compatible networks with IPC. L2++ powered by FVM, Wasm, libp2p, IPFS/IPLD, and CometBFT.
https://ipc.space
Apache License 2.0
44 stars 39 forks source link

Index top-down cross-net messages by height #63

Closed adlrocha closed 11 months ago

adlrocha commented 1 year ago

When a new top-down cross-net message is committed in the parent is currently indexed by nonce in an array. We don't keep any information about the height in the parent where the message was committed.

As we are moving into a new design for top-down cross-net execution based on proofs of finality, it simplifies a lot the logic to track at what height messages were committed in the parent. Thus, we will index them by height through a mapping(height -> []CrossMsg) so we can easily query the messages committed at each height

aakoshh commented 1 year ago

As a side note, to avoid bloating the state tree with the message payloads, in IBC only the hash of the message is added to the outbox, while the message itself is emitted as an event, which is stored by Tendermint Core in the transaction event log. The relayers reconstruct the message from the event log and attach it to the relayed transaction, and the IBC contract compares it to the hash, for which it has a Merkle proof of inclusion in the committed state.

Once again this way the payload itself would not be part of the above mapping itself, reducing the cost of the transaction by not storing this for eternity.

aakoshh commented 1 year ago

A similar approach would be possible in our case as well. If the contract emits the CrossMsg as an event, then

In both cases they don't have to weigh down on the Ethereum contract storage.

cryptoAtwill commented 1 year ago

Evm should have provided api to query the events by topic id, there should have no need to use lotus apis.

Just that using this approach, the messages will not be available in contract or available for other contracts. Do we need the messages to be available for other contracts? We might also need a way to validate these are the messages that are committed in a block height in parent or it's completely relying on fendermint parent finality?

Also, unit testing would be quite difficult I guess if the top down messages are not off chain considering we are using forge sol tests.

adlrocha commented 11 months ago

closing this one as it has been addressed differently in https://github.com/consensus-shipyard/ipc-solidity-actors/pull/285 (@cryptoAtwill, feel free to reopen if this is not the case)