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

fix: use entrypoint instead of pay_init_fee #5623

Merged
merged 4 commits into from
Apr 15, 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
10 changes: 0 additions & 10 deletions noir-projects/aztec-nr/authwit/src/account.nr
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,6 @@ impl AccountActions {
}
// docs:end:entrypoint

pub fn pay_init_fee(self, fee_payload: FeePayload) {
let valid_fn = self.is_valid_impl;
let mut private_context = self.context.private.unwrap();

let fee_hash = fee_payload.hash();
assert(valid_fn(private_context, fee_hash));
fee_payload.execute_calls(private_context);
private_context.capture_min_revertible_side_effect_counter();
}

// docs:start:spend_private_authwit
pub fn spend_private_authwit(self, inner_hash: Field) -> Field {
let context = self.context.private.unwrap();
Expand Down
6 changes: 3 additions & 3 deletions noir-projects/aztec-nr/aztec/src/context/private_context.nr
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ use dep::protocol_types::{
},
contrakt::{storage_read::StorageRead, storage_update_request::StorageUpdateRequest},
grumpkin_private_key::GrumpkinPrivateKey, header::Header,
messaging::l2_to_l1_message::L2ToL1Message, utils::reader::Reader, traits::{is_empty, Deserialize, Empty}
messaging::l2_to_l1_message::L2ToL1Message, utils::reader::Reader,
traits::{is_empty, Deserialize, Empty}
};

// TODO(https://github.com/AztecProtocol/aztec-packages/issues/1165)
Expand Down Expand Up @@ -189,6 +190,7 @@ impl PrivateContext {
chain_id: self.inputs.private_global_variables.chain_id,
version: self.inputs.private_global_variables.version
};

priv_circuit_pub_inputs
}

Expand Down Expand Up @@ -387,8 +389,6 @@ impl PrivateContext {
);
}

// crate::oracle::debug_log::debug_log_array_with_prefix("Private call stack item", item.serialize());

self.private_call_stack_hashes.push(item.hash());

PackedReturns::new(item.public_inputs.returns_hash)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@ contract EcdsaAccount {
actions.entrypoint(app_payload, fee_payload);
}

#[aztec(private)]
#[aztec(noinitcheck)]
fn pay_init_fee(fee_payload: pub FeePayload) {
let actions = AccountActions::private(&mut context, ACCOUNT_ACTIONS_STORAGE_SLOT, is_valid_impl);
actions.pay_init_fee(fee_payload);
}

#[aztec(private)]
#[aztec(noinitcheck)]
fn spend_private_authwit(inner_hash: Field) -> Field {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,6 @@ contract SchnorrAccount {
actions.entrypoint(app_payload, fee_payload);
}

#[aztec(private)]
#[aztec(noinitcheck)]
fn pay_init_fee(fee_payload: pub FeePayload) {
let actions = AccountActions::private(
&mut context,
storage.approved_actions.storage_slot,
is_valid_impl
);
actions.pay_init_fee(fee_payload);
}

#[aztec(private)]
#[aztec(noinitcheck)]
fn spend_private_authwit(inner_hash: Field) -> Field {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ contract SchnorrHardcodedAccount {
actions.entrypoint(app_payload, fee_payload);
}

#[aztec(private)]
fn pay_init_fee(fee_payload: pub FeePayload) {
let actions = AccountActions::private(&mut context, ACCOUNT_ACTIONS_STORAGE_SLOT, is_valid_impl);
actions.pay_init_fee(fee_payload);
}

#[aztec(private)]
fn spend_private_authwit(inner_hash: Field) -> Field {
let actions = AccountActions::private(&mut context, ACCOUNT_ACTIONS_STORAGE_SLOT, is_valid_impl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ contract SchnorrSingleKeyAccount {
actions.entrypoint(app_payload, fee_payload);
}

#[aztec(private)]
fn pay_init_fee(fee_payload: pub FeePayload) {
let actions = AccountActions::private(&mut context, ACCOUNT_ACTIONS_STORAGE_SLOT, is_valid_impl);
actions.pay_init_fee(fee_payload);
}

#[aztec(private)]
fn spend_private_authwit(inner_hash: Field) -> Field {
let actions = AccountActions::private(&mut context, ACCOUNT_ACTIONS_STORAGE_SLOT, is_valid_impl);
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);
}

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 @@ -148,7 +148,7 @@ export class AccountManager {
this.accountContract.getContractArtifact(),
args,
'constructor',
'pay_init_fee',
'entrypoint',
);
}
return this.deployMethod;
Expand Down
Loading