-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
contracts-bedrock: improve
CrossL2Inbox
devex (#11322)
* 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: Michael Amadi <amadimichaeld@gmail.com>
- Loading branch information
1 parent
cc67d34
commit 051db54
Showing
7 changed files
with
202 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 12 additions & 1 deletion
13
packages/contracts-bedrock/snapshots/abi/TransientReentrancyAware.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,12 @@ | ||
[] | ||
[ | ||
{ | ||
"inputs": [], | ||
"name": "NotEntered", | ||
"type": "error" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "ReentrantCall", | ||
"type": "error" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters