Skip to content
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

feat: do not return databus returndata, keep it private. #5023

Merged
merged 4 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1729,13 +1729,16 @@ impl<'a> Context<'a> {
// will expand the array if there is one.
let return_acir_vars = self.flatten_value_list(return_values, dfg)?;
let mut warnings = Vec::new();
for acir_var in return_acir_vars {
for (acir_var, is_databus) in return_acir_vars {
if self.acir_context.is_constant(&acir_var) {
warnings.push(SsaReport::Warning(InternalWarning::ReturnConstant {
call_stack: call_stack.clone(),
}));
}
self.acir_context.return_var(acir_var)?;
if !is_databus {
// We do not return value for the data bus.
self.acir_context.return_var(acir_var)?;
}
}
Ok(warnings)
}
Expand Down Expand Up @@ -2659,12 +2662,22 @@ impl<'a> Context<'a> {
&mut self,
arguments: &[ValueId],
dfg: &DataFlowGraph,
) -> Result<Vec<AcirVar>, InternalError> {
) -> Result<Vec<(AcirVar, bool)>, InternalError> {
let mut acir_vars = Vec::with_capacity(arguments.len());
for value_id in arguments {
let is_databus = if let Some(return_databus) = self.data_bus.return_data {
dfg[*value_id] == dfg[return_databus]
} else {
false
};
let value = self.convert_value(*value_id, dfg);
acir_vars.append(
&mut self.acir_context.flatten(value)?.iter().map(|(var, _)| *var).collect(),
&mut self
.acir_context
.flatten(value)?
.iter()
.map(|(var, _)| (*var, is_databus))
.collect(),
);
}
Ok(acir_vars)
Expand Down
10 changes: 9 additions & 1 deletion tooling/noirc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,15 @@ impl Abi {
.copied()
})
{
Some(decode_value(&mut return_witness_values.into_iter(), &return_type.abi_type)?)
// We do not return value for the data bus.
if return_type.visibility == AbiVisibility::DataBus {
None
} else {
Some(decode_value(
&mut return_witness_values.into_iter(),
&return_type.abi_type,
)?)
}
} else {
// Unlike for the circuit inputs, we tolerate not being able to find the witness values for the return value.
// This is because the user may be decoding a partial witness map for which is hasn't been calculated yet.
Expand Down
Loading