Skip to content

Commit

Permalink
chore(contracts): migrate all contracts to use the AVM
Browse files Browse the repository at this point in the history
  • Loading branch information
dbanks12 authored and fcarreiro committed May 8, 2024
1 parent 73a75b5 commit b74ede5
Show file tree
Hide file tree
Showing 21 changed files with 315 additions and 807 deletions.
2 changes: 1 addition & 1 deletion avm-transpiler/src/transpile_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl From<CompiledAcirContract> for TranspiledContract {
// TODO(4269): once functions are tagged for transpilation to AVM, check tag
if function
.custom_attributes
.contains(&"aztec(public-vm)".to_string())
.contains(&"aztec(public)".to_string())
{
info!(
"Transpiling AVM function {} on contract {}",
Expand Down
15 changes: 4 additions & 11 deletions noir-projects/aztec-nr/aztec/src/context.nr
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,33 @@ mod inputs;

mod private_context;
mod public_context;
mod avm_context;
mod interface;
mod gas;

use interface::{
ContextInterface, PrivateCallInterface, PublicCallInterface, PrivateVoidCallInterface,
PublicVoidCallInterface, AvmCallInterface, AvmVoidCallInterface
PublicVoidCallInterface
};
use private_context::PrivateContext;
use private_context::PackedReturns;
use public_context::PublicContext;
use public_context::FunctionReturns;
use avm_context::AvmContext;

struct Context {
private: Option<&mut PrivateContext>,
public: Option<&mut PublicContext>,
avm: Option<&mut AvmContext>,
}

impl Context {
pub fn private(context: &mut PrivateContext) -> Context {
Context { private: Option::some(context), public: Option::none(), avm: Option::none() }
Context { private: Option::some(context), public: Option::none() }
}

pub fn public(context: &mut PublicContext) -> Context {
Context { public: Option::some(context), private: Option::none(), avm: Option::none() }
}

pub fn avm(context: &mut AvmContext) -> Context {
Context { avm: Option::some(context), public: Option::none(), private: Option::none() }
Context { public: Option::some(context), private: Option::none() }
}

pub fn none() -> Context {
Context { public: Option::none(), private: Option::none(), avm: Option::none() }
Context { public: Option::none(), private: Option::none() }
}
}
281 changes: 0 additions & 281 deletions noir-projects/aztec-nr/aztec/src/context/avm_context.nr

This file was deleted.

2 changes: 0 additions & 2 deletions noir-projects/aztec-nr/aztec/src/context/inputs.nr
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
mod private_context_inputs;
mod public_context_inputs;
mod avm_context_inputs;

use crate::context::inputs::private_context_inputs::PrivateContextInputs;
use crate::context::inputs::public_context_inputs::PublicContextInputs;
use crate::context::inputs::avm_context_inputs::AvmContextInputs;

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct PrivateContextInputs {
impl Empty for PrivateContextInputs {
fn empty() -> Self {
PrivateContextInputs {
call_context : CallContext::empty(),
call_context: CallContext::empty(),
historical_header: Header::empty(),
tx_context: TxContext::empty(),
start_side_effect_counter: 0 as u32,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,15 @@
use crate::context::globals::public_global_variables::PublicGlobalVariables;
use dep::protocol_types::traits::Empty;

use dep::protocol_types::{abis::call_context::CallContext, abis::gas::Gas, header::Header, traits::Empty};

// PublicContextInputs are expected to be provided to each public function
// docs:start:public-context-inputs
struct PublicContextInputs {
call_context: CallContext,
historical_header: Header,

public_global_variables: PublicGlobalVariables,
start_side_effect_counter: u32,
gas_left: Gas,
transaction_fee: Field,
selector: Field,
args_hash: Field,
}
// docs:end:public-context-inputs

impl Empty for PublicContextInputs {
fn empty() -> Self {
PublicContextInputs {
call_context: CallContext::empty(),
historical_header: Header::empty(),
public_global_variables: PublicGlobalVariables::empty(),
start_side_effect_counter: 0 as u32,
gas_left: Gas::empty(),
transaction_fee: 0,
selector: 0,
args_hash: 0,
}
}
}
Loading

0 comments on commit b74ede5

Please sign in to comment.