Skip to content

Commit

Permalink
isa: use new GfaConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Mar 4, 2025
1 parent 5e61b4c commit 4364174
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 24 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions src/codex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

use aluvm::alu::regs::Status;
use aluvm::alu::{CoreConfig, CoreExt, Lib, LibId, LibSite, Vm};
use aluvm::{fe256, RegE};
use aluvm::{fe256, GfaConfig, RegE};
use amplify::confinement::{SmallVec, TinyOrdMap, TinyString};
use amplify::num::u256;
use amplify::Bytes32;
Expand Down Expand Up @@ -78,8 +78,9 @@ impl Codex {
}

// Phase one: get inputs, verify access conditions
let mut vm_inputs =
Vm::<aluvm::gfa::Instr<LibId>>::with(self.input_config, self.field_order);
let mut vm_inputs = Vm::<aluvm::gfa::Instr<LibId>>::with(self.input_config, GfaConfig {
field_order: self.field_order,
});
let mut read_once_input = SmallVec::new();
for input in &operation.destroying {
let cell = memory
Expand Down Expand Up @@ -130,7 +131,9 @@ impl Codex {
read_once_output: operation.destructible.as_slice(),
immutable_output: operation.immutable.as_slice(),
};
let mut vm_main = Vm::<Instr<LibId>>::with(self.verification_config, self.field_order);
let mut vm_main = Vm::<Instr<LibId>>::with(self.verification_config, GfaConfig {
field_order: self.field_order,
});
match vm_main.exec(*entry_point, &context, resolver) {
Status::Ok => Ok(()),
Status::Fail => {
Expand Down
5 changes: 2 additions & 3 deletions src/isa/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
use core::fmt::{self, Debug, Formatter};

use aluvm::alu::{CoreExt, NoExt, Register, Supercore};
use aluvm::{GfaCore, RegE};
use amplify::num::u256;
use aluvm::{GfaConfig, GfaCore, RegE};

#[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug, Display)]
enum Io {
Expand Down Expand Up @@ -93,7 +92,7 @@ impl Debug for UsonicCore {

impl CoreExt for UsonicCore {
type Reg = RegE;
type Config = u256;
type Config = GfaConfig;

fn with(config: Self::Config) -> Self { UsonicCore { ui: [0; 4], gfa: GfaCore::with(config) } }

Expand Down
15 changes: 0 additions & 15 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ mod contract;
pub mod stl;
mod util;

use amplify::num::u256;
pub use codex::{AccessId, CallError, CallId, Codex, CodexId, LibRepo, Memory, VmContext};
pub use contract::{Consensus, ConstU32, Contract, ContractId, ContractMeta, ContractName};
pub use isa::{Instr, IoCat, UsonicCore, UsonicInstr, ISA_ULTRASONIC};
Expand All @@ -60,17 +59,3 @@ pub use util::Identity;
pub use zkaluvm::fe256;

pub const LIB_NAME_ULTRASONIC: &str = "UltraSONIC";

pub const FIELD_ORDER_25519: u256 = u256::from_inner([
0xFFFF_FFFF_FFFF_FFEC,
0xFFFF_FFFF_FFFF_FFFF,
0xFFFF_FFFF_FFFF_FFFF,
0x8FFF_FFFF_FFFF_FFFF,
]);
pub const FIELD_ORDER_STARK: u256 = u256::from_inner([1, 0, 17, 0x0800_0000_0000_0000]);
pub const FIELD_ORDER_SECP: u256 = u256::from_inner([
0xFFFF_FFFE_FFFF_FC2E,
0xFFFF_FFFF_FFFF_FFFF,
0xFFFF_FFFF_FFFF_FFFF,
0xFFFF_FFFF_FFFF_FFFF,
]);

0 comments on commit 4364174

Please # to comment.