Ignore global cache for patched accounts (#9752)
* Ignore global cache for patched accounts * Rollback patched account flag * Store root in checkpoint storage
This commit is contained in:
parent
1c1cd8b164
commit
a3bd355b16
@ -499,6 +499,7 @@ impl Provider where {
|
|||||||
None => bail!(ErrorKind::ContractDoesNotExist),
|
None => bail!(ErrorKind::ContractDoesNotExist),
|
||||||
Some(address) => {
|
Some(address) => {
|
||||||
let (code, storage) = state.into_account(&address)?;
|
let (code, storage) = state.into_account(&address)?;
|
||||||
|
trace!(target: "privatetx", "Private contract executed. code: {:?}, state: {:?}, result: {:?}", code, storage, result.output);
|
||||||
let enc_code = match code {
|
let enc_code = match code {
|
||||||
Some(c) => Some(self.encrypt(&address, &Self::iv_from_address(&address), &c)?),
|
Some(c) => Some(self.encrypt(&address, &Self::iv_from_address(&address), &c)?),
|
||||||
None => None,
|
None => None,
|
||||||
@ -506,7 +507,6 @@ impl Provider where {
|
|||||||
(enc_code, self.encrypt(&address, &Self::iv_from_transaction(transaction), &Self::snapshot_from_storage(&storage))?)
|
(enc_code, self.encrypt(&address, &Self::iv_from_transaction(transaction), &Self::snapshot_from_storage(&storage))?)
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
trace!(target: "privatetx", "Private contract executed. code: {:?}, state: {:?}, result: {:?}", encrypted_code, encrypted_storage, result.output);
|
|
||||||
Ok(PrivateExecutionResult {
|
Ok(PrivateExecutionResult {
|
||||||
code: encrypted_code,
|
code: encrypted_code,
|
||||||
state: encrypted_storage,
|
state: encrypted_storage,
|
||||||
|
@ -91,6 +91,17 @@ fn private_contract() {
|
|||||||
trace!("Transaction created. Pushing block");
|
trace!("Transaction created. Pushing block");
|
||||||
push_block_with_transactions(&client, &[public_tx]);
|
push_block_with_transactions(&client, &[public_tx]);
|
||||||
|
|
||||||
|
trace!("Querying default private state");
|
||||||
|
let mut query_tx = Transaction::default();
|
||||||
|
query_tx.action = Action::Call(address.clone());
|
||||||
|
query_tx.data = "0c55699c".from_hex().unwrap(); // getX
|
||||||
|
query_tx.gas = 50000.into();
|
||||||
|
query_tx.nonce = 1.into();
|
||||||
|
let query_tx = query_tx.sign(&key1.secret(), chain_id);
|
||||||
|
let result = pm.private_call(BlockId::Latest, &query_tx).unwrap();
|
||||||
|
assert_eq!(&result.output[..], &("0000000000000000000000000000000000000000000000000000000000000000".from_hex().unwrap()[..]));
|
||||||
|
assert_eq!(pm.get_validators(BlockId::Latest, &address).unwrap(), validators);
|
||||||
|
|
||||||
trace!("Modifying private state");
|
trace!("Modifying private state");
|
||||||
let mut private_tx = Transaction::default();
|
let mut private_tx = Transaction::default();
|
||||||
private_tx.action = Action::Call(address.clone());
|
private_tx.action = Action::Call(address.clone());
|
||||||
|
@ -204,6 +204,10 @@ impl Account {
|
|||||||
self.code_filth = Filth::Dirty;
|
self.code_filth = Filth::Dirty;
|
||||||
self.storage_cache = Self::empty_storage_cache();
|
self.storage_cache = Self::empty_storage_cache();
|
||||||
self.storage_changes = storage;
|
self.storage_changes = storage;
|
||||||
|
if self.storage_root != KECCAK_NULL_RLP {
|
||||||
|
self.original_storage_cache = Some((self.storage_root, Self::empty_storage_cache()));
|
||||||
|
}
|
||||||
|
self.storage_root = KECCAK_NULL_RLP;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set (and cache) the contents of the trie's storage at `key` to `value`.
|
/// Set (and cache) the contents of the trie's storage at `key` to `value`.
|
||||||
|
Loading…
Reference in New Issue
Block a user