-
Notifications
You must be signed in to change notification settings - Fork 201
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
Impl eth_call state override feature #3027
base: master
Are you sure you want to change the base?
Conversation
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.
Reviewed 11 of 18 files at r1, all commit messages.
Reviewable status: 11 of 18 files reviewed, 4 unresolved discussions (waiting on @Pana)
crates/cfxcore/executor/src/state/overlay_account/mod.rs
line 187 at r1 (raw file):
/// Inditcates if this account's storage entries and lazily loaded fields on /// db are marked invalid (so an entry is empty if not in cache). pub fn fresh_storage(&self) -> bool {
fresh_storage
should take storage_overrided
into consideration.
crates/cfxcore/executor/src/state/state_object/state_override.rs
line 26 at r1 (raw file):
}; self.prefetch(&addr_with_space, RequireFields::Code)?;
I think the following logic should be in the initialization of OverlayAccount
, by adding a function like new_loaded_with_overrided
, rather than repeatedly modifying the OverlayAccount
here through state
.
crates/cfxcore/executor/src/state/overlay_account/storage.rs
line 201 at r1 (raw file):
Ok(if let Some(value) = self.cached_entry_at(key) { value } else if self.fresh_storage() || self.storage_overrided {
Update fresh_storage
and remove this.
crates/cfxcore/executor/src/state/overlay_account/storage.rs
line 245 at r1 (raw file):
// used for state override.diff pub fn update_storage_read_cache(&mut self, key: Vec<u8>, value: U256) { let owner = if self.address.space == Space::Native {
Assert empty checkpoint here.
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.
Reviewable status: 10 of 19 files reviewed, 4 unresolved discussions (waiting on @ChenxingLi)
crates/cfxcore/executor/src/state/overlay_account/mod.rs
line 187 at r1 (raw file):
Previously, ChenxingLi (Chenxing Li) wrote…
fresh_storage
should takestorage_overrided
into consideration.
Done.
crates/cfxcore/executor/src/state/overlay_account/storage.rs
line 201 at r1 (raw file):
Previously, ChenxingLi (Chenxing Li) wrote…
Update
fresh_storage
and remove this.
Done.
crates/cfxcore/executor/src/state/overlay_account/storage.rs
line 245 at r1 (raw file):
Previously, ChenxingLi (Chenxing Li) wrote…
Assert empty checkpoint here.
Done.
crates/cfxcore/executor/src/state/state_object/state_override.rs
line 26 at r1 (raw file):
Previously, ChenxingLi (Chenxing Li) wrote…
I think the following logic should be in the initialization of
OverlayAccount
, by adding a function likenew_loaded_with_overrided
, rather than repeatedly modifying theOverlayAccount
here throughstate
.
Done.
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.
Reviewed 3 of 18 files at r1, 1 of 5 files at r2, all commit messages.
Reviewable status: 14 of 19 files reviewed, 11 unresolved discussions (waiting on @Pana)
crates/cfxcore/executor/src/state/overlay_account/factory.rs
line 58 at r2 (raw file):
} pub fn from_loaded_and_override(
from_loaded_with_override
crates/cfxcore/executor/src/state/overlay_account/factory.rs
line 65 at r2 (raw file):
if let Some(balance) = acc_overrides.balance { let curr_balance = acc.balance().clone();
*acc.balance()
crates/cfxcore/executor/src/state/overlay_account/factory.rs
line 76 at r2 (raw file):
} if let Some(code) = acc_overrides.code.clone() {
Don't clone in the reading part, use as_ref
instead.
crates/cfxcore/executor/src/state/overlay_account/factory.rs
line 81 at r2 (raw file):
match ( acc_overrides.state.clone(),
Same, use as_ref
crates/cfxcore/executor/src/state/overlay_account/factory.rs
line 90 at r2 (raw file):
acc.override_storage_read_cache(&diff, false); } (Some(_state), Some(_diff)) => unreachable!(), /* the rpc layer */
It is better to translate the rpc type into a new type to avoid unreachable
here.
crates/cfxcore/executor/src/state/overlay_account/storage.rs
line 254 at r2 (raw file):
self.storage_read_cache .write() .insert(key.to_vec(), storage_value);
key
is already an Vec
.
crates/cfxcore/executor/src/state/overlay_account/storage.rs
line 258 at r2 (raw file):
pub fn override_storage_read_cache( &mut self, state: &HashMap<H256, H256>, complete_override: bool,
Confuse with the State
in the whole execution layer. Consider using the account_storage
.
crates/cfxcore/executor/src/state/overlay_account/storage.rs
line 264 at r2 (raw file):
self.storage_overrided = true; } for (key, value) in state.iter() {
I believe the compiler doesn't require an iter()
here.
crates/cfxcore/executor/src/state/overlay_account/storage.rs
line 267 at r2 (raw file):
let key = key.as_bytes().to_vec(); let value = U256::from_big_endian(value.as_bytes()); self.update_storage_read_cache(key, value);
What about putting all the implementation about update_storage_read_cache
directly?
And assert empty checkpoints once.
crates/cfxcore/executor/src/state/overlay_account/account_entry.rs
line 41 at r2 (raw file):
} pub fn from_loaded_and_override(
from_loaded_with_override
crates/cfxcore/executor/src/state/state_object/state_override.rs
line 28 at r2 (raw file):
); self.cache.write().insert(addr_with_space, account_entry);
Use let cache = self.cache.write()
before the for loop.
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.
Reviewable status: 14 of 19 files reviewed, 11 unresolved discussions (waiting on @ChenxingLi)
crates/cfxcore/executor/src/state/overlay_account/account_entry.rs
line 41 at r2 (raw file):
Previously, ChenxingLi (Chenxing Li) wrote…
from_loaded_with_override
Done.
crates/cfxcore/executor/src/state/overlay_account/factory.rs
line 58 at r2 (raw file):
Previously, ChenxingLi (Chenxing Li) wrote…
from_loaded_with_override
Done.
crates/cfxcore/executor/src/state/overlay_account/factory.rs
line 65 at r2 (raw file):
Previously, ChenxingLi (Chenxing Li) wrote…
*acc.balance()
Done.
crates/cfxcore/executor/src/state/overlay_account/factory.rs
line 76 at r2 (raw file):
Previously, ChenxingLi (Chenxing Li) wrote…
Don't clone in the reading part, use
as_ref
instead.
Done.
crates/cfxcore/executor/src/state/overlay_account/factory.rs
line 81 at r2 (raw file):
Previously, ChenxingLi (Chenxing Li) wrote…
Same, use
as_ref
Done.
crates/cfxcore/executor/src/state/overlay_account/factory.rs
line 90 at r2 (raw file):
Previously, ChenxingLi (Chenxing Li) wrote…
It is better to translate the rpc type into a new type to avoid
unreachable
here.
Done.
crates/cfxcore/executor/src/state/overlay_account/storage.rs
line 254 at r2 (raw file):
Previously, ChenxingLi (Chenxing Li) wrote…
key
is already anVec
.
Done.
crates/cfxcore/executor/src/state/overlay_account/storage.rs
line 258 at r2 (raw file):
Previously, ChenxingLi (Chenxing Li) wrote…
Confuse with the
State
in the whole execution layer. Consider using theaccount_storage
.
Done.
crates/cfxcore/executor/src/state/overlay_account/storage.rs
line 264 at r2 (raw file):
Previously, ChenxingLi (Chenxing Li) wrote…
I believe the compiler doesn't require an
iter()
here.
Done.
crates/cfxcore/executor/src/state/overlay_account/storage.rs
line 267 at r2 (raw file):
Previously, ChenxingLi (Chenxing Li) wrote…
What about putting all the implementation about
update_storage_read_cache
directly?And assert empty checkpoints once.
Done.
crates/cfxcore/executor/src/state/state_object/state_override.rs
line 28 at r2 (raw file):
Previously, ChenxingLi (Chenxing Li) wrote…
Use
let cache = self.cache.write()
before the for loop.
Done.
retest this please |
2 similar comments
retest this please |
retest this please |
This change is