-
Couldn't load subscription status.
- Fork 289
read delegated status of eoa from the account #2468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
87b74fd to
cb481d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements the ability to read delegation status directly from the code hash in account data, rather than fetching and inspecting the code separately. The key changes involve storing inline code (23 bytes) for delegated accounts and determining delegation status during account decoding.
- Adds
inline_codefield to account structures to store delegated code inline - Refactors code retrieval logic to check for inline code before database lookup
- Updates account decoding to detect delegation from code hash length and extract inline code
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| monad-eth-types/src/lib.rs | Adds inline_code field to EthAccount struct |
| monad-triedb-utils/src/decode.rs | Implements logic to decode inline delegated code from 23-byte code hash and set delegation flag |
| monad-triedb-utils/src/triedb_env.rs | Adds inline_code field to Account struct and renames get_code to get_code_db |
| monad-triedb-utils/src/lib.rs | Removes redundant code fetching logic for delegation detection |
| monad-rpc/src/handlers/eth/account.rs | Updates code retrieval to check inline code before database lookup |
| monad-rpc/src/handlers/debug.rs | Updates code retrieval to check inline code before database lookup |
| monad-state-backend/src/mock.rs | Initializes inline_code field in mock implementation |
| monad-state-backend/src/in_memory.rs | Initializes inline_code field in in-memory implementation |
| monad-triedb-utils/src/mock_triedb.rs | Renames get_code method to get_code_db |
| monad-cxx/monad-execution | Updates subproject commit reference |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
cb481d6 to
26783e4
Compare
| } else if buf.len() == 33 { | ||
| match <[u8; 32]>::decode(&mut buf) { | ||
| Ok(x) => Some(x), | ||
| Err(e) => { | ||
| warn!("rlp code_hash decode failed: {:?}", e); | ||
| return None; | ||
| } | ||
| } | ||
| } else if buf.len() != 24 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the significance of length 33 and 24?
| } else { | ||
| match <[u8; 23]>::decode(&mut buf) { | ||
| Ok(x) => { | ||
| is_delegated = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't seem right -- is_delegated should only be true if it's prefixed with 0xef0100 right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when the decoded code field is inline, they are always 23 bytes and represents delegated code based on how execution stores it, but yeah we should add an assertion checking the prefix here.
| }; | ||
|
|
||
| let is_delegated = false; | ||
| let mut is_delegated = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i feel like having this is_delegated field here is error prone. it's defaulted to false for legacy accounts and only updated in get_accounts_async, whereas for new accounts it's the actual value here. I think they should be updated at the same place
| pub code_hash: Option<B256>, | ||
| pub inline_code: Option<FixedBytes<23>>, | ||
| pub is_delegated: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest consolidating these three fields to a single Vec<u8> field but provide helper methods like has_code(), is_inline_delegated() and get_code_hash() (similar to the Account in execution).
The only con of this is this will require computing code hash on demand for delegated accounts, which adds a keccak operation. However, this should only impact eth_getAccount in RPC iiuc, and delegated accounts are expected to be a small portion, thus the impact is minimal.
No description provided.