-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,7 @@ | |
| // You should have received a copy of the GNU General Public License | ||
| // along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| use alloy_primitives::{B256, U256}; | ||
| use alloy_primitives::{keccak256, FixedBytes, B256, U256}; | ||
| use alloy_rlp::Decodable; | ||
| use monad_eth_types::EthAccount; | ||
| use tracing::warn; | ||
|
|
@@ -47,23 +47,49 @@ pub fn rlp_decode_account(account_rlp: Vec<u8>) -> Option<EthAccount> { | |
| return None; | ||
| }; | ||
|
|
||
| let is_delegated = false; | ||
| let mut is_delegated = false; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i feel like having this |
||
| let mut inline_code = None; | ||
| let code_hash = if buf.is_empty() { | ||
| None | ||
| } else { | ||
| } 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 { | ||
|
Comment on lines
+54
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what's the significance of length 33 and 24? |
||
| warn!( | ||
| "The stored code_hash length is not expected {:?}", | ||
| buf.len() | ||
| ); | ||
| return None; | ||
| } 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 commentThe 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 commentThe 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. |
||
| inline_code = Some(x); | ||
| match keccak256(x).as_slice().try_into() { | ||
| Ok(hash) => Some(hash), | ||
| Err(e) => { | ||
| warn!("error extracting code_hash {:?}", e); | ||
| return None; | ||
| } | ||
| } | ||
| } | ||
| Err(e) => { | ||
| warn!("rlp delegated code_hash decode failed: {:?}", e); | ||
| return None; | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| Some(EthAccount { | ||
| nonce, | ||
| balance, | ||
| code_hash: code_hash.map(B256::from), | ||
| inline_code: inline_code.map(FixedBytes::<23>::from), | ||
| is_delegated, | ||
| }) | ||
| } | ||
|
|
||
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 likehas_code(),is_inline_delegated()andget_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.