• 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
.circleci Loading commit data...
.github Loading commit data...
.vscode Loading commit data...
bedrock-devnet Loading commit data...
cannon Loading commit data...
docs Loading commit data...
op-batcher Loading commit data...
op-bootnode Loading commit data...
op-chain-ops Loading commit data...
op-challenger Loading commit data...
op-conductor Loading commit data...
op-dispute-mon Loading commit data...
op-e2e Loading commit data...
op-heartbeat Loading commit data...
op-node Loading commit data...
op-plasma Loading commit data...
op-preimage Loading commit data...
op-program Loading commit data...
op-proposer Loading commit data...
op-service Loading commit data...
op-supervisor Loading commit data...
op-ufm Loading commit data...
op-wheel Loading commit data...
ops Loading commit data...
ops-bedrock Loading commit data...
packages/contracts-bedrock Loading commit data...
proxyd Loading commit data...
specs Loading commit data...
.coderabbit.yml Loading commit data...
.dockerignore Loading commit data...
.editorconfig Loading commit data...
.envrc.example Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.gitmodules Loading commit data...
.npmrc Loading commit data...
.nvmrc Loading commit data...
.semgrepignore Loading commit data...
.shellcheckrc Loading commit data...
.snyk Loading commit data...
CITATION.cff Loading commit data...
CONTRIBUTING.md Loading commit data...
LICENSE Loading commit data...
Makefile Loading commit data...
README.md Loading commit data...
SECURITY.md Loading commit data...
cloudbuild.yaml Loading commit data...
codecov.yml Loading commit data...
docker-bake.hcl Loading commit data...
go.mod Loading commit data...
go.sum Loading commit data...
package.json Loading commit data...
pnpm-lock.yaml Loading commit data...
pnpm-workspace.yaml Loading commit data...
versions.json Loading commit data...