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

feat: move ACL from inside DRP to outside DRPObject #318

Merged
merged 39 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
9e43987
feat: add acl to DRPobject
anhnd350309 Jan 6, 2025
ce5f3ed
feat: update proto
anhnd350309 Jan 7, 2025
874e342
feat: handle move acl from DRP to DRPObject
anhnd350309 Jan 7, 2025
327b726
Update testcase
anhnd350309 Jan 7, 2025
43b83b9
remove acl
anhnd350309 Jan 7, 2025
d574672
fix biome
anhnd350309 Jan 7, 2025
27702e1
fix biome
anhnd350309 Jan 7, 2025
7e4be0b
fix: root vertex prefix
anhnd350309 Jan 7, 2025
185f746
fix: acl is null
anhnd350309 Jan 7, 2025
1775623
feat: resolve comment
anhnd350309 Jan 7, 2025
2ef9670
feat: update prefix in root vertex
anhnd350309 Jan 7, 2025
c325ac8
feat: fix biome
anhnd350309 Jan 7, 2025
4abc1e8
feat: fix testcase node
anhnd350309 Jan 7, 2025
3c6bc22
remove console
anhnd350309 Jan 7, 2025
8a0edb3
feat: rename prefix to vertex type
anhnd350309 Jan 8, 2025
68c5c99
feat: improve some performance
anhnd350309 Jan 8, 2025
cd21213
resolve comment
anhnd350309 Jan 8, 2025
ee5e1a2
feat: pre compute LCA first
anhnd350309 Jan 8, 2025
7528f26
feat: rename drp and acl states
anhnd350309 Jan 8, 2025
54bd49f
feat: improve if else drp type
anhnd350309 Jan 9, 2025
bfab670
resolve comment
anhnd350309 Jan 10, 2025
c0203f0
Merge branch 'main' into feat/move-acl-to-outside
anhnd350309 Jan 10, 2025
ef2250c
delete file proto auto generate
anhnd350309 Jan 12, 2025
5477f34
resolve comment
anhnd350309 Jan 12, 2025
762433a
feat: remove file
anhnd350309 Jan 12, 2025
dffdb00
Merge branch 'main' into feat/move-acl-to-outside
anhnd350309 Jan 12, 2025
50b42db
feat: fix all testcase
anhnd350309 Jan 12, 2025
85ae5dc
fix biome
anhnd350309 Jan 12, 2025
0d1544e
feat: change vertexType to drpType, type to opType
anhnd350309 Jan 12, 2025
cf0ff80
fix testcase
anhnd350309 Jan 12, 2025
c28c30d
fix: performance PR 318 (#348)
hoangquocvietuet Jan 13, 2025
05398b2
fix update drpType
anhnd350309 Jan 13, 2025
b7ee6a5
Merge branch 'main' into feat/move-acl-to-outside
anhnd350309 Jan 13, 2025
bb59631
fix testcase
anhnd350309 Jan 13, 2025
4be0f0b
fix: follow issue #242
anhnd350309 Jan 13, 2025
0087443
fix biome
anhnd350309 Jan 13, 2025
9650147
fix: change check some verties to check first vertex
anhnd350309 Jan 13, 2025
a09352c
rename DrpTypeOperation; use that instead of strings
d-roak Jan 15, 2025
d5027da
merge main; add tests to biome
d-roak Jan 15, 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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// GENERATED CODE -- NO SERVICES IN PROTO
2 changes: 1 addition & 1 deletion packages/network/src/proto/drp/network/v1/messages_pb.ts

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

21 changes: 19 additions & 2 deletions packages/network/src/proto/drp/object/v1/object_pb.ts

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

2 changes: 1 addition & 1 deletion packages/network/src/proto/google/protobuf/struct_pb.ts

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

7 changes: 4 additions & 3 deletions packages/node/src/handlers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Stream } from "@libp2p/interface";
import { NetworkPb, streamToUint8Array } from "@ts-drp/network";
import type { DRP, DRPObject, ObjectPb, Vertex } from "@ts-drp/object";
import type { DRP, DRPObject, IACL, ObjectPb, Vertex } from "@ts-drp/object";
import { fromString as uint8ArrayFromString } from "uint8arrays/from-string";
import { type DRPNode, log } from "./index.js";

Expand Down Expand Up @@ -236,6 +236,7 @@ export async function verifyIncomingVertices(
operation: {
type: vertex.operation?.type ?? "",
value: vertex.operation?.value,
vertexType: vertex.operation?.vertexType ?? "",
},
dependencies: vertex.dependencies,
timestamp: vertex.timestamp,
Expand All @@ -244,10 +245,10 @@ export async function verifyIncomingVertices(
});

const drp = object.drp as DRP;
if (!drp.acl) {
const acl: IACL & DRP = object.acl as IACL & DRP;
if (!acl) {
return vertices;
}
const acl = drp.acl;
const verificationPromises = vertices.map(async (vertex) => {
if (vertex.signature === "") {
return null;
Expand Down
10 changes: 8 additions & 2 deletions packages/node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
type DRPNetworkNodeConfig,
NetworkPb,
} from "@ts-drp/network";
import { type DRP, DRPObject, type Vertex } from "@ts-drp/object";
import { type DRP, DRPObject, type IACL, type Vertex } from "@ts-drp/object";
import { drpMessagesHandler } from "./handlers.js";
import * as operations from "./operations.js";
import { DRPObjectStore } from "./store/index.js";
Expand Down Expand Up @@ -78,7 +78,13 @@ export class DRPNode {
sync?: boolean,
peerId?: string,
) {
const object = new DRPObject(this.networkNode.peerId, drp, id, abi);
const object = new DRPObject(
this.networkNode.peerId,
drp,
null as unknown as IACL & DRP,
id,
abi,
);
operations.createObject(this, object);
operations.subscribeObject(this, object.id);
if (sync) {
Expand Down
9 changes: 6 additions & 3 deletions packages/node/tests/node.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { AddWinsSetWithACL } from "@topology-foundation/blueprints/src/AddWinsSetWithACL/index.js";
import { ACL } from "@topology-foundation/blueprints/src/ACL/index.js";
import { AddWinsSet } from "@topology-foundation/blueprints/src/index.js";
import { VertexTypeOperation } from "@topology-foundation/object/src/index.js";
import { type DRP, DRPObject } from "@ts-drp/object";
import { beforeAll, beforeEach, describe, expect, test } from "vitest";
import {
Expand All @@ -19,12 +20,13 @@ describe("DPRNode with verify and sign signature", () => {
});

beforeEach(async () => {
drp = new AddWinsSetWithACL(
drp = new AddWinsSet();
const acl = new ACL(
new Map([
[drpNode.networkNode.peerId, drpNode.networkNode.publicKey || ""],
]),
);
drpObject = new DRPObject(drpNode.networkNode.peerId, drp);
drpObject = new DRPObject(drpNode.networkNode.peerId, drp, acl);
});

test("Node will not sign vertex if it is not the creator", async () => {
Expand Down Expand Up @@ -107,6 +109,7 @@ describe("DPRNode with verify and sign signature", () => {
operation: {
type: "add",
value: 1,
vertexType: VertexTypeOperation.drp,
},
dependencies: [],
signature: "",
Expand Down
1 change: 1 addition & 0 deletions packages/object/src/hashgraph/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export class HashGraph {
operation: {
type: OperationType.NOP,
value: null,
vertexType: "",
},
dependencies: [],
timestamp: -1,
Expand Down
Loading
Loading