Skip to content

Conversation

@mikety
Copy link
Contributor

@mikety mikety commented Oct 17, 2025

No description provided.

@mikety mikety changed the title read is_delegated from acounct code hash read is_delegated from code hash Oct 17, 2025
@mikety mikety force-pushed the mikety/is-delegated-eoa branch 2 times, most recently from 87b74fd to cb481d6 Compare October 21, 2025 23:00
@mikety mikety marked this pull request as ready for review October 21, 2025 23:01
Copilot AI review requested due to automatic review settings October 21, 2025 23:01
Copy link

Copilot AI left a 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_code field 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.

@mikety mikety changed the title read is_delegated from code hash read is_delegated from inline code Oct 21, 2025
@mikety mikety changed the title read is_delegated from inline code read delegated status of eoa from the account Oct 21, 2025
@mikety mikety force-pushed the mikety/is-delegated-eoa branch from cb481d6 to 26783e4 Compare October 22, 2025 05:37
Comment on lines +54 to +62
} 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 {
Copy link
Contributor

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;
Copy link
Contributor

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?

Copy link
Contributor

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;
Copy link
Contributor

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

Comment on lines 46 to 48
pub code_hash: Option<B256>,
pub inline_code: Option<FixedBytes<23>>,
pub is_delegated: bool,
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants