From 35ab836c0f4d18326c388031d816e5deef6f081a Mon Sep 17 00:00:00 2001 From: Eugene Kovalev Date: Wed, 22 Jan 2025 00:32:24 +0100 Subject: [PATCH] Undo changes to the node, mock the runtime interface --- Cargo.lock | 5 -- Cargo.toml | 2 - node/ark/Cargo.toml | 15 ------ node/ark/src/lib.rs | 101 ----------------------------------- runtime-interface/Cargo.toml | 3 -- runtime-interface/src/lib.rs | 20 +------ utils/crates-io/src/lib.rs | 1 - 7 files changed, 2 insertions(+), 145 deletions(-) delete mode 100644 node/ark/Cargo.toml delete mode 100644 node/ark/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 9c8fa5b37a8..fc421a55ed8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5907,10 +5907,6 @@ dependencies = [ "hex-literal", ] -[[package]] -name = "gear-ark" -version = "1.7.0" - [[package]] name = "gear-authorship" version = "1.7.0" @@ -6359,7 +6355,6 @@ dependencies = [ "ark-ff 0.4.2", "ark-scale", "byteorder", - "gear-ark", "gear-core", "gear-lazy-pages", "gear-lazy-pages-common", diff --git a/Cargo.toml b/Cargo.toml index 9c820a41c5d..06f4ee0a4ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -103,7 +103,6 @@ members = [ "node/service", "node/authorship", "node/testing", - "node/ark", "pallets/*", "runtime/*", "runtime-interface/sandbox", @@ -240,7 +239,6 @@ gtest = { path = "gtest" } gmeta = { path = "gmeta" } gmeta-codegen = { path = "gmeta/codegen" } gprimitives = { path = "gprimitives", default-features = false } -gear-ark = { path = "node/ark" } gear-authorship = { path = "node/authorship" } gear-core-backend = { path = "core-backend", default-features = false } gear-call-gen = { path = "utils/call-gen" } diff --git a/node/ark/Cargo.toml b/node/ark/Cargo.toml deleted file mode 100644 index fac3af1c80a..00000000000 --- a/node/ark/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -name = "gear-ark" -description = "Host primitives for supported Argument of Knowledge systems" -documentation = "https://docs.rs/gear-ark" -edition.workspace = true -version.workspace = true -authors.workspace = true -license.workspace = true -homepage.workspace = true -repository.workspace = true -rust-version.workspace = true - -[features] -default = ["std"] -std = [] diff --git a/node/ark/src/lib.rs b/node/ark/src/lib.rs deleted file mode 100644 index d091d7915c8..00000000000 --- a/node/ark/src/lib.rs +++ /dev/null @@ -1,101 +0,0 @@ -// This file is part of Gear. - -// Copyright (C) 2021-2024 Gear Technologies Inc. -// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -//! Mock definitions and implementations for Goldilocs field and Poseidon hash - -pub mod field { - pub mod goldilocks_field { - use super::types::{Field, PrimeField64}; - use crate::hash::poseidon::Poseidon; - - use core::fmt::{self, Debug, Display, Formatter}; - - #[derive(Copy, Clone, Default)] - #[repr(transparent)] - pub struct GoldilocksField(pub u64); - - impl Display for GoldilocksField { - fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - Display::fmt(&self.to_canonical_u64(), f) - } - } - - impl Debug for GoldilocksField { - fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - Debug::fmt(&self.to_canonical_u64(), f) - } - } - - impl Field for GoldilocksField { - const ORDER: u64 = 0xFFFFFFFF00000001; - - #[inline(always)] - fn from_canonical_u64(n: u64) -> Self { - debug_assert!(n < Self::ORDER); - Self(n) - } - } - - impl PrimeField64 for GoldilocksField { - #[inline] - fn to_canonical_u64(&self) -> u64 { - let mut c = self.0; - // We only need one condition subtraction, since 2 * ORDER would not fit in a u64. - if c >= Self::ORDER { - c -= Self::ORDER; - } - c - } - } - - impl Poseidon for GoldilocksField {} - } - - pub mod types { - pub trait Field { - const ORDER: u64; - - fn from_canonical_u64(n: u64) -> Self; - } - - pub trait PrimeField64 { - fn to_canonical_u64(&self) -> u64; - } - } -} - -pub mod hash { - pub mod poseidon { - pub const SPONGE_RATE: usize = 8; - pub const SPONGE_CAPACITY: usize = 4; - pub const SPONGE_WIDTH: usize = SPONGE_RATE + SPONGE_CAPACITY; - - use crate::field::types::PrimeField64; - - pub trait Poseidon: PrimeField64 { - // Mocked default implementation: does nothing. - #[inline] - fn poseidon(input: [Self; SPONGE_WIDTH]) -> [Self; SPONGE_WIDTH] - where - Self: Sized, - { - input - } - } - } -} diff --git a/runtime-interface/Cargo.toml b/runtime-interface/Cargo.toml index 7d1f021a916..b59f907c222 100644 --- a/runtime-interface/Cargo.toml +++ b/runtime-interface/Cargo.toml @@ -15,7 +15,6 @@ gear-core.workspace = true gear-lazy-pages-common.workspace = true gear-lazy-pages = { workspace = true, optional = true } gear-sandbox-interface.workspace = true -gear-ark = { workspace = true, optional = true } sp-io.workspace = true sp-runtime-interface.workspace = true @@ -54,6 +53,4 @@ std = [ "ark-ff/std", "ark-scale/std", "sha2/std", - - "gear-ark/std", ] diff --git a/runtime-interface/src/lib.rs b/runtime-interface/src/lib.rs index c29e6a26eda..1633dd0de5d 100644 --- a/runtime-interface/src/lib.rs +++ b/runtime-interface/src/lib.rs @@ -45,13 +45,6 @@ use { }, ark_ff::fields::field_hashers::DefaultFieldHasher, ark_scale::ArkScale, - gear_ark::{ - field::{ - goldilocks_field::GoldilocksField, - types::{Field, PrimeField64}, - }, - hash::poseidon::Poseidon, - }, gear_lazy_pages::LazyPagesStorage, }; @@ -422,16 +415,7 @@ pub trait GearBls12_381 { #[runtime_interface] pub trait GearPoseidonHash { - fn poseidon(input: Vec) -> Vec { - let data: [GoldilocksField; 12] = input - .into_iter() - .map(GoldilocksField::from_canonical_u64) - .collect::>() - .try_into() - .expect("Expect input to be of length 12"); - - let hash = ::poseidon(data); - - hash.iter().map(|x| x.to_canonical_u64()).collect() + fn poseidon(_input: Vec) -> Vec { + unimplemented!("Comes in a separate PR") } } diff --git a/utils/crates-io/src/lib.rs b/utils/crates-io/src/lib.rs index a53aee3edf8..a5d653becea 100644 --- a/utils/crates-io/src/lib.rs +++ b/utils/crates-io/src/lib.rs @@ -82,7 +82,6 @@ pub const STACKED_DEPENDENCIES: &[&str] = &[ "gear-lazy-pages-common", "gear-lazy-pages", "gear-sandbox-interface", - "gear-ark", "gear-runtime-interface", "gear-sandbox", "gear-core-backend",