Skip to content

Commit

Permalink
TRN-808 Sylo Data Pallet (#917)
Browse files Browse the repository at this point in the history
* create cargo package for new sylo pallet

* implement pallet functionality for registering resolvers

* implement tests for registering resolvers

* implement functionality for record validation

* implement tests for creating validation records

* setup benchmarking for sylo pallet

* implement remaning sylo extrinsic benchmarks

* modify on charge tx to force sylo fee swap for sylo pallet extrinsics

* use a storage value for reserved sylo resolver method

* fix mock in fee-control tests

* add more comments to config

* fix tests compiling

* implement integration tests for sylo pallet fees

* resize constants for sylo config

* use EnsureOrigin and emit event on state change

* avoid unnecessary clones in sylo pallet

* ensure strings have upper bound in benchmark and add verification

* refactor tests

* fix benchmark verification

* Update benchmarks for pallet-sylo on TRN-808-sylo-pallet

* implement e2e tests to validate sylo gas costs

* remove commented code

* add more doc comments to sylo pallet

* add tests for admin set calls

* better error name and refactor to benchmark impl

* use correct args for sylo weights

* add more coverage for sylo fee edge cases and more e2e tests

* Update benchmarks for pallet-sylo on TRN-808-sylo-pallet

* fix fee-control and fee-proxy mocks

* fix linter

* remove unneeded imports

* rename sylo-pallet -> sylo-data-verification-pallet

* minor refactor

---------

Co-authored-by: GitHub Action <[email protected]>
  • Loading branch information
JCSanPedro and actions-user authored Jan 16, 2025
1 parent a70f58f commit 7b974a3
Show file tree
Hide file tree
Showing 27 changed files with 3,537 additions and 42 deletions.
32 changes: 32 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ pallet-nft-peg = { path = "pallet/nft-peg", default-features = false }
pallet-sft = { path = "pallet/sft", default-features = false }
pallet-sft-rpc = { path = "pallet/sft/rpc", default-features = false }
pallet-sft-rpc-runtime-api = { path = "pallet/sft/rpc/runtime-api", default-features = false }
pallet-sylo-data-verification = { path = "pallet/sylo-data-verification", default-features = false }
pallet-token-approvals = { path = "pallet/token-approvals", default-features = false }
pallet-tx-fee-pot = { path = "pallet/tx-fee-pot", default-features = false }
pallet-vortex-distribution = { path = "pallet/vortex-distribution", default-features = false }
Expand Down
35 changes: 28 additions & 7 deletions e2e/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,15 +623,31 @@ export const finalizeTx = (
extrinsic: SubmittableExtrinsic<"promise">,
opts?: Partial<SignerOptions>,
) => {
return new Promise<any[]>((resolve) => {
const sendCb =
(resolve: any, reject: any) =>
({ internalError, dispatchError, status, events = [] }: any) => {
if (internalError) {
return reject(internalError);
}

if (dispatchError && !dispatchError.isModule) {
return reject(dispatchError.toJSON());
}

if (dispatchError && dispatchError.isModule) {
const { section, name, docs } = dispatchError.registry.findMetaError(dispatchError.asModule);

return reject({ section, name, docs });
}

if (status.isInBlock) resolve(events);
};

return new Promise<any[]>((resolve, reject) => {
if (opts) {
extrinsic.signAndSend(signer, opts, ({ status, events = [] }: any) => {
if (status.isInBlock) resolve(events);
});
extrinsic.signAndSend(signer, opts, sendCb(resolve, reject));
} else {
extrinsic.signAndSend(signer, ({ status, events = [] }: any) => {
if (status.isInBlock) resolve(events);
});
extrinsic.signAndSend(signer, sendCb(resolve, reject));
}
});
};
Expand Down Expand Up @@ -807,3 +823,8 @@ export const loadTestUsers = (userAmount?: number): KeyringPair[] => {
console.log(`loaded ${keypairs.length} users`);
return keypairs;
};

export const getPrefixLength = (encoded: SubmittableExtrinsic<any>): number => {
if (encoded.encodedLength < 66) return 6;
return 8;
};
2 changes: 1 addition & 1 deletion e2e/test/Doughnuts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ describe("Doughnuts", () => {
.transact(call, doughnutHex, nonce, genesis_hash, tip, holderSig)
.send()
.catch((err: any) => {
console.log(err);
console.log("DOUGHNUT ERR", err);
});

// console.log(events);
Expand Down
Loading

0 comments on commit 7b974a3

Please sign in to comment.