Struct dock_runtime::accumulator::pallet::Pallet
source · pub struct Pallet<T>(_);
Expand description
The pallet implementing the on-chain logic.
Implementations§
source§impl<T> Pallet<T>where
T: Config,
impl<T> Pallet<T>where T: Config,
pub fn public_key_with_params( _: &AccumPublicKeyStorageKey ) -> Option<(AccumulatorPublicKey<T>, Option<AccumulatorParameters<T>>)>
sourcepub fn get_accumulator_with_public_key_and_params(
id: &AccumulatorId
) -> Option<(Vec<u8, Global>, Option<(AccumulatorPublicKey<T>, Option<AccumulatorParameters<T>>)>)>
pub fn get_accumulator_with_public_key_and_params( id: &AccumulatorId ) -> Option<(Vec<u8, Global>, Option<(AccumulatorPublicKey<T>, Option<AccumulatorParameters<T>>)>)>
Get accumulated value with public key and params.
source§impl<T> Pallet<T>where
T: Config,
impl<T> Pallet<T>where T: Config,
pub fn add_params( origin: <T as Config>::Origin, params: AddAccumulatorParams<T>, signature: DidOrDidMethodKeySignature<AccumulatorOwner> ) -> Result<(), DispatchError>
pub fn add_public_key( origin: <T as Config>::Origin, public_key: AddAccumulatorPublicKey<T>, signature: DidOrDidMethodKeySignature<AccumulatorOwner> ) -> Result<(), DispatchError>
pub fn remove_params( origin: <T as Config>::Origin, remove: RemoveAccumulatorParams<T>, signature: DidOrDidMethodKeySignature<AccumulatorOwner> ) -> Result<(), DispatchError>
pub fn remove_public_key( origin: <T as Config>::Origin, remove: RemoveAccumulatorPublicKey<T>, signature: DidOrDidMethodKeySignature<AccumulatorOwner> ) -> Result<(), DispatchError>
sourcepub fn add_accumulator(
origin: <T as Config>::Origin,
add_accumulator: AddAccumulator<T>,
signature: DidOrDidMethodKeySignature<AccumulatorOwner>
) -> Result<(), DispatchError>
pub fn add_accumulator( origin: <T as Config>::Origin, add_accumulator: AddAccumulator<T>, signature: DidOrDidMethodKeySignature<AccumulatorOwner> ) -> Result<(), DispatchError>
Add a new accumulator with the initial accumulated value. Each accumulator has a unique id and it refers to a public key. It is assumed that the accumulator is owned by the DID that owns the public key. It logs an event with the accumulator id and accumulated value. For each new accumulator, its creation block is recorded in state to indicate from which block, the chain should be scanned for the accumulator’s updates. Note: Weight is same for both kinds of accumulator even when universal takes a bit more space
sourcepub fn update_accumulator(
origin: <T as Config>::Origin,
update: UpdateAccumulator<T>,
signature: DidOrDidMethodKeySignature<AccumulatorOwner>
) -> Result<(), DispatchError>
pub fn update_accumulator( origin: <T as Config>::Origin, update: UpdateAccumulator<T>, signature: DidOrDidMethodKeySignature<AccumulatorOwner> ) -> Result<(), DispatchError>
Update an existing accumulator. The update contains the new accumulated value, the updates themselves and the witness updated info. The updates and witness update info are optional as the owner might be privately communicating the updated witnesses. It logs an event with the accumulator id and the new accumulated value which is sufficient for a verifier. But the prover (who has a witness to update) needs the updates and the witness update info and is expected to look into the corresponding extrinsic arguments.
pub fn remove_accumulator( origin: <T as Config>::Origin, remove: RemoveAccumulator<T>, signature: DidOrDidMethodKeySignature<AccumulatorOwner> ) -> Result<(), DispatchError>
source§impl<T> Pallet<T>where
T: Config,
impl<T> Pallet<T>where T: Config,
pub fn did_counters<KArg>(k: KArg) -> StoredAccumulatorOwnerCounterswhere KArg: EncodeLike<AccumulatorOwner>,
source§impl<T> Pallet<T>where
T: Config,
impl<T> Pallet<T>where T: Config,
pub fn accumulator_params<KArg1, KArg2>( k1: KArg1, k2: KArg2 ) -> Option<AccumulatorParameters<T>>where KArg1: EncodeLike<AccumulatorOwner>, KArg2: EncodeLike<IncId>,
source§impl<T> Pallet<T>where
T: Config,
impl<T> Pallet<T>where T: Config,
sourcepub fn accumulator_key<KArg1, KArg2>(
k1: KArg1,
k2: KArg2
) -> Option<AccumulatorPublicKey<T>>where
KArg1: EncodeLike<AccumulatorOwner>,
KArg2: EncodeLike<IncId>,
pub fn accumulator_key<KArg1, KArg2>( k1: KArg1, k2: KArg2 ) -> Option<AccumulatorPublicKey<T>>where KArg1: EncodeLike<AccumulatorOwner>, KArg2: EncodeLike<IncId>,
Public key storage is kept separate from accumulator storage and a single key can be used to manage several accumulators. It is assumed that whoever (DID) owns the public key, owns the accumulator as well and only that DID can update accumulator.
source§impl<T> Pallet<T>where
T: Config,
impl<T> Pallet<T>where T: Config,
sourcepub fn accumulator<KArg>(k: KArg) -> Option<AccumulatorWithUpdateInfo<T>>where
KArg: EncodeLike<AccumulatorId>,
pub fn accumulator<KArg>(k: KArg) -> Option<AccumulatorWithUpdateInfo<T>>where KArg: EncodeLike<AccumulatorId>,
Stores latest accumulator as key value: accumulator id -> (created_at, last_updated_at, Accumulator)
created_at
is the block number when the accumulator was created and is intended to serve as a starting
point for anyone looking for all updates to the accumulator. last_updated_at
is the block number when
the last update was sent. created_at
and last_updated_at
together indicate which blocks should be
considered for finding accumulator updates.
Historical values and updates are persisted as events indexed with the accumulator id. The reason for
not storing past values is to save storage in chain state. Another option could have been to store
block numbers for the updates so that each block from created_at
doesn’t need to be scanned but
even that requires large storage as we expect millions of updates.
Just keeping the latest accumulated value allows for any potential on chain verification as well.
Trait Implementations§
source§impl From<<Pallet<Runtime> as Callable<Runtime>>::Call> for Call
impl From<<Pallet<Runtime> as Callable<Runtime>>::Call> for Call
source§fn from(call: CallableCallFor<Accumulator, Runtime>) -> Self
fn from(call: CallableCallFor<Accumulator, Runtime>) -> Self
source§impl<T> GetStorageVersion for Pallet<T>where
T: Config,
impl<T> GetStorageVersion for Pallet<T>where T: Config,
source§fn current_storage_version() -> StorageVersion
fn current_storage_version() -> StorageVersion
source§fn on_chain_storage_version() -> StorageVersion
fn on_chain_storage_version() -> StorageVersion
source§impl<T> Hooks<<T as Config>::BlockNumber> for Pallet<T>where
T: Config,
impl<T> Hooks<<T as Config>::BlockNumber> for Pallet<T>where T: Config,
§fn on_finalize(_n: BlockNumber)
fn on_finalize(_n: BlockNumber)
§fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight
fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight
on_finalize
).
Implement to have something happen using the remaining weight.
Will not fire if the remaining weight is 0.
Return the weight used, the hook will subtract it from current weight used
and pass the result to the next on_idle
hook if it exists.§fn on_initialize(_n: BlockNumber) -> Weight
fn on_initialize(_n: BlockNumber) -> Weight
§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
§fn offchain_worker(_n: BlockNumber)
fn offchain_worker(_n: BlockNumber)
§fn integrity_test()
fn integrity_test()
source§impl<T> IntegrityTest for Pallet<T>where
T: Config,
impl<T> IntegrityTest for Pallet<T>where T: Config,
source§fn integrity_test()
fn integrity_test()
source§impl IsSubType<<Pallet<Runtime> as Callable<Runtime>>::Call> for Call
impl IsSubType<<Pallet<Runtime> as Callable<Runtime>>::Call> for Call
source§fn is_sub_type(&self) -> Option<&CallableCallFor<Accumulator, Runtime>>
fn is_sub_type(&self) -> Option<&CallableCallFor<Accumulator, Runtime>>
Some(_)
if self
is an instance of sub type T
.source§impl<T> OffchainWorker<<T as Config>::BlockNumber> for Pallet<T>where
T: Config,
impl<T> OffchainWorker<<T as Config>::BlockNumber> for Pallet<T>where T: Config,
source§fn offchain_worker(n: <T as Config>::BlockNumber)
fn offchain_worker(n: <T as Config>::BlockNumber)
source§impl<T> OnFinalize<<T as Config>::BlockNumber> for Pallet<T>where
T: Config,
impl<T> OnFinalize<<T as Config>::BlockNumber> for Pallet<T>where T: Config,
source§fn on_finalize(n: <T as Config>::BlockNumber)
fn on_finalize(n: <T as Config>::BlockNumber)
source§impl<T> OnGenesis for Pallet<T>where
T: Config,
impl<T> OnGenesis for Pallet<T>where T: Config,
source§fn on_genesis()
fn on_genesis()
source§impl<T> OnIdle<<T as Config>::BlockNumber> for Pallet<T>where
T: Config,
impl<T> OnIdle<<T as Config>::BlockNumber> for Pallet<T>where T: Config,
source§fn on_idle(n: <T as Config>::BlockNumber, remaining_weight: Weight) -> Weight
fn on_idle(n: <T as Config>::BlockNumber, remaining_weight: Weight) -> Weight
remaining_weight
to make sure it is high enough to allow for
your pallet’s extra computation. Read moresource§impl<T> OnInitialize<<T as Config>::BlockNumber> for Pallet<T>where
T: Config,
impl<T> OnInitialize<<T as Config>::BlockNumber> for Pallet<T>where T: Config,
source§fn on_initialize(n: <T as Config>::BlockNumber) -> Weight
fn on_initialize(n: <T as Config>::BlockNumber) -> Weight
source§impl<T> OnRuntimeUpgrade for Pallet<T>where
T: Config,
impl<T> OnRuntimeUpgrade for Pallet<T>where T: Config,
source§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
source§impl<T> PalletInfoAccess for Pallet<T>where
T: Config,
impl<T> PalletInfoAccess for Pallet<T>where T: Config,
source§fn module_name() -> &'static str
fn module_name() -> &'static str
source§fn crate_version() -> CrateVersion
fn crate_version() -> CrateVersion
source§impl<T> PartialEq<Pallet<T>> for Pallet<T>
impl<T> PartialEq<Pallet<T>> for Pallet<T>
impl<T> Eq for Pallet<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for Pallet<T>where T: RefUnwindSafe,
impl<T> Send for Pallet<T>where T: Send,
impl<T> Sync for Pallet<T>where T: Sync,
impl<T> Unpin for Pallet<T>where T: Unpin,
impl<T> UnwindSafe for Pallet<T>where T: UnwindSafe,
Blanket Implementations§
source§impl<T> CanUpdate<()> for T
impl<T> CanUpdate<()> for T
source§fn can_remove(&self, _entity: &()) -> bool
fn can_remove(&self, _entity: &()) -> bool
§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
§fn checked_from<T>(t: T) -> Option<Self>where
Self: TryFrom<T>,
fn checked_from<T>(t: T) -> Option<Self>where Self: TryFrom<T>,
§fn checked_into<T>(self) -> Option<T>where
Self: TryInto<T>,
fn checked_into<T>(self) -> Option<T>where Self: TryInto<T>,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IsType<T> for T
impl<T> IsType<T> for T
§impl<T> PalletVersionToStorageVersionHelper for Twhere
T: GetStorageVersion + PalletInfoAccess,
impl<T> PalletVersionToStorageVersionHelper for Twhere T: GetStorageVersion + PalletInfoAccess,
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere Self: UniqueSaturatedFrom<T>,
§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere Self: UniqueSaturatedInto<T>,
T
. Read more§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere T: UncheckedFrom<S>,
§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.§impl<T, S> UniqueSaturatedInto<T> for Swhere
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for Swhere T: Bounded, S: TryInto<T>,
§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.