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

Integrated with KCs #194

Open
wants to merge 104 commits into
base: v8/integrate-w-gamma-contracts
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
1ec72d4
Integrated with KCs
br41nl3t Dec 13, 2024
65098c6
done
Mihajlo-Pavlovic Dec 13, 2024
7aa9020
fix 1
Mihajlo-Pavlovic Dec 13, 2024
d38c5f2
rename 1
Mihajlo-Pavlovic Dec 13, 2024
7312cc1
Add tokens count
Mihajlo-Pavlovic Dec 13, 2024
c361289
Add last fixes
Mihajlo-Pavlovic Dec 13, 2024
018caf4
fixes
Mihajlo-Pavlovic Dec 13, 2024
a818c10
Bumped package version
br41nl3t Dec 13, 2024
af89ee2
Fixes for blockchain
Mihajlo-Pavlovic Dec 13, 2024
ce386dd
simplify code
Mihajlo-Pavlovic Dec 14, 2024
236dab6
improve
Mihajlo-Pavlovic Dec 14, 2024
ec61366
remove redundancy
Mihajlo-Pavlovic Dec 14, 2024
1805307
fix
Mihajlo-Pavlovic Dec 14, 2024
457fd9d
Merge branch 'v8/kcs-integration' into v8/public-private-pairing-rework
Mihajlo-Pavlovic Dec 16, 2024
8a1fc08
Merge pull request #195 from OriginTrail/v8/public-private-pairing-re…
Mihajlo-Pavlovic Dec 16, 2024
b1f031b
Get improvment
Mihajlo-Pavlovic Dec 16, 2024
a13370f
try fix esm/cjs compat
aleksaelezovic Dec 16, 2024
775490f
depend on correct (new) assertion-tools version
aleksaelezovic Dec 16, 2024
a370fd3
Merge branch 'v8/kcs-integration' into v8/fix-esm-compat
br41nl3t Dec 16, 2024
7cacc3d
Merge pull request #198 from aleksaelezovic/v8/fix-esm-compat
br41nl3t Dec 16, 2024
0bb85dd
Merged
br41nl3t Dec 16, 2024
90f484c
fix webpack issues
aleksaelezovic Dec 17, 2024
42527cd
new build
aleksaelezovic Dec 17, 2024
23be6cc
Merge pull request #199 from aleksaelezovic/v8/fix-esm-compat
br41nl3t Dec 17, 2024
f7fc11a
Updated package
br41nl3t Dec 17, 2024
0e75363
Adding api version
ilijaMar Dec 17, 2024
f87a70b
Changed default from v0 to v1
ilijaMar Dec 17, 2024
256a583
Asset create calls graph create
ilijaMar Dec 17, 2024
618b94a
Updated graph create to newer version
ilijaMar Dec 17, 2024
43be461
Private representation added with public sujbect if pair exsits
Mihajlo-Pavlovic Dec 17, 2024
9b8fc7f
remove token count
Mihajlo-Pavlovic Dec 17, 2024
2a3ac69
Swaped graph and asset
ilijaMar Dec 18, 2024
a312781
Repositories support
brkagithub Dec 18, 2024
966b5f9
Fixes and enable bid suggestion
Mihajlo-Pavlovic Dec 18, 2024
5d9bcbf
Merge pull request #201 from OriginTrail/remove-private-representatio…
Mihajlo-Pavlovic Dec 18, 2024
2699c3a
Merge pull request #202 from OriginTrail/v8/repositories-support
Mihajlo-Pavlovic Dec 18, 2024
e8b92b2
Changed max file size
ilijaMar Dec 18, 2024
a450f17
Merge branch 'v8/kcs-integration' into v8/addintApiVersion
Mihajlo-Pavlovic Dec 18, 2024
d57a0a6
Merge pull request #200 from OriginTrail/v8/addintApiVersion
Mihajlo-Pavlovic Dec 18, 2024
f7d9934
Integration + remove paranet UAL from create + remove update
brkagithub Dec 18, 2024
7b688d0
Merge remote-tracking branch 'origin/v8/kcs-integration' into v8/inte…
brkagithub Dec 18, 2024
08b4345
Merge branch 'v8/kcs-integration' into v8/integrate-w-new-contracts
brkagithub Dec 18, 2024
1a816ec
Merge pull request #203 from OriginTrail/v8/integrate-w-new-contracts
brkagithub Dec 18, 2024
cb85d31
remove extra create
brkagithub Dec 18, 2024
8bb83cd
Add missing imports
brkagithub Dec 18, 2024
a470054
Release sigma dkg.js
brkagithub Dec 18, 2024
a8d05ad
Add new hubs and update version
brkagithub Dec 19, 2024
5257fa3
fix ask, add new hub for testnet
brkagithub Dec 19, 2024
1562d2f
Release new version
brkagithub Dec 20, 2024
004a012
Push dkg min js
brkagithub Dec 20, 2024
58644fe
Bump version
brkagithub Dec 20, 2024
524987f
Ayo sigma boy
br41nl3t Dec 20, 2024
467e382
Add hubs to constants
Mihajlo-Pavlovic Dec 20, 2024
d3b4f28
version bump
Mihajlo-Pavlovic Dec 20, 2024
3837456
Merge pull request #205 from OriginTrail/add-testnet-hubs
Mihajlo-Pavlovic Dec 20, 2024
c5359e9
Implement correct publishing cost formula
Mihajlo-Pavlovic Dec 20, 2024
49f7d8c
Version bump
Mihajlo-Pavlovic Dec 20, 2024
451c729
Add new hubs
brkagithub Dec 23, 2024
f617d1a
Dont send chunk size, send immutable
brkagithub Dec 23, 2024
f4dfc16
Update hubs again
brkagithub Dec 23, 2024
c01ef75
Merge pull request #206 from OriginTrail/improvement/add-other-testne…
brkagithub Dec 23, 2024
5613ec9
Fixes for RC
Mihajlo-Pavlovic Dec 24, 2024
0241af8
Update newest hubs
brkagithub Dec 24, 2024
b951c8f
Bump version
brkagithub Dec 24, 2024
a239d72
Merge branch 'v8/kcs-integration' into improvement/add-other-testnet-…
Mihajlo-Pavlovic Dec 24, 2024
1387f37
Merge pull request #207 from OriginTrail/improvement/add-other-testne…
Mihajlo-Pavlovic Dec 24, 2024
a05e7ed
Bump version and hubs
brkagithub Dec 25, 2024
abd1008
sigma boy
brkagithub Dec 25, 2024
df7e392
remove console log
brkagithub Dec 25, 2024
fe99ddd
fix bid
Mihajlo-Pavlovic Dec 25, 2024
8a4f834
Fixes
Mihajlo-Pavlovic Dec 25, 2024
8596691
Fix get
Mihajlo-Pavlovic Dec 25, 2024
eb8d18a
Merge pull request #208 from OriginTrail/improvement/add-other-testne…
brkagithub Dec 26, 2024
31fc380
8.0.0
brkagithub Dec 26, 2024
7959e7a
min js
brkagithub Dec 26, 2024
9a66f9f
Change oracle for gnosis
brkagithub Dec 26, 2024
f498b20
dd try catch to gnosis gas oracle
brkagithub Dec 26, 2024
a701d09
PR feedback
brkagithub Dec 26, 2024
198a731
Run build
Mihajlo-Pavlovic Dec 26, 2024
a1e019d
Merge pull request #210 from OriginTrail/fix/gnosis-gas-price
Mihajlo-Pavlovic Dec 26, 2024
b71d768
version bump
Mihajlo-Pavlovic Dec 26, 2024
5d94b7c
correct version for npm
Mihajlo-Pavlovic Dec 26, 2024
00a8886
Change defaults for other blockchains, fix defaulting
brkagithub Dec 26, 2024
d9bca33
merge
brkagithub Dec 26, 2024
8611005
Merge remote-tracking branch 'origin/v8/kcs-integration' into fix/gno…
brkagithub Dec 26, 2024
ac801ae
Bump verison, build again, fix typos
brkagithub Dec 26, 2024
4be5dea
Merge pull request #211 from OriginTrail/fix/gnosis-gas-price
br41nl3t Dec 26, 2024
e168965
Implement get/increase allowance for new contracts
brkagithub Dec 27, 2024
ad287e2
Merge pull request #212 from OriginTrail/v8/allowance-backwards-compa…
brkagithub Dec 27, 2024
2ddb486
Add validation for signatures
Mihajlo-Pavlovic Dec 27, 2024
53a2289
add signature validaton code
Mihajlo-Pavlovic Dec 30, 2024
89fc850
Fix decrease allowance issue
Jan 13, 2025
dd74aaa
Fixed demo.js
ilijaMar Jan 13, 2025
129ece2
Changeg constant name
ilijaMar Jan 13, 2025
b25e108
Merge remote-tracking branch 'origin/v8/updating-demo' into v8/decrea…
Jan 13, 2025
1ce759f
Add dotenv adn fix demo
Jan 13, 2025
3dc61fc
Add development pub key
Jan 13, 2025
e2bcd2b
PR suggesstions
Jan 13, 2025
bdf7f7c
Capitalize constants
Jan 13, 2025
daa1839
remove knowledgeCollectionAddress as a param of increaseKnowledgeColl…
Jan 13, 2025
5237e10
Bump version num
Jan 13, 2025
86dd523
Merge pull request #215 from OriginTrail/v8/decrease-allowance-and-de…
zsculac Jan 13, 2025
c5cf29e
Apdated publish finality
ilijaMar Jan 17, 2025
7d4422b
Merge pull request #216 from OriginTrail/v8/adding-publish-finality
Mihajlo-Pavlovic Jan 17, 2025
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
64 changes: 32 additions & 32 deletions examples/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,57 +80,57 @@ function divider() {
console.log('======================== NODE INFO RECEIVED');
console.log(nodeInfo);

divider();
// divider();

console.time('Publish (1 replication, 3 finalizations)')
const result0 = await DkgClient.asset.create(content, {
epochsNum: 2,
tokenAmount: '100',
minimumNumberOfFinalizationConfirmations: 3,
minimumNumberOfNodeReplications: 1,
});
console.timeEnd('Publish (1 replication, 3 finalizations)')
// console.time('Publish (1 replication, 3 finalizations)')
// const result0 = await DkgClient.asset.create(content, {
// epochsNum: 2,
// tokenAmount: '100',
// minimumNumberOfFinalizationConfirmations: 3,
// minimumNumberOfNodeReplications: 1,
// });
// console.timeEnd('Publish (1 replication, 3 finalizations)')

console.log(JSON.stringify(result0));
// console.log(JSON.stringify(result0));

divider();
// divider();

console.time('Publish (1 replication, 1 finalization)')
const result1 = await DkgClient.asset.create(content, {
epochsNum: 2,
tokenAmount: '100',
minimumNumberOfFinalizationConfirmations: 1,
minimumNumberOfNodeReplications: 1,
});
console.timeEnd('Publish (1 replication, 1 finalization)')
// console.time('Publish (1 replication, 1 finalization)')
// const result1 = await DkgClient.asset.create(content, {
// epochsNum: 2,
// tokenAmount: '100',
// minimumNumberOfFinalizationConfirmations: 1,
// minimumNumberOfNodeReplications: 1,
// });
// console.timeEnd('Publish (1 replication, 1 finalization)')

console.log(JSON.stringify(result1));
// console.log(JSON.stringify(result1));

divider();

console.time('Publish (3 replications, 3 finalizations)')
const result2 = await DkgClient.asset.create(content, {
epochsNum: 2,
tokenAmount: '100',
tokenAmount: '100000000000',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we still have this it should be calculated on chain

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should work now, yes

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without hardcoded amount

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It won't work because we don't have new sharding table contract in this version

minimumNumberOfFinalizationConfirmations: 3,
minimumNumberOfNodeReplications: 3,
});
console.timeEnd('Publish (3 replications, 3 finalizations)')

console.log(JSON.stringify(result2));
console.log(result2);

divider();
// divider();

console.time('Publish (5 replications, 5 finalizations)')
const result3 = await DkgClient.asset.create(content, {
epochsNum: 2,
tokenAmount: '100',
minimumNumberOfFinalizationConfirmations: 5,
minimumNumberOfNodeReplications: 5,
});
console.timeEnd('Publish (5 replications, 5 finalizations)')
// console.time('Publish (5 replications, 5 finalizations)')
// const result3 = await DkgClient.asset.create(content, {
// epochsNum: 2,
// tokenAmount: '100',
// minimumNumberOfFinalizationConfirmations: 5,
// minimumNumberOfNodeReplications: 5,
// });
// console.timeEnd('Publish (5 replications, 5 finalizations)')

console.log(JSON.stringify(result3));
// console.log(JSON.stringify(result3));

// divider();

Expand Down
18 changes: 6 additions & 12 deletions managers/asset-operations-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ export default class AssetOperationsManager {
const datasetRoot = kcTools.calculateMerkleRoot(dataset.public);

const contentAssetStorageAddress = await this.blockchainService.getContractAddress(
'ContentAssetStorage',
'KnowledgeCollectionStorage',
blockchain,
);

Expand Down Expand Up @@ -459,19 +459,16 @@ export default class AssetOperationsManager {

const {
identityId: publisherNodeIdentityId,
signer: publisherNodeSigner,
r: publisherNodeR,
vs: publisherNodeVS,
} = publishOperationResult.data.publisherNodeSignature;

const identityIds = [];
const signers = [];
const r = [];
const vs = [];

signatures.forEach((signature) => {
identityIds.push(signature.identityId);
signers.push(signature.signer);
r.push(signature.r);
vs.push(signature.vs);
});
Expand All @@ -480,13 +477,14 @@ export default class AssetOperationsManager {
tokenAmount ??
(await this.blockchainService.getStakeWeightedAverageAsk()) * epochsNum * datasetSize;

let tokenId;
let knowledgeCollectionId;
let mintKnowledgeAssetReceipt;

if (paranetUAL == null) {
({ tokenId, receipt: mintKnowledgeAssetReceipt } =
({ knowledgeCollectionId, receipt: mintKnowledgeAssetReceipt } =
await this.blockchainService.createKnowledgeCollection(
{
publishOperationId,
merkleRoot: datasetRoot,
knowledgeAssetsAmount: kcTools.countDistinctSubjects(dataset.public),
byteSize: datasetSize,
Expand All @@ -496,11 +494,9 @@ export default class AssetOperationsManager {
tokenAmount: estimatedPublishingCost,
paymaster: payer,
publisherNodeIdentityId,
publisherNodeSigner,
publisherNodeR,
publisherNodeVS,
identityIds,
signers,
r,
vs,
},
Expand All @@ -511,7 +507,7 @@ export default class AssetOperationsManager {
));
} else {
const { contract: paranetKaContract, tokenId: paranetTokenId } = resolveUAL(paranetUAL);
({ tokenId, receipt: mintKnowledgeAssetReceipt } =
({ knowledgeCollectionId, receipt: mintKnowledgeAssetReceipt } =
await this.blockchainService.createKnowledgeCollection(
{
merkleRoot: datasetRoot,
Expand All @@ -523,11 +519,9 @@ export default class AssetOperationsManager {
tokenAmount: estimatedPublishingCost,
paymaster: payer,
publisherNodeIdentityId,
publisherNodeSigner,
publisherNodeR,
publisherNodeVS,
identityIds,
signers,
r,
vs,
},
Expand All @@ -538,7 +532,7 @@ export default class AssetOperationsManager {
));
}

const UAL = deriveUAL(blockchain.name, contentAssetStorageAddress, tokenId);
const UAL = deriveUAL(blockchain.name, contentAssetStorageAddress, knowledgeCollectionId);

let finalityStatusResult = 0;
if (minimumNumberOfFinalizationConfirmations > 0) {
Expand Down
43 changes: 29 additions & 14 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"dependencies": {
"assertion-tools": "^8.0.0-gamma.1",
"axios": "^0.27.2",
"dkg-evm-module": "^8.0.2-alpha.0",
"dkg-evm-module": "^8.0.3-gamma.7",
"ethers": "^6.1.0",
"jsonld": "^8.1.0",
"web3": "^1.7.3"
Expand Down
14 changes: 8 additions & 6 deletions services/blockchain-service/blockchain-service-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const ParanetNeuroIncentivesPoolAbi = require('dkg-evm-module/abi/ParanetNeuroIn
const ParanetKnowledgeMinersRegistryAbi = require('dkg-evm-module/abi/ParanetKnowledgeMinersRegistry.json');
const IdentityStorageAbi = require('dkg-evm-module/abi/IdentityStorage.json');
const KnowledgeCollectionAbi = require('dkg-evm-module/abi/KnowledgeCollection.json');
const KnowledgeCollectionLibAbi = require('dkg-evm-module/abi/KnowledgeCollectionLib.json');

// const ShardingTableStorageAbi = require('dkg-evm-module/abi/ShardingTableStorage.sol.json');

Expand All @@ -47,6 +48,7 @@ export default class BlockchainServiceBase {
this.abis.ParanetKnowledgeMinersRegistry = ParanetKnowledgeMinersRegistryAbi;
this.abis.IdentityStorage = IdentityStorageAbi;
this.abis.KnowledgeCollection = KnowledgeCollectionAbi;
this.abis.KnowledgeCollectionLib = KnowledgeCollectionLibAbi;
// this.abis.ShardingTableStorageAbi = ShardingTableStorageAbi;

this.abis.ContentAsset.filter((obj) => obj.type === 'event').forEach((event) => {
Expand Down Expand Up @@ -323,7 +325,7 @@ export default class BlockchainServiceBase {
this[blockchain.name].contractAddresses[blockchain.hubContract][contractName] =
await this.callContractFunction(
'Hub',
contractName.includes('AssetStorage')
contractName.includes('AssetStorage') || contractName.includes('CollectionStorage')
? 'getAssetStorageAddress'
: 'getContractAddress',
[contractName],
Expand Down Expand Up @@ -460,7 +462,7 @@ export default class BlockchainServiceBase {
receipt = await this.executeContractFunction(
'KnowledgeCollection',
'createKnowledgeCollection',
[Object.values(requestData)],
[...Object.values(requestData)],
blockchain,
);
} else {
Expand All @@ -472,16 +474,16 @@ export default class BlockchainServiceBase {
);
}

let { tokenId } = await this.decodeEventLogs(receipt, 'AssetMinted', blockchain);
let { id } = await this.decodeEventLogs(receipt, 'KnowledgeCollectionCreated', blockchain);

tokenId = parseInt(tokenId, 10);
id = parseInt(id, 10);

stepHooks.afterHook({
status: OPERATIONS_STEP_STATUS.CREATE_ASSET_COMPLETED,
data: { tokenId },
data: { id },
});

return { tokenId, receipt };
return { knowledgeCollectionId: id, receipt };
} catch (error) {
if (allowanceIncreased) {
await this.executeContractFunction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default class NodeBlockchainService extends BlockchainServiceBase {
this.config = config;
this.events = {};

this.abis.ContentAsset.filter((obj) => obj.type === 'event').forEach((event) => {
this.abis.KnowledgeCollectionLib.filter((obj) => obj.type === 'event').forEach((event) => {
const concatInputs = event.inputs.map((input) => input.internalType);

this.events[event.name] = {
Expand Down
3 changes: 2 additions & 1 deletion services/input-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
LOW_BID_SUGGESTION,
PARANET_NODES_ACCESS_POLICY,
PARANET_MINERS_ACCESS_POLICY,
ZERO_ADDRESS,
} from '../constants.js';

export default class InputService {
Expand Down Expand Up @@ -333,7 +334,7 @@ export default class InputService {
}

getPayer(options) {
return options.payer ?? this.config.payer ?? null;
return options.payer ?? this.config.payer ?? ZERO_ADDRESS;
}

getMinimumNumberOfFinalizationConfirmations(options) {
Expand Down