Input addresses

This commit is contained in:
Daniel Lubarov 2023-03-16 14:08:31 -07:00
parent c8d591f6da
commit 44c77f5583
5 changed files with 15 additions and 0 deletions

View File

@ -46,6 +46,13 @@ pub struct GenerationInputs {
pub contract_code: HashMap<H256, Vec<u8>>,
pub block_metadata: BlockMetadata,
/// A list of known addresses in the input state trie (which itself doesn't hold addresses,
/// only state keys). This is only useful for debugging, so that we can return addresses in the
/// post-state rather than state keys. (See `GenerationOutputs`, and in particular
/// `AddressOrStateKey`.) If the caller is not interested in the post-state, this can be left
/// empty.
pub addresses: Vec<Address>,
}
#[derive(Clone, Debug, Deserialize, Serialize, Default)]

View File

@ -30,6 +30,11 @@ pub struct AccountOutput {
}
pub(crate) fn get_outputs<F: Field>(state: &mut GenerationState<F>) -> GenerationOutputs {
// First observe all addresses passed in the by caller.
for address in state.inputs.addresses.clone() {
state.observe_address(address);
}
let account_map = read_trie::<AccountTrieRecord>(
&state.memory,
state.memory.read_global_metadata(StateTrieRoot).as_usize(),

View File

@ -101,6 +101,7 @@ fn test_basic_smart_contract() -> anyhow::Result<()> {
tries: tries_before,
contract_code,
block_metadata,
addresses: vec![],
};
let mut timing = TimingTree::new("prove", log::Level::Debug);

View File

@ -48,6 +48,7 @@ fn test_empty_txn_list() -> anyhow::Result<()> {
},
contract_code: HashMap::new(),
block_metadata,
addresses: vec![],
};
let mut timing = TimingTree::new("prove", log::Level::Debug);

View File

@ -75,6 +75,7 @@ fn test_simple_transfer() -> anyhow::Result<()> {
tries: tries_before,
contract_code: HashMap::new(),
block_metadata,
addresses: vec![],
};
let mut timing = TimingTree::new("prove", log::Level::Debug);