Skip to content

Instantly share code, notes, and snippets.

@aleph-v
Created September 3, 2019 16:15
Show Gist options
  • Save aleph-v/99d7a5e21a1c5a28567d0b3bc2514f3a to your computer and use it in GitHub Desktop.
Save aleph-v/99d7a5e21a1c5a28567d0b3bc2514f3a to your computer and use it in GitHub Desktop.
Compiling substrate-node v1.0.0 (/Users/pvienhage/dev/starkcrypto/substrate-node)
Compiling substrate-runtime v1.0.0 (/Users/pvienhage/dev/starkcrypto/substrate-runtime)
error[E0412]: cannot find type `Event` in this scope
--> substrate-runtime/src/exchange.rs:50:1
|
50 | / decl_module! {
51 | | /// The module declaration.
52 | | pub struct Module<T: Trait> for enum Call where origin: T::Origin {
53 | | // Initializing events
... |
225 | | }
226 | | }
| |_^ not found in this scope
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
help: possible candidates are found in other modules, you can import them into scope
|
5 | use balances::Event;
|
5 | use crate::Event;
|
5 | use crate::finality::Event;
|
5 | use indices::Event;
|
and 2 other candidates
error[E0576]: cannot find associated type `Event` in trait `Trait`
--> substrate-runtime/src/exchange.rs:50:1
|
50 | / decl_module! {
51 | | /// The module declaration.
52 | | pub struct Module<T: Trait> for enum Call where origin: T::Origin {
53 | | // Initializing events
... |
225 | | }
226 | | }
| |_^ not found in `Trait`
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
warning: unused import: `decl_event`
--> substrate-runtime/src/exchange.rs:14:5
|
14 | decl_event, decl_module, decl_storage, dispatch::Result, ensure, StorageMap, StorageValue,
| ^^^^^^^^^^
|
note: lint level defined here
--> substrate-runtime/src/lib.rs:16:5
|
16 | unused,
| ^^^^^^
= note: #[warn(unused_imports)] implied by #[warn(unused)]
warning: unused import: `macros_decl::hex`
--> substrate-runtime/src/finality.rs:2:5
|
2 | use macros_decl::hex;
| ^^^^^^^^^^^^^^^^
warning: unused import: `primefield::FieldElement`
--> substrate-runtime/src/finality.rs:4:5
|
4 | use primefield::FieldElement;
| ^^^^^^^^^^^^^^^^^^^^^^^^
warning: unused imports: `ChildrenStorageOverlay`, `StorageOverlay`, `with_storage`
--> substrate-runtime/src/finality.rs:7:18
|
7 | use runtime_io::{with_storage, ChildrenStorageOverlay, StorageOverlay};
| ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
warning: unused import: `BlakeTwo256`
--> substrate-runtime/src/finality.rs:8:34
|
8 | use runtime_primitives::traits::{BlakeTwo256, Hash};
| ^^^^^^^^^^^
warning: unused import: `ensure`
--> substrate-runtime/src/finality.rs:10:62
|
10 | decl_event, decl_module, decl_storage, dispatch::Result, ensure, StorageMap, StorageValue,
| ^^^^^^
warning: unused import: `ensure_root`
--> substrate-runtime/src/finality.rs:12:14
|
12 | use system::{ensure_root, ensure_signed};
| ^^^^^^^^^^^
warning: unused import: `u256::U256`
--> substrate-runtime/src/finality.rs:13:5
|
13 | use u256::U256;
| ^^^^^^^^^^
warning: type `num_validators` should have an upper camel case name
--> substrate-runtime/src/finality.rs:48:13
|
48 | pub num_validators: u32;
| ^^^^^^^^^^^^^^ help: convert the identifier to upper camel case: `NumValidators`
|
= note: #[warn(non_camel_case_types)] on by default
warning: type `__GetByteStructnum_validators` should have an upper camel case name
--> substrate-runtime/src/finality.rs:48:13
|
48 | pub num_validators: u32;
| ^^^^^^^^^^^^^^ help: convert the identifier to upper camel case: `GetByteStructnumValidators`
warning: unused import: `Hash`
--> substrate-runtime/src/finality.rs:8:47
|
8 | use runtime_primitives::traits::{BlakeTwo256, Hash};
| ^^^^
warning: unused import: `StorageValue`
--> substrate-runtime/src/finality.rs:10:82
|
10 | decl_event, decl_module, decl_storage, dispatch::Result, ensure, StorageMap, StorageValue,
| ^^^^^^^^^^^^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0412`.
error: Could not compile `substrate-runtime`.
To learn more, run the command again with --verbose.
use crate::wrappers::*;
use macros_decl::hex;
use parity_codec::{Encode, Decode};
use primefield::FieldElement;
use rstd::prelude::*;
#[cfg(feature = "std")]
use runtime_io::{with_storage, ChildrenStorageOverlay, StorageOverlay};
use runtime_primitives::traits::{BlakeTwo256, Hash};
use support::{
decl_event, decl_module, decl_storage, dispatch::Result, ensure, StorageMap, StorageValue,
};
use system::{ensure_root, ensure_signed};
use u256::U256;
use stark::{
check_proof,
fibonacci::{get_fibonacci_constraints, PublicInput},
ProofParams,
};
#[derive(PartialEq, Eq, Encode, Default, Clone, Decode)]
#[cfg_attr(feature = "std", derive(Debug))]
pub struct RecordedProof {
proof: Vec<u8>,
public: Vec<u8>,
}
// TODO - This really should be an enum but we can't use enums in substrate storage because of the required default derivation
// Status 0 - unproven, 1 - proven, 2 - finalized, 3 - disputed
#[derive(PartialEq, Encode, Default, Clone, Decode)]
#[cfg_attr(feature = "std", derive(Debug))]
pub struct LinkStatus {
hash: [u8; 32],
status: u32,
}
pub trait Trait: system::Trait {
type Event: From<Event> + Into<<Self as system::Trait>::Event>;
}
// TODO - May want successive random source for the pesudo random queries.
decl_storage! {
trait Store for Module<T: Trait> as FinalityProof {
pub HashChain : map u32 => LinkStatus;
pub Sigs: map (u32, T::AccountId) => Signature;
pub Validators: map T::AccountId => PublicKey;
pub FinalizedIndex: u32;
pub MaxIndex: u32;
pub num_validators: u32;
}
}
decl_module!{
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
fn deposit_event() = default;
pub fn prove_chain(origin, recorded: RecordedProof, start_index: u32, end_index: u32) -> Result {
ensure_signed(origin)?; //TODO - Do we need this? Do we want to lock to validators or add a cost?
let _start_hash = <HashChain<T>>::get(start_index);
let _end_hash = <HashChain<T>>::get(end_index);
//TODO - This will be sliced out for a starkdex proof.
let public : PublicInput = recorded.public.as_slice().into();
assert!(check_proof(
recorded.proof.as_slice(),
&get_fibonacci_constraints(&public),
&public,
// TODO - These params should be stored or provided instead of hardcoded
&ProofParams {
blowup: 16,
pow_bits: 12,
queries: 20,
fri_layout: vec![2, 3],
constraints_degree_bound: 1,
},
2,
1024
), "The block proof is invalid");
//We update the intermediary elements to say they are proven.
for i in start_index..end_index {
let mut chain_element = <HashChain<T>>::get(i);
chain_element.status = 1; // TODO - Enum here
<HashChain<T>>::insert(i, chain_element);
}
Self::deposit_event(Event::ProofRecorded(start_index, end_index, recorded));
Ok(())
}
}
}
decl_event!{
pub enum Event
{
ProofRecorded(u32, u32, RecordedProof),
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment