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

Support expiration policy #6833

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
688 changes: 391 additions & 297 deletions Cargo.lock

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,24 @@ fuel-abi-types = "0.7"
# Although ALL verions are "X.Y", we need the complete semver for
# fuel-core-client as the GitHub Actions workflow parses this value to pull down
# the correct tarball
fuel-core-client = { version = "0.40.0", default-features = false }
fuel-core-types = { version = "0.40", default-features = false }
fuel-core-client = { version = "0.40.2", default-features = false, git = "https://github.com/FuelLabs/fuel-core", branch = "add_zk_opcodes" }
fuel-core-types = { version = "0.40.2", default-features = false, git = "https://github.com/FuelLabs/fuel-core", branch = "add_zk_opcodes" }

# Dependencies from the `fuels-rs` repository:

fuels = "0.66.10"
fuels-core = "0.66.10"
fuels-accounts = "0.66.10"
fuels = { version = "0.66.10", git = "https://github.com/FuelLabs/fuels-rs/", branch = "feature/zk-opcodes" }
fuels-core = { version = "0.66.10", git = "https://github.com/FuelLabs/fuels-rs/", branch = "feature/zk-opcodes" }
fuels-accounts = { version = "0.66.10", git = "https://github.com/FuelLabs/fuels-rs/", branch = "feature/zk-opcodes" }

# Dependencies from the `fuel-vm` repository:
fuel-asm = "0.58"
fuel-crypto = "0.58"
fuel-types = "0.58"
fuel-tx = "0.58"
fuel-vm = "0.58"
fuel-asm = "0.59.1"
fuel-crypto = "0.59.1"
fuel-types = "0.59.1"
fuel-tx = "0.59.1"
fuel-vm = "0.59.1"

# Dependencies from the `forc-wallet` repository:
forc-wallet = "0.11"
forc-wallet = { version = "0.11", git = "https://github.com/FuelLabs/forc-wallet/", branch = "feature/zk-opcodes" }

#
# External dependencies
Expand Down
1 change: 1 addition & 0 deletions forc-plugins/forc-client/src/op/run/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use fuels::{
transaction_builders::{BuildableTransaction, VariableOutputPolicy},
},
};
use fuels_accounts::ViewOnlyAccount;
use fuels_accounts::{provider::Provider, Account};
use pkg::BuiltPackage;
use std::time::Duration;
Expand Down
42 changes: 21 additions & 21 deletions forc-plugins/forc-client/src/util/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,15 @@ pub enum ForcClientAccount {
KmsSigner(AwsSigner),
}

#[async_trait]
impl Account for ForcClientAccount {
async fn get_asset_inputs_for_amount(
&self,
asset_id: AssetId,
amount: u64,
excluded_coins: Option<Vec<CoinTypeId>>,
) -> Result<Vec<Input>> {
match self {
ForcClientAccount::Wallet(wallet) => {
wallet
.get_asset_inputs_for_amount(asset_id, amount, excluded_coins)
.await
}
ForcClientAccount::KmsSigner(account) => {
account
.get_asset_inputs_for_amount(asset_id, amount, excluded_coins)
.await
}
}
}

fn add_witnesses<Tb: TransactionBuilder>(&self, tb: &mut Tb) -> Result<()> {
tb.add_signer(self.clone())?;

Ok(())
}
}

#[async_trait]
impl ViewOnlyAccount for ForcClientAccount {
fn address(&self) -> &Bech32Address {
match self {
Expand All @@ -67,6 +47,26 @@ impl ViewOnlyAccount for ForcClientAccount {
ForcClientAccount::KmsSigner(account) => Ok(account.provider()),
}
}

async fn get_asset_inputs_for_amount(
&self,
asset_id: AssetId,
amount: u64,
excluded_coins: Option<Vec<CoinTypeId>>,
) -> Result<Vec<Input>> {
match self {
ForcClientAccount::Wallet(wallet) => {
wallet
.get_asset_inputs_for_amount(asset_id, amount, excluded_coins)
.await
}
ForcClientAccount::KmsSigner(account) => {
account
.get_asset_inputs_for_amount(asset_id, amount, excluded_coins)
.await
}
}
}
}

#[async_trait]
Expand Down
6 changes: 3 additions & 3 deletions forc-plugins/forc-client/src/util/aws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ impl Signer for AwsSigner {
}
}

#[async_trait]
impl ViewOnlyAccount for AwsSigner {
fn address(&self) -> &Bech32Address {
&self.bech
Expand All @@ -249,10 +250,7 @@ impl ViewOnlyAccount for AwsSigner {
fn try_provider(&self) -> Result<&Provider> {
Ok(&self.provider)
}
}

#[async_trait]
impl Account for AwsSigner {
async fn get_asset_inputs_for_amount(
&self,
asset_id: AssetId,
Expand All @@ -267,3 +265,5 @@ impl Account for AwsSigner {
.collect::<Vec<Input>>())
}
}

impl Account for AwsSigner {}
1 change: 1 addition & 0 deletions forc-test/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ impl TestExecutor {
gas_price,
consensus_params.gas_costs(),
consensus_params.fee_params(),
None,
)
.map_err(|e| anyhow::anyhow!("{e:?}"))?;

Expand Down
4 changes: 2 additions & 2 deletions forc-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ impl PackageWithDeploymentToTest {
.map(|(contract_id, tx)| {
// Transact the deployment transaction constructed for this contract dependency.
let tx = tx
.into_ready(gas_price, params.gas_costs(), params.fee_params())
.into_ready(gas_price, params.gas_costs(), params.fee_params(), None)
.unwrap();
interpreter.transact(tx).map_err(anyhow::Error::msg)?;
Ok(contract_id)
Expand All @@ -247,7 +247,7 @@ impl PackageWithDeploymentToTest {
&params,
);
let root_contract_tx = root_contract_tx
.into_ready(gas_price, params.gas_costs(), params.fee_params())
.into_ready(gas_price, params.gas_costs(), params.fee_params(), None)
.unwrap();
// Deploy the root contract.
interpreter
Expand Down
2 changes: 2 additions & 0 deletions sway-ast/src/expr/op_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ define_op_codes!(
(Ed19, Ed19Opcode, "ed19", (addr: reg, sig: reg, hash: reg, len: reg)),
(K256, K256Opcode, "k256", (addr: reg, data: reg, size: reg)),
(S256, S256Opcode, "s256", (addr: reg, data: reg, size: reg)),
(ECOP, ECOPOpcode, "ecop", (dst_addr: reg, curve: reg, operation: reg, src_addr: reg)),
(EPAR, EPAROpcode, "epar", (ret: reg, curve: reg, groups_of_points: reg, addr: reg)),
/* Other Instructions */
(Flag, FlagOpcode, "flag", (value: reg)),
(Gm, GmOpcode, "gm", (ret: reg, op: imm)),
Expand Down
2 changes: 2 additions & 0 deletions sway-core/src/asm_generation/finalized_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,8 @@ fn print_instruction(op: &Instruction) {
Instruction::ECAL(x) => f("ECAL", x.unpack()),
Instruction::BSIZ(x) => f("BSIZ", x.unpack()),
Instruction::BLDD(x) => f("BLDD", x.unpack()),
Instruction::ECOP(x) => f("ECOP", x.unpack()),
Instruction::EPAR(x) => f("EPAR", x.unpack()),
}
}

Expand Down
22 changes: 22 additions & 0 deletions sway-core/src/asm_lang/allocated_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,18 @@ pub(crate) enum AllocatedOpcode {
),
K256(AllocatedRegister, AllocatedRegister, AllocatedRegister),
S256(AllocatedRegister, AllocatedRegister, AllocatedRegister),
ECOP(
AllocatedRegister,
AllocatedRegister,
AllocatedRegister,
AllocatedRegister,
),
EPAR(
AllocatedRegister,
AllocatedRegister,
AllocatedRegister,
AllocatedRegister,
),

/* Other Instructions */
FLAG(AllocatedRegister),
Expand Down Expand Up @@ -392,6 +404,8 @@ impl AllocatedOpcode {
ED19(_r1, _r2, _r3, _r4) => vec![],
K256(_r1, _r2, _r3) => vec![],
S256(_r1, _r2, _r3) => vec![],
ECOP(_r1, _r2, _r3, _r4) => vec![],
EPAR(r1, _r2, _r3, _r4) => vec![r1],

/* Other Instructions */
FLAG(_r1) => vec![],
Expand Down Expand Up @@ -521,6 +535,8 @@ impl fmt::Display for AllocatedOpcode {
ED19(a, b, c, d) => write!(fmtr, "ed19 {a} {b} {c} {d}"),
K256(a, b, c) => write!(fmtr, "k256 {a} {b} {c}"),
S256(a, b, c) => write!(fmtr, "s256 {a} {b} {c}"),
ECOP(a, b, c, d) => write!(fmtr, "ecop {a} {b} {c} {d}"),
EPAR(a, b, c, d) => write!(fmtr, "epar {a} {b} {c} {d}"),

/* Other Instructions */
FLAG(a) => write!(fmtr, "flag {a}"),
Expand Down Expand Up @@ -731,6 +747,12 @@ impl AllocatedOp {
}
K256(a, b, c) => op::K256::new(a.to_reg_id(), b.to_reg_id(), c.to_reg_id()).into(),
S256(a, b, c) => op::S256::new(a.to_reg_id(), b.to_reg_id(), c.to_reg_id()).into(),
ECOP(a, b, c, d) => {
op::ECOP::new(a.to_reg_id(), b.to_reg_id(), c.to_reg_id(), d.to_reg_id()).into()
}
EPAR(a, b, c, d) => {
op::EPAR::new(a.to_reg_id(), b.to_reg_id(), c.to_reg_id(), d.to_reg_id()).into()
}

/* Other Instructions */
FLAG(a) => op::FLAG::new(a.to_reg_id()).into(),
Expand Down
10 changes: 10 additions & 0 deletions sway-core/src/asm_lang/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,14 @@ impl Op {
let (r1, r2, r3) = three_regs(handler, args, immediate, whole_op_span)?;
VirtualOp::S256(r1, r2, r3)
}
"ecop" => {
let (r1, r2, r3, r4) = four_regs(handler, args, immediate, whole_op_span)?;
VirtualOp::ECOP(r1, r2, r3, r4)
}
"epar" => {
let (r1, r2, r3, r4) = four_regs(handler, args, immediate, whole_op_span)?;
VirtualOp::EPAR(r1, r2, r3, r4)
}

/* Other Instructions */
"flag" => {
Expand Down Expand Up @@ -1239,6 +1247,8 @@ impl fmt::Display for VirtualOp {
ED19(a, b, c, d) => write!(fmtr, "ed19 {a} {b} {c} {d}"),
K256(a, b, c) => write!(fmtr, "k256 {a} {b} {c}"),
S256(a, b, c) => write!(fmtr, "s256 {a} {b} {c}"),
ECOP(a, b, c, d) => write!(fmtr, "ecop {a} {b} {c} {d}"),
EPAR(a, b, c, d) => write!(fmtr, "epar {a} {b} {c} {d}"),

/* Other Instructions */
FLAG(a) => write!(fmtr, "flag {a}"),
Expand Down
46 changes: 46 additions & 0 deletions sway-core/src/asm_lang/virtual_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,18 @@ pub(crate) enum VirtualOp {
),
K256(VirtualRegister, VirtualRegister, VirtualRegister),
S256(VirtualRegister, VirtualRegister, VirtualRegister),
ECOP(
VirtualRegister,
VirtualRegister,
VirtualRegister,
VirtualRegister,
),
EPAR(
VirtualRegister,
VirtualRegister,
VirtualRegister,
VirtualRegister,
),

/* Other Instructions */
FLAG(VirtualRegister),
Expand Down Expand Up @@ -339,6 +351,8 @@ impl VirtualOp {
ED19(r1, r2, r3, r4) => vec![r1, r2, r3, r4],
K256(r1, r2, r3) => vec![r1, r2, r3],
S256(r1, r2, r3) => vec![r1, r2, r3],
ECOP(r1, r2, r3, r4) => vec![r1, r2, r3, r4],
EPAR(r1, r2, r3, r4) => vec![r1, r2, r3, r4],

/* Other Instructions */
FLAG(r1) => vec![r1],
Expand Down Expand Up @@ -407,6 +421,7 @@ impl VirtualOp {
| TIME(_, _)
| GM(_, _)
| GTF(_, _, _)
| EPAR(_, _, _, _)
// Virtual OPs
| LoadDataId(_, _)
| AddrDataId(_, _)
Expand Down Expand Up @@ -463,6 +478,7 @@ impl VirtualOp {
| ED19(_, _, _, _)
| K256(_, _, _)
| S256(_, _, _)
| ECOP(_, _, _, _)
| FLAG(_)
// Virtual OPs
| BLOB(_)
Expand Down Expand Up @@ -570,6 +586,8 @@ impl VirtualOp {
| TRO(_, _, _, _)
| K256(_, _, _)
| S256(_, _, _)
| ECOP(_, _, _, _)
| EPAR(_, _, _, _)
| GM(_, _)
| GTF(_, _, _)
| BLOB(_)
Expand Down Expand Up @@ -687,6 +705,8 @@ impl VirtualOp {
ED19(r1, r2, r3, r4) => vec![r1, r2, r3, r4],
K256(r1, r2, r3) => vec![r1, r2, r3],
S256(r1, r2, r3) => vec![r1, r2, r3],
ECOP(r1, r2, r3, r4) => vec![r1, r2, r3, r4],
EPAR(_r1, r2, r3, r4) => vec![r2, r3, r4],

/* Other Instructions */
FLAG(r1) => vec![r1],
Expand Down Expand Up @@ -809,6 +829,8 @@ impl VirtualOp {
ED19(_r1, _r2, _r3, _r4) => vec![],
K256(_r1, _r2, _r3) => vec![],
S256(_r1, _r2, _r3) => vec![],
ECOP(_r1, _r2, _r3, _r4) => vec![],
EPAR(r1, _r2, _r3, _r4) => vec![r1],

/* Other Instructions */
FLAG(_r1) => vec![],
Expand Down Expand Up @@ -1256,6 +1278,18 @@ impl VirtualOp {
update_reg(reg_to_reg_map, r2),
update_reg(reg_to_reg_map, r3),
),
ECOP(r1, r2, r3, r4) => Self::ECOP(
update_reg(reg_to_reg_map, r1),
update_reg(reg_to_reg_map, r2),
update_reg(reg_to_reg_map, r3),
update_reg(reg_to_reg_map, r4),
),
EPAR(r1, r2, r3, r4) => Self::EPAR(
update_reg(reg_to_reg_map, r1),
update_reg(reg_to_reg_map, r2),
update_reg(reg_to_reg_map, r3),
update_reg(reg_to_reg_map, r4),
),

/* Other Instructions */
FLAG(r1) => Self::FLAG(update_reg(reg_to_reg_map, r1)),
Expand Down Expand Up @@ -1737,6 +1771,18 @@ impl VirtualOp {
map_reg(&mapping, reg2),
map_reg(&mapping, reg3),
),
ECOP(reg1, reg2, reg3, reg4) => AllocatedOpcode::ECOP(
map_reg(&mapping, reg1),
map_reg(&mapping, reg2),
map_reg(&mapping, reg3),
map_reg(&mapping, reg4),
),
EPAR(reg1, reg2, reg3, reg4) => AllocatedOpcode::EPAR(
map_reg(&mapping, reg1),
map_reg(&mapping, reg2),
map_reg(&mapping, reg3),
map_reg(&mapping, reg4),
),

/* Other Instructions */
FLAG(reg) => AllocatedOpcode::FLAG(map_reg(&mapping, reg)),
Expand Down
Loading
Loading