• Mark Tyneway's avatar
    contracts-bedrock: improve `CrossL2Inbox` devex (#11322) · 051db548
    Mark Tyneway authored
    * contracts-bedrock: improve `CrossL2Inbox` devex
    
    Improve the `CrossL2Inbox` devex by creating an alternative entrypoint.
    This design was not considered previously because there was a "top level
    call" restriction, aka the "only EOA" invariant. This was to allow for
    static analysis of transactions, keeping resource usage lower for
    validating transactions when building blocks or at the mempool layer.
    Since 3074/7702 render the enforcement of only eoa impossible,  we decided
    to op/acc and lean into the approach of allowing subcalls to trigger
    `ExecutingMessage` events.
    
    This new interface allows another contract to be the entrypoint,
    the idea is that the user sends the `Identifier` and the serialized
    log (message) to whatever contract that they want and then pass it to
    `CrossL2Inbox.validateMessage` which then emits the event that consensus
    validates. This allows the calling smart contract to be aware of the
    schema for the log and deserialize it however they see fit. Since the
    serialized logs are done with the following algorithm:
    
    ```go
    msg := make([]byte, 0)
    for _, topic := range log.Topics {
        msg = append(msg, topic.Bytes()...)
    }
    msg = append(msg, log.Data...)
    ```
    
    It is very easy to use `abi.decode` to decode a log, given that solidity
    was used to `emit` it. The topics are `bytes32` and then the data is
    abi encoded given the schema of the event itself. Unused parts like
    `topic[0]` (hash of the event name) can be dropped when decoding if
    they are not required.
    
    * ctb: fix typo
    
    * remove nonReentrant and add tests for validateMessage, rename ENTERED_SLOT preimage
    
    * add natspec for _checkIdentifier and update that of validateMessage
    
    * update version and semver-lock file
    
    * check all topics in crossl2inbox test, run pnpm snapshots
    
    * tests: fix
    
    ---------
    Co-authored-by: default avatarMichael Amadi <amadimichaeld@gmail.com>
    051db548
Name
Last commit
Last update
..
EAS Loading commit data...
L1 Loading commit data...
L2 Loading commit data...
Safe Loading commit data...
cannon Loading commit data...
dispute Loading commit data...
governance Loading commit data...
legacy Loading commit data...
libraries Loading commit data...
periphery Loading commit data...
universal Loading commit data...
vendor Loading commit data...