Skip to content

Commit

Permalink
fix: use entrypoint instead of pay_init_fee
Browse files Browse the repository at this point in the history
  • Loading branch information
alexghr committed Apr 9, 2024
1 parent 6191313 commit 1e46b00
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 5 deletions.
2 changes: 1 addition & 1 deletion l1-contracts/src/core/libraries/ConstantsGen.sol
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ library Constants {
uint256 internal constant DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE =
0x85864497636cf755ae7bde03f267ce01a520981c21c3682aaf82a631;
uint256 internal constant DEPLOYER_CONTRACT_ADDRESS =
0x12bcd3e09e8d8559c75d59552db47471f63c72fbbc9decb59c517b4e58634a72;
0x23fb38e0a3ddf4840e582ee7a9eb0ccbc858d415c140bd0bac26bb0c761c83fc;
uint256 internal constant L1_TO_L2_MESSAGE_ORACLE_CALL_LENGTH = 17;
uint256 internal constant MAX_NOTE_FIELDS_LENGTH = 20;
uint256 internal constant GET_NOTE_ORACLE_RETURN_LENGTH = 23;
Expand Down
31 changes: 31 additions & 0 deletions noir-projects/aztec-nr/aztec/src/context/private_context.nr
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ impl PrivateContext {
chain_id: self.inputs.private_global_variables.chain_id,
version: self.inputs.private_global_variables.version
};

crate::oracle::debug_log::debug_log_format(
"Finished private context with {0} note hash read requests",
[self.note_hash_read_requests.len() as Field]
);

priv_circuit_pub_inputs
}

Expand All @@ -199,6 +205,12 @@ impl PrivateContext {
}

pub fn push_note_hash_read_request(&mut self, note_hash: Field) {
crate::oracle::debug_log::debug_log_format(
"Pushing note hash read request for note_hash={0} counter={1} len={2}",
[
note_hash, self.side_effect_counter as Field, (self.note_hash_read_requests.len() as Field) + 1
]
);
let side_effect = SideEffect { value: note_hash, counter: self.side_effect_counter };
self.note_hash_read_requests.push(side_effect);
self.side_effect_counter = self.side_effect_counter + 1;
Expand Down Expand Up @@ -343,6 +355,25 @@ impl PrivateContext {
is_delegate_call
);

let mut note_hash_read_req_count = 0;
for i in 0..MAX_NOTE_HASH_READ_REQUESTS_PER_CALL {
if !is_empty(item.public_inputs.note_hash_read_requests[i]) {
note_hash_read_req_count = note_hash_read_req_count + 1;
}
}

crate::oracle::debug_log::debug_log_format(
"Called private function got back contract_address={0} function_data={1} public_inputs={2} note_hash_read_reqs={3}",
[
item.contract_address.to_field(), item.function_data.hash(), item.public_inputs.hash(), note_hash_read_req_count
]
);

// crate::oracle::debug_log::debug_log_array_with_prefix(
// "Called private function public inputs",
// item.public_inputs.serialize()
// );

assert_eq(item.public_inputs.call_context.side_effect_counter, self.side_effect_counter);
assert_eq(item.public_inputs.start_side_effect_counter, self.side_effect_counter);
self.side_effect_counter = item.public_inputs.end_side_effect_counter + 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ global REGISTERER_UNCONSTRAINED_FUNCTION_BROADCASTED_MAGIC_VALUE = 0xe7af8166354
// CONTRACT INSTANCE CONSTANTS
// sha224sum 'struct ContractInstanceDeployed'
global DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE = 0x85864497636cf755ae7bde03f267ce01a520981c21c3682aaf82a631;
global DEPLOYER_CONTRACT_ADDRESS = 0x12bcd3e09e8d8559c75d59552db47471f63c72fbbc9decb59c517b4e58634a72;
global DEPLOYER_CONTRACT_ADDRESS = 0x23fb38e0a3ddf4840e582ee7a9eb0ccbc858d415c140bd0bac26bb0c761c83fc;

// NOIR CONSTANTS - constants used only in yarn-packages/noir-contracts
// Some are defined here because Noir doesn't yet support globals referencing other globals yet.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,21 @@ export class DeployAccountMethod extends DeployMethod {

if (options.fee && this.#feePaymentArtifact) {
const { address } = this.getInstance();
const emptyAppPayload = EntrypointPayload.fromAppExecution([]);
const feePayload = await EntrypointPayload.fromFeeOptions(options?.fee);

exec.calls.push({
to: address,
args: encodeArguments(this.#feePaymentArtifact, [feePayload]),
args: encodeArguments(this.#feePaymentArtifact, [emptyAppPayload, feePayload]),
functionData: FunctionData.fromAbi(this.#feePaymentArtifact),
});

exec.authWitnesses ??= [];
exec.packedArguments ??= [];

exec.authWitnesses.push(await this.#authWitnessProvider.createAuthWit(emptyAppPayload.hash()));
exec.authWitnesses.push(await this.#authWitnessProvider.createAuthWit(feePayload.hash()));
exec.packedArguments.push(...emptyAppPayload.packedArguments);
exec.packedArguments.push(...feePayload.packedArguments);

options.fee = undefined;
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec.js/src/account_manager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export class AccountManager {
this.accountContract.getContractArtifact(),
args,
'constructor',
'pay_init_fee',
'entrypoint',
);
}
return this.deployMethod;
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/circuits.js/src/constants.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const REGISTERER_UNCONSTRAINED_FUNCTION_BROADCASTED_MAGIC_VALUE =
0xe7af816635466f128568edb04c9fa024f6c87fb9010fdbffa68b3d99n;
export const DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE =
0x85864497636cf755ae7bde03f267ce01a520981c21c3682aaf82a631n;
export const DEPLOYER_CONTRACT_ADDRESS = 0x12bcd3e09e8d8559c75d59552db47471f63c72fbbc9decb59c517b4e58634a72n;
export const DEPLOYER_CONTRACT_ADDRESS = 0x23fb38e0a3ddf4840e582ee7a9eb0ccbc858d415c140bd0bac26bb0c761c83fcn;
export const L1_TO_L2_MESSAGE_ORACLE_CALL_LENGTH = 17;
export const MAX_NOTE_FIELDS_LENGTH = 20;
export const GET_NOTE_ORACLE_RETURN_LENGTH = 23;
Expand Down
10 changes: 10 additions & 0 deletions yarn-project/simulator/src/client/client_execution_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,16 @@ export class ClientExecutionContext extends ViewDataOracle {

this.nestedExecutions.push(childExecutionResult);

const ci = childExecutionResult.callStackItem;
this.log(`Called private function and got back call stack item with hashes:
Contract address=${ci.contractAddress.toString()}
Function data=${ci.functionData.hash().toString()}
Public inputs=${ci.publicInputs.hash().toString()}
Count of note hash read requests=${ci.publicInputs.noteHashReadRequests.filter(x => !x.isEmpty()).length}
`);

// this.log(`Called private function public inputs: ${ci.publicInputs.toFields().map(f => f.toString())}`);

return childExecutionResult.callStackItem;
}

Expand Down

0 comments on commit 1e46b00

Please sign in to comment.