forked from kkrt-labs/kakarot-rpc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add eth_call and eth_send_transaction entrypoints to kakarot (kkrt-la…
…bs#554) Time spent on this PR: 2.5 ## Pull request type Please check the type of change your PR introduces: - [ ] Bugfix - [x] Feature - [ ] Code style update (formatting, renaming) - [x] Refactoring (no functional changes, no api changes) - [ ] Build related changes - [ ] Documentation content changes - [ ] Other (please describe): ## What is the current behavior? The EOAccount owns the logic of transferring native tokens and dispatching between contract deployment and contract invocation. On the other hand, the kakarot contract exposes two methods (execute_at_address & deploy_contract_account) that require the caller to know what they want to do and how they need to send the data. This is an extra complexity compared to what the EVM does: the kakarot contract should be able to handle a plain (encoded or decoded) EVM tx without requiring the caller to do any logic themselves. As a matter of fact, the EOAccount responsibility is (almost) narrowed to a standard AA responsibility: accepte a sign tx, verify signature and propagate the call. Almost because it still needs to **decode** the tx, and actually Yoav (from Braavos) thinks that we should go further and remove this **decoding** part from the EOA: only validate a signature and send the payload (encoded) to the kakarot contract. This would allow us to use Braavos contract out of the box (with a proper signer type) Resolves kkrt-labs#551 kkrt-labs#411 ## What is the new behavior? The Kakarot contract has two new entrypoints that behave as in the [ethereum RPC doc](https://ethereum.org/en/developers/docs/apis/json-rpc) - `eth_call`: Executes a new message call immediately without creating a transaction (`@view` function) - `eth_send_transaction`: Creates new message call transaction or a contract creation, if the data field contains code. (`@external` function) Along the way, the test refactoring (kkrt-labs#441) was eventually done, and the `ExecutionContext` `init` & `init_at_address` have been merged into one single general purpose `init` method. ## Other information Following a community call discussion, we could put more of these entrypoints in the main Kakarot contract: - eth_getBalance - eth_getStorageAt - eth_getTransactionCount - eth_getCode - etc. to put more logic in the core contract and less in the RPC thay may eventually require a complete refacto depending on where we actually make this kakarot live. I have added a check `compute_starknet_address(IAccount.get_evm_address(contract_address)) != contract_address` to avoid unexpected behaviors resulting from a starknet contract implementing `get_evm_address` without being **the** `ContractAccount`. I'd like to remove this sooner or later but still need to think about all the edge cases.
- Loading branch information
1 parent
662f251
commit 1ddafaf
Showing
106 changed files
with
1,077 additions
and
1,074 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
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
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
Oops, something went wrong.