From 395f37c5c5606533be50d9fabd736e1c9c115d2e Mon Sep 17 00:00:00 2001 From: Nicolas Luck Date: Tue, 20 Feb 2024 23:40:20 +0100 Subject: [PATCH 1/7] Rename other link languages --- cli/seed_proto.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/seed_proto.json b/cli/seed_proto.json index 08aa8312d..8240e162c 100644 --- a/cli/seed_proto.json +++ b/cli/seed_proto.json @@ -12,7 +12,7 @@ }, { "meta": { - "name": "perspectiveDiffSync", + "name": "perspectiveDiffSync-socket", "description": "Holochain based Perspective link sharing language, with revision signals sent with socket.io through a centralized server", "sourceCodeLink": "https://github.com/coasys/ad4m/tree/dev/bootstrap-languages/p-diff-sync-socket-signaling", "possibleTemplateParams": ["uid", "name", "description"] @@ -21,7 +21,7 @@ }, { "meta": { - "name": "perspectiveDiffSync", + "name": "CloudLinks", "description": "Centralized link language", "sourceCodeLink": "https://github.com/coasys/ad4m/tree/dev/bootstrap-languages/p-diff-sync-socket-signaling", "possibleTemplateParams": ["uid", "name", "description"] From 89255999dd7f8baafdcc619f8087295667400c35 Mon Sep 17 00:00:00 2001 From: Nicolas Luck Date: Tue, 20 Feb 2024 23:40:47 +0100 Subject: [PATCH 2/7] activate debug outputs in p-diff-sync --- .../zomes/perspective_diff_sync/src/lib.rs | 7 ++++- .../src/link_adapter/pull.rs | 6 ++-- .../src/telepresence/signal.rs | 10 +++---- .../p-diff-sync/linksAdapter.ts | 29 +++++++++++-------- 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/lib.rs b/bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/lib.rs index a7423da8a..f3f2e10b3 100644 --- a/bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/lib.rs +++ b/bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/lib.rs @@ -101,15 +101,20 @@ pub fn update_current_revision(_hash: Hash) -> ExternResult<()> { #[hdk_extern] fn recv_send_remote_signal(signal: SerializedBytes) -> ExternResult<()> { + info!("recv_send_remote_signal"); //Check if its a normal diff expression signal match HashBroadcast::try_from(signal.clone()) { Ok(broadcast) => { + info!("recv_send_remote_signal broadcast: {:?}", broadcast); link_adapter::pull::handle_broadcast::(broadcast) .map_err(|err| utils::err(&format!("{}", err)))?; } //Check if its a broadcast message Err(_) => match PerspectiveExpression::try_from(signal.clone()) { - Ok(sig) => emit_signal(sig)?, + Ok(sig) => { + info!("recv_send_remote_signal signal: {:?}", sig); + emit_signal(sig)? + } //Check if its an online ping Err(_) => return Err(utils::err(&format!("Signal not recognized: {:?}", signal))), }, diff --git a/bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/link_adapter/pull.rs b/bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/link_adapter/pull.rs index 5897c3435..43c303507 100644 --- a/bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/link_adapter/pull.rs +++ b/bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/link_adapter/pull.rs @@ -214,7 +214,7 @@ pub fn pull( pub fn handle_broadcast( broadcast: HashBroadcast, ) -> SocialContextResult<()> { - // debug!("===PerspectiveDiffSync.fast_forward_signal(): Function start"); + debug!("===PerspectiveDiffSync.handle_broadcast(): Function start"); // let fn_start = get_now()?.time(); let diff_reference = broadcast.reference.clone(); let revision = broadcast.reference_hash.clone(); @@ -224,10 +224,10 @@ pub fn handle_broadcast( if current_revision.is_some() { let current_revision = current_revision.unwrap(); if revision == current_revision.hash { - // debug!("===PerspectiveDiffSync.fast_forward_signal(): Revision is the same as current"); + debug!("===PerspectiveDiffSync.handle_broadcast(): Revision is the same as current"); }; if diff_reference.parents == Some(vec![current_revision.hash]) { - // debug!("===PerspectiveDiffSync.fast_forward_signal(): Revisions parent is the same as current, we can fast forward our current"); + debug!("===PerspectiveDiffSync.handle_broadcast(): Revisions parent is the same as current, we can fast forward our current"); update_current_revision::(revision, get_now()?)?; emit_signal(broadcast.diff.clone())?; }; diff --git a/bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/telepresence/signal.rs b/bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/telepresence/signal.rs index e7d616970..b57c28cfe 100644 --- a/bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/telepresence/signal.rs +++ b/bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/telepresence/signal.rs @@ -7,10 +7,10 @@ use crate::{errors::SocialContextResult, inputs::SignalData}; pub fn send_signal(signal_data: SignalData) -> SocialContextResult { let agent = get_dids_agent_key(signal_data.remote_agent_did.clone())?; - // debug!( - // "PerspectiveDiffSync.send_signal() to DID: {:?} / HC: {:?}", - // signal_data.remote_agent_did, agent - // ); + debug!( + "PerspectiveDiffSync.send_signal() to DID: {:?} / HC: {:?}", + signal_data.remote_agent_did, agent + ); match agent { Some(agent) => send_remote_signal(signal_data.payload.clone().get_sb()?, vec![agent])?, None => { @@ -23,7 +23,7 @@ pub fn send_signal(signal_data: SignalData) -> SocialContextResult SocialContextResult { let active_agents = get_active_agents()?; - //debug!("PerspectiveDiffSync.send_broadcast() to: {:?}", active_agents); + debug!("PerspectiveDiffSync.send_broadcast() to: {:?}", active_agents); send_remote_signal(data.clone().get_sb()?, active_agents)?; Ok(data) diff --git a/bootstrap-languages/p-diff-sync/linksAdapter.ts b/bootstrap-languages/p-diff-sync/linksAdapter.ts index 05d64b24a..53764a557 100644 --- a/bootstrap-languages/p-diff-sync/linksAdapter.ts +++ b/bootstrap-languages/p-diff-sync/linksAdapter.ts @@ -50,9 +50,9 @@ export class LinkAdapter implements LinkSyncAdapter { } async sync(): Promise { - //console.log("PerspectiveDiffSync.sync(); Getting lock"); + console.log("PerspectiveDiffSync.sync(); Getting lock"); const release = await this.generalMutex.acquire(); - //console.log("PerspectiveDiffSync.sync(); Got lock"); + console.log("PerspectiveDiffSync.sync(); Got lock"); try { //@ts-ignore let current_revision = await this.hcDna.call(DNA_NICK, ZOME_NAME, "sync", null); @@ -70,6 +70,7 @@ export class LinkAdapter implements LinkSyncAdapter { } async gossip() { + console.log("PerspectiveDiffSync.gossip()"); this.gossipLogCount += 1; let lostPeers: DID[] = []; @@ -92,6 +93,8 @@ export class LinkAdapter implements LinkSyncAdapter { // Lexically sort the peers peers.sort(); + console.log("PerspectiveDiffSync.gossip(); peers:", peers); + // If we are the first peer, we are the scribe let is_scribe = peers[0] == this.me; @@ -193,6 +196,7 @@ export class LinkAdapter implements LinkSyncAdapter { } async commit(diff: PerspectiveDiff): Promise { + console.log("PerspectiveDiffSync.commit()"); //console.log("PerspectiveDiffSync.commit(); Getting lock"); const release = await this.generalMutex.acquire(); try { @@ -224,19 +228,20 @@ export class LinkAdapter implements LinkSyncAdapter { } async handleHolochainSignal(signal: any): Promise { + console.log("PerspectiveDiffSync.handleHolochainSignal(); signal", signal); const { diff, reference_hash, reference, broadcast_author } = signal.payload; //Check if this signal came from another agent & contains a diff and reference_hash if (diff && reference_hash && reference && broadcast_author) { - // console.log(`PerspectiveDiffSync.handleHolochainSignal: - // diff: ${JSON.stringify(diff)} - // reference_hash: ${reference_hash.toString('base64')} - // reference: { - // diff: ${reference.diff?.toString('base64')} - // parents: ${reference.parents ? reference.parents.map( (parent: Buffer) => parent ? parent.toString('base64') : 'null').join(', '):'none'} - // diffs_since_snapshot: ${reference?.diffs_since_snapshot} - // } - // broadcast_author: ${broadcast_author} - // `) + console.log(`PerspectiveDiffSync.handleHolochainSignal: + diff: ${JSON.stringify(diff)} + reference_hash: ${reference_hash.toString('base64')} + reference: { + diff: ${reference.diff?.toString('base64')} + parents: ${reference.parents ? reference.parents.map( (parent: Buffer) => parent ? parent.toString('base64') : 'null').join(', '):'none'} + diffs_since_snapshot: ${reference?.diffs_since_snapshot} + } + broadcast_author: ${broadcast_author} + `) try { //console.log("PerspectiveDiffSync.handleHolochainSignal: Getting lock"); From 4a933476d83c97fb38608e376f4cedab77186be7 Mon Sep 17 00:00:00 2001 From: Nicolas Luck Date: Tue, 20 Feb 2024 23:43:13 +0100 Subject: [PATCH 3/7] new network seed with debug p-diff-sync --- cli/mainnet_seed.json | 8 ++++---- rust-executor/src/mainnet_seed.json | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cli/mainnet_seed.json b/cli/mainnet_seed.json index a2f7e9bb6..70abec24b 100644 --- a/cli/mainnet_seed.json +++ b/cli/mainnet_seed.json @@ -4,12 +4,12 @@ "did:key:z6MkvPpWxwXAnLtMcoc9sX7GEoJ96oNnQ3VcQJRLspNJfpE7" ], "knownLinkLanguages": [ - "QmzSYwddewWW2BbWhreKBaok2LKPAAM6fvWnAov6kGXowEuRHjR", - "QmzSYwddGEumgdAgQGJhMA1uE2DfrnMEnNYMe3dn4kjdGJAmmEk", + "QmzSYwdok9VqCQC4zqLSLWmLhU3FN1C33aaq32972pz26YaF4uG", + "QmzSYwddjYfNpgFk69C1DfWeNc3uPS1rKNJEj5TqouhCcAgzPUx", "QmzSYwdnHrRH8MmuPWKKrDvFoVyW5CophNpT1ipQUCcenPVTQnd" ], - "directMessageLanguage": "QmzSYwdebMWD8484aQUB1KWLPqQGezbXWfcu1wMQu983e1ZgGG9", - "agentLanguage": "QmzSYwdZDdgxiyE8crozqbxoBP52h6ocMdDq2S2mg4ScjzVLWKQ", + "directMessageLanguage": "QmzSYwdnJwf8hHkdktTj2shuLcM712czTN7Y7LwKXyLa3mFqDvt", + "agentLanguage": "QmzSYwdYZaPyUT5iKuybkt6sfxPVaWXRS7vRwAyurev3XCYfAft", "perspectiveLanguage": "QmzSYwddxFCzVD63LgR8MTBaUEcwf9jhB3XjLbYBp2q8V1MqVtS", "neighbourhoodLanguage": "QmzSYwdo2a6E4XghRHrN5eCReyYRDeRE8VnRbvqgoWZsr9B4pxV", "languageLanguageBundle": "// https://deno.land/x/url_join@1.0.0/mod.ts\nvar urlJoin = function(...args) {\n let input;\n if (typeof args[0] === \"object\") {\n input = args[0];\n } else {\n input = [].slice.call(args);\n }\n return normalize(input);\n};\nvar normalize = (strArray) => {\n const resultArray = [];\n if (strArray.length === 0) {\n return \"\";\n }\n if (typeof strArray[0] !== \"string\") {\n throw new TypeError(\"Url must be a string. Received \" + strArray[0]);\n }\n if (strArray[0].match(/^[^/:]+:\\/*$/) && strArray.length > 1) {\n const first = strArray.shift();\n strArray[0] = first + strArray[0];\n }\n if (strArray[0].match(/^file:\\/\\/\\//)) {\n strArray[0] = strArray[0].replace(/^([^/:]+):\\/*/, \"$1:///\");\n } else {\n strArray[0] = strArray[0].replace(/^([^/:]+):\\/*/, \"$1://\");\n }\n for (let i = 0; i < strArray.length; i++) {\n let component = strArray[i];\n if (typeof component !== \"string\") {\n throw new TypeError(\"Url must be a string. Received \" + component);\n }\n if (component === \"\") {\n continue;\n }\n if (i > 0) {\n component = component.replace(/^[\\/]+/, \"\");\n }\n if (i < strArray.length - 1) {\n component = component.replace(/[\\/]+$/, \"\");\n } else {\n component = component.replace(/[\\/]+$/, \"/\");\n }\n resultArray.push(component);\n }\n let str = resultArray.join(\"/\");\n str = str.replace(/\\/(\\?|&|#[^!])/g, \"$1\");\n let parts = str.split(\"?\");\n str = parts.shift() + (parts.length > 0 ? \"?\" : \"\") + parts.join(\"&\");\n return str;\n};\n\n// https://deno.land/x/axiod@0.26.2/helpers.ts\nvar methods = [\n \"get\",\n \"post\",\n \"put\",\n \"delete\",\n \"options\",\n \"head\",\n \"connect\",\n \"trace\",\n \"patch\"\n];\nvar addInterceptor = () => {\n const interceptor = {\n list: [],\n use: function(fulfilled, rejected) {\n const id = this.list.length;\n this.list.push({\n fulfilled,\n rejected\n });\n return id;\n },\n eject: function(index) {\n if (this.list[index]) {\n this.list[index] = null;\n }\n }\n };\n return interceptor;\n};\n\n// https://deno.land/x/axiod@0.26.2/mod.ts\nfunction axiod(url, config) {\n if (typeof url === \"string\") {\n return axiod.request(Object.assign({}, axiod.defaults, { url }, config));\n }\n return axiod.request(Object.assign({}, axiod.defaults, url));\n}\naxiod.defaults = {\n url: \"/\",\n method: \"get\",\n timeout: 0,\n withCredentials: false,\n validateStatus: (status) => {\n return status >= 200 && status < 300;\n }\n};\naxiod.create = (config) => {\n const instance = axiod.bind({});\n instance.defaults = Object.assign({}, axiod.defaults, config);\n instance._request = request;\n instance.request = (options) => {\n return instance._request(Object.assign({}, instance.defaults, options));\n };\n instance.get = (url, config2) => {\n return instance.request(\n Object.assign({}, { url }, config2, { method: \"get\" })\n );\n };\n instance.post = (url, data, config2) => {\n return instance.request(\n Object.assign({}, { url }, config2, { method: \"post\", data })\n );\n };\n instance.put = (url, data, config2) => {\n return instance.request(\n Object.assign({}, { url }, config2, { method: \"put\", data })\n );\n };\n instance.delete = (url, data, config2) => {\n return instance.request(\n Object.assign({}, { url }, config2, { method: \"delete\", data })\n );\n };\n instance.options = (url, data, config2) => {\n return instance.request(\n Object.assign({}, { url }, config2, { method: \"options\", data })\n );\n };\n instance.head = (url, data, config2) => {\n return instance.request(\n Object.assign({}, { url }, config2, { method: \"head\", data })\n );\n };\n instance.connect = (url, data, config2) => {\n return instance.request(\n Object.assign({}, { url }, config2, { method: \"connect\", data })\n );\n };\n instance.trace = (url, data, config2) => {\n return instance.request(\n Object.assign({}, { url }, config2, { method: \"trace\", data })\n );\n };\n instance.patch = (url, data, config2) => {\n return instance.request(\n Object.assign({}, { url }, config2, { method: \"patch\", data })\n );\n };\n instance.interceptors = {\n request: addInterceptor(),\n response: addInterceptor()\n };\n instance.interceptors.request.list = [];\n instance.interceptors.response.list = [];\n return instance;\n};\nasync function request(config) {\n if (this.interceptors.request.list.length > 0) {\n for (const interceptor of this.interceptors.request.list) {\n if (interceptor) {\n const { fulfilled } = interceptor;\n if (fulfilled && config) {\n config = await fulfilled(config);\n }\n }\n }\n }\n let {\n url = \"/\",\n baseURL,\n method,\n headers,\n params = {},\n data,\n timeout,\n withCredentials,\n auth,\n validateStatus,\n paramsSerializer,\n transformRequest,\n transformResponse,\n redirect,\n responseType = \"json\"\n } = config;\n if (baseURL) {\n url = urlJoin(baseURL, url);\n }\n if (method) {\n if (methods.indexOf(method.toLowerCase().trim()) === -1) {\n throw new Error(`Method ${method} is not supported`);\n } else {\n method = method.toLowerCase().trim();\n }\n } else {\n method = \"get\";\n }\n let _params = \"\";\n if (params) {\n if (paramsSerializer) {\n _params = paramsSerializer(params);\n } else {\n _params = Object.keys(params).map((key) => {\n return encodeURIComponent(key) + \"=\" + encodeURIComponent(params[key]);\n }).join(\"&\");\n }\n }\n if (withCredentials) {\n if (auth?.username && auth?.password) {\n if (!headers) {\n headers = {};\n }\n headers[\"Authorization\"] = \"Basic \" + btoa(unescape(encodeURIComponent(`${auth.username}:${auth.password}`)));\n }\n }\n const fetchRequestObject = {};\n if (method !== \"get\") {\n fetchRequestObject.method = method.toUpperCase();\n }\n if (_params) {\n url = urlJoin(url, `?${_params}`);\n }\n if (data && method !== \"get\") {\n if (transformRequest && Array.isArray(transformRequest) && transformRequest.length > 0) {\n for (var i = 0; i < (transformRequest || []).length; i++) {\n if (transformRequest && transformRequest[i]) {\n data = transformRequest[i](data, headers);\n }\n }\n }\n if (typeof data === \"string\" || data instanceof FormData || data instanceof URLSearchParams) {\n fetchRequestObject.body = data;\n } else {\n try {\n fetchRequestObject.body = JSON.stringify(data);\n if (!headers) {\n headers = {};\n }\n headers[\"Accept\"] = \"application/json\";\n headers[\"Content-Type\"] = \"application/json\";\n } catch (ex) {\n }\n }\n }\n if (headers) {\n const _headers = new Headers();\n Object.keys(headers).forEach((header) => {\n if (headers && headers[header]) {\n _headers.set(header, headers[header]);\n }\n });\n fetchRequestObject.headers = _headers;\n }\n const controller = new AbortController();\n fetchRequestObject.signal = controller.signal;\n let timeoutCounter = 0;\n if ((timeout || 0) > 0) {\n timeoutCounter = setTimeout(() => {\n timeoutCounter = 0;\n controller.abort();\n }, timeout);\n }\n if (redirect) {\n fetchRequestObject.redirect = redirect;\n }\n return fetch(url, fetchRequestObject).then(async (x) => {\n if (timeoutCounter) {\n clearTimeout(timeoutCounter);\n }\n const _status = x.status;\n const _statusText = x.statusText;\n let _data = null;\n try {\n const response2 = x.clone();\n if (responseType === \"json\") {\n _data = await response2.json();\n } else if (responseType === \"text\") {\n _data = await response2.text();\n } else if (responseType === \"arraybuffer\") {\n _data = await response2.arrayBuffer();\n } else if (responseType === \"blob\") {\n _data = await response2.blob();\n } else if (responseType === \"stream\") {\n _data = (await response2.blob()).stream();\n } else {\n _data = await response2.text();\n }\n } catch (ex) {\n _data = await x.clone().text();\n }\n if (transformResponse) {\n if (transformResponse && Array.isArray(transformResponse) && transformResponse.length > 0) {\n for (var i2 = 0; i2 < (transformResponse || []).length; i2++) {\n if (transformResponse && transformResponse[i2]) {\n _data = transformResponse[i2](_data);\n }\n }\n }\n }\n const _headers = x.headers;\n const _config = {\n url,\n baseURL,\n method,\n headers,\n params,\n data,\n timeout,\n withCredentials,\n auth,\n paramsSerializer,\n redirect,\n responseType\n };\n let isValidStatus = true;\n if (validateStatus) {\n isValidStatus = validateStatus(_status);\n } else {\n isValidStatus = _status >= 200 && _status <= 303;\n }\n let response = null;\n let error = null;\n if (isValidStatus) {\n response = {\n status: _status,\n statusText: _statusText,\n data: _data,\n headers: _headers,\n config: _config\n };\n } else {\n error = {\n response: {\n status: _status,\n statusText: _statusText,\n data: _data,\n headers: _headers\n },\n config: _config\n };\n }\n if (this.interceptors.response.list.length > 0) {\n for (const interceptor of this.interceptors.response.list) {\n if (interceptor) {\n const { fulfilled, rejected } = interceptor;\n if (fulfilled && response) {\n response = await fulfilled(response);\n }\n if (rejected && error) {\n error = await rejected(error);\n }\n }\n }\n }\n if (error) {\n return Promise.reject(error);\n }\n return Promise.resolve(response);\n });\n}\naxiod._request = request;\naxiod.request = request;\naxiod.get = (url, config) => {\n return axiod.request(\n Object.assign({}, { url }, config, { method: \"get\" })\n );\n};\naxiod.post = (url, data, config) => {\n return axiod.request(\n Object.assign({}, { url }, config, { method: \"post\", data })\n );\n};\naxiod.put = (url, data, config) => {\n return axiod.request(\n Object.assign({}, { url }, config, { method: \"put\", data })\n );\n};\naxiod.delete = (url, data, config) => {\n return axiod.request(\n Object.assign({}, { url }, config, { method: \"delete\", data })\n );\n};\naxiod.options = (url, data, config) => {\n return axiod.request(\n Object.assign({}, { url }, config, { method: \"options\", data })\n );\n};\naxiod.head = (url, data, config) => {\n return axiod.request(\n Object.assign({}, { url }, config, { method: \"head\", data })\n );\n};\naxiod.connect = (url, data, config) => {\n return axiod.request(\n Object.assign({}, { url }, config, { method: \"connect\", data })\n );\n};\naxiod.trace = (url, data, config) => {\n return axiod.request(\n Object.assign({}, { url }, config, { method: \"trace\", data })\n );\n};\naxiod.patch = (url, data, config) => {\n return axiod.request(\n Object.assign({}, { url }, config, { method: \"patch\", data })\n );\n};\naxiod.interceptors = {\n request: addInterceptor(),\n response: addInterceptor()\n};\nvar mod_default = axiod;\n\n// languageAdapter.ts\nvar LangAdapter = class {\n constructor(context) {\n }\n async getLanguageSource(address) {\n if (address.substring(0, 2) != \"Qm\") {\n console.error(\"LanguageLanguage.getLanguageSource(): The address is not a valid hash\");\n return \"\";\n }\n const cid = address.toString();\n let presignedUrl;\n try {\n const getPresignedUrl = await mod_default.get(PROXY_URL + `?key=${cid}`);\n presignedUrl = getPresignedUrl.data.url;\n } catch (e) {\n console.error(\"Get language source failed at getting presigned url\", address);\n throw e;\n }\n let languageSource;\n try {\n const getLanguageSource = await mod_default.get(presignedUrl);\n languageSource = getLanguageSource.data;\n } catch (e) {\n console.error(\"Get language source failed at getting language source\", address);\n throw e;\n }\n return languageSource;\n }\n};\n\n// putAdapter.ts\nvar CloudflarePutAdapter = class {\n #agent;\n constructor(context) {\n this.#agent = context.agent;\n }\n async createPublic(language) {\n const hash = UTILS.hash(language.bundle.toString());\n if (hash != language.meta.address)\n throw new Error(`Language Persistence: Can't store language. Address stated in meta differs from actual file\nWanted: ${language.meta.address}\nGot: ${hash}`);\n const agent = this.#agent;\n const expression = agent.createSignedExpression(language.meta);\n const key = `meta-${hash}`;\n const metaPostData = {\n key,\n // Content of the new object.\n value: JSON.stringify(expression)\n };\n try {\n const metaPostResult = await mod_default.post(PROXY_URL, metaPostData);\n if (metaPostResult.status != 200) {\n console.error(\"Upload language meta data gets error: \", metaPostResult);\n }\n const languageBundleBucketParams = {\n key: hash,\n // Content of the new object.\n value: language.bundle.toString()\n };\n const bundlePostResult = await mod_default.post(PROXY_URL, languageBundleBucketParams);\n if (bundlePostResult.status != 200) {\n console.error(\"Upload language bundle data gets error: \", metaPostResult);\n }\n return hash;\n } catch (e) {\n if (e.response.status == 400 && e.response.data.includes(\"Key already exists\")) {\n console.log(\"[Cloudflare-based Language Language]: Tried to replace existing language. Ignoring...\");\n return hash;\n }\n console.error(\"[Cloudflare-based Language Language]: Error storing Language: \", e.response.data);\n throw e;\n }\n }\n};\n\n// adapter.ts\nvar Adapter = class {\n constructor(context) {\n this.putAdapter = new CloudflarePutAdapter(context);\n }\n async get(address) {\n if (address.substring(0, 2) != \"Qm\") {\n console.error(\"LanguageLanguage.get(): The address is not a valid hash\");\n return null;\n }\n const metaDataKey = `meta-${address}`;\n let presignedUrl;\n try {\n const getPresignedUrl = await mod_default.get(PROXY_URL + `?key=${metaDataKey}`);\n presignedUrl = getPresignedUrl.data.url;\n } catch (e) {\n console.error(\"Get meta information failed at getting presigned url\", address);\n return null;\n }\n let metaObject;\n try {\n const getMetaObject = await mod_default.get(presignedUrl);\n metaObject = getMetaObject.data;\n } catch (e) {\n console.error(\"Get meta information failed at getting meta information\", presignedUrl);\n return null;\n }\n return metaObject;\n }\n};\n\n// index.ts\nvar name = \"languages\";\nvar PROXY_URL = \"https://bootstrap-store-gateway.perspect3vism.workers.dev\";\nfunction interactions(expression) {\n return [];\n}\nasync function create(context) {\n const expressionAdapter = new Adapter(context);\n const languageAdapter = new LangAdapter(context);\n return {\n name,\n expressionAdapter,\n languageAdapter,\n interactions\n };\n}\nexport {\n PROXY_URL,\n create as default,\n name\n};\n" diff --git a/rust-executor/src/mainnet_seed.json b/rust-executor/src/mainnet_seed.json index a2f7e9bb6..70abec24b 100644 --- a/rust-executor/src/mainnet_seed.json +++ b/rust-executor/src/mainnet_seed.json @@ -4,12 +4,12 @@ "did:key:z6MkvPpWxwXAnLtMcoc9sX7GEoJ96oNnQ3VcQJRLspNJfpE7" ], "knownLinkLanguages": [ - "QmzSYwddewWW2BbWhreKBaok2LKPAAM6fvWnAov6kGXowEuRHjR", - "QmzSYwddGEumgdAgQGJhMA1uE2DfrnMEnNYMe3dn4kjdGJAmmEk", + "QmzSYwdok9VqCQC4zqLSLWmLhU3FN1C33aaq32972pz26YaF4uG", + "QmzSYwddjYfNpgFk69C1DfWeNc3uPS1rKNJEj5TqouhCcAgzPUx", "QmzSYwdnHrRH8MmuPWKKrDvFoVyW5CophNpT1ipQUCcenPVTQnd" ], - "directMessageLanguage": "QmzSYwdebMWD8484aQUB1KWLPqQGezbXWfcu1wMQu983e1ZgGG9", - "agentLanguage": "QmzSYwdZDdgxiyE8crozqbxoBP52h6ocMdDq2S2mg4ScjzVLWKQ", + "directMessageLanguage": "QmzSYwdnJwf8hHkdktTj2shuLcM712czTN7Y7LwKXyLa3mFqDvt", + "agentLanguage": "QmzSYwdYZaPyUT5iKuybkt6sfxPVaWXRS7vRwAyurev3XCYfAft", "perspectiveLanguage": "QmzSYwddxFCzVD63LgR8MTBaUEcwf9jhB3XjLbYBp2q8V1MqVtS", "neighbourhoodLanguage": "QmzSYwdo2a6E4XghRHrN5eCReyYRDeRE8VnRbvqgoWZsr9B4pxV", "languageLanguageBundle": "// https://deno.land/x/url_join@1.0.0/mod.ts\nvar urlJoin = function(...args) {\n let input;\n if (typeof args[0] === \"object\") {\n input = args[0];\n } else {\n input = [].slice.call(args);\n }\n return normalize(input);\n};\nvar normalize = (strArray) => {\n const resultArray = [];\n if (strArray.length === 0) {\n return \"\";\n }\n if (typeof strArray[0] !== \"string\") {\n throw new TypeError(\"Url must be a string. Received \" + strArray[0]);\n }\n if (strArray[0].match(/^[^/:]+:\\/*$/) && strArray.length > 1) {\n const first = strArray.shift();\n strArray[0] = first + strArray[0];\n }\n if (strArray[0].match(/^file:\\/\\/\\//)) {\n strArray[0] = strArray[0].replace(/^([^/:]+):\\/*/, \"$1:///\");\n } else {\n strArray[0] = strArray[0].replace(/^([^/:]+):\\/*/, \"$1://\");\n }\n for (let i = 0; i < strArray.length; i++) {\n let component = strArray[i];\n if (typeof component !== \"string\") {\n throw new TypeError(\"Url must be a string. Received \" + component);\n }\n if (component === \"\") {\n continue;\n }\n if (i > 0) {\n component = component.replace(/^[\\/]+/, \"\");\n }\n if (i < strArray.length - 1) {\n component = component.replace(/[\\/]+$/, \"\");\n } else {\n component = component.replace(/[\\/]+$/, \"/\");\n }\n resultArray.push(component);\n }\n let str = resultArray.join(\"/\");\n str = str.replace(/\\/(\\?|&|#[^!])/g, \"$1\");\n let parts = str.split(\"?\");\n str = parts.shift() + (parts.length > 0 ? \"?\" : \"\") + parts.join(\"&\");\n return str;\n};\n\n// https://deno.land/x/axiod@0.26.2/helpers.ts\nvar methods = [\n \"get\",\n \"post\",\n \"put\",\n \"delete\",\n \"options\",\n \"head\",\n \"connect\",\n \"trace\",\n \"patch\"\n];\nvar addInterceptor = () => {\n const interceptor = {\n list: [],\n use: function(fulfilled, rejected) {\n const id = this.list.length;\n this.list.push({\n fulfilled,\n rejected\n });\n return id;\n },\n eject: function(index) {\n if (this.list[index]) {\n this.list[index] = null;\n }\n }\n };\n return interceptor;\n};\n\n// https://deno.land/x/axiod@0.26.2/mod.ts\nfunction axiod(url, config) {\n if (typeof url === \"string\") {\n return axiod.request(Object.assign({}, axiod.defaults, { url }, config));\n }\n return axiod.request(Object.assign({}, axiod.defaults, url));\n}\naxiod.defaults = {\n url: \"/\",\n method: \"get\",\n timeout: 0,\n withCredentials: false,\n validateStatus: (status) => {\n return status >= 200 && status < 300;\n }\n};\naxiod.create = (config) => {\n const instance = axiod.bind({});\n instance.defaults = Object.assign({}, axiod.defaults, config);\n instance._request = request;\n instance.request = (options) => {\n return instance._request(Object.assign({}, instance.defaults, options));\n };\n instance.get = (url, config2) => {\n return instance.request(\n Object.assign({}, { url }, config2, { method: \"get\" })\n );\n };\n instance.post = (url, data, config2) => {\n return instance.request(\n Object.assign({}, { url }, config2, { method: \"post\", data })\n );\n };\n instance.put = (url, data, config2) => {\n return instance.request(\n Object.assign({}, { url }, config2, { method: \"put\", data })\n );\n };\n instance.delete = (url, data, config2) => {\n return instance.request(\n Object.assign({}, { url }, config2, { method: \"delete\", data })\n );\n };\n instance.options = (url, data, config2) => {\n return instance.request(\n Object.assign({}, { url }, config2, { method: \"options\", data })\n );\n };\n instance.head = (url, data, config2) => {\n return instance.request(\n Object.assign({}, { url }, config2, { method: \"head\", data })\n );\n };\n instance.connect = (url, data, config2) => {\n return instance.request(\n Object.assign({}, { url }, config2, { method: \"connect\", data })\n );\n };\n instance.trace = (url, data, config2) => {\n return instance.request(\n Object.assign({}, { url }, config2, { method: \"trace\", data })\n );\n };\n instance.patch = (url, data, config2) => {\n return instance.request(\n Object.assign({}, { url }, config2, { method: \"patch\", data })\n );\n };\n instance.interceptors = {\n request: addInterceptor(),\n response: addInterceptor()\n };\n instance.interceptors.request.list = [];\n instance.interceptors.response.list = [];\n return instance;\n};\nasync function request(config) {\n if (this.interceptors.request.list.length > 0) {\n for (const interceptor of this.interceptors.request.list) {\n if (interceptor) {\n const { fulfilled } = interceptor;\n if (fulfilled && config) {\n config = await fulfilled(config);\n }\n }\n }\n }\n let {\n url = \"/\",\n baseURL,\n method,\n headers,\n params = {},\n data,\n timeout,\n withCredentials,\n auth,\n validateStatus,\n paramsSerializer,\n transformRequest,\n transformResponse,\n redirect,\n responseType = \"json\"\n } = config;\n if (baseURL) {\n url = urlJoin(baseURL, url);\n }\n if (method) {\n if (methods.indexOf(method.toLowerCase().trim()) === -1) {\n throw new Error(`Method ${method} is not supported`);\n } else {\n method = method.toLowerCase().trim();\n }\n } else {\n method = \"get\";\n }\n let _params = \"\";\n if (params) {\n if (paramsSerializer) {\n _params = paramsSerializer(params);\n } else {\n _params = Object.keys(params).map((key) => {\n return encodeURIComponent(key) + \"=\" + encodeURIComponent(params[key]);\n }).join(\"&\");\n }\n }\n if (withCredentials) {\n if (auth?.username && auth?.password) {\n if (!headers) {\n headers = {};\n }\n headers[\"Authorization\"] = \"Basic \" + btoa(unescape(encodeURIComponent(`${auth.username}:${auth.password}`)));\n }\n }\n const fetchRequestObject = {};\n if (method !== \"get\") {\n fetchRequestObject.method = method.toUpperCase();\n }\n if (_params) {\n url = urlJoin(url, `?${_params}`);\n }\n if (data && method !== \"get\") {\n if (transformRequest && Array.isArray(transformRequest) && transformRequest.length > 0) {\n for (var i = 0; i < (transformRequest || []).length; i++) {\n if (transformRequest && transformRequest[i]) {\n data = transformRequest[i](data, headers);\n }\n }\n }\n if (typeof data === \"string\" || data instanceof FormData || data instanceof URLSearchParams) {\n fetchRequestObject.body = data;\n } else {\n try {\n fetchRequestObject.body = JSON.stringify(data);\n if (!headers) {\n headers = {};\n }\n headers[\"Accept\"] = \"application/json\";\n headers[\"Content-Type\"] = \"application/json\";\n } catch (ex) {\n }\n }\n }\n if (headers) {\n const _headers = new Headers();\n Object.keys(headers).forEach((header) => {\n if (headers && headers[header]) {\n _headers.set(header, headers[header]);\n }\n });\n fetchRequestObject.headers = _headers;\n }\n const controller = new AbortController();\n fetchRequestObject.signal = controller.signal;\n let timeoutCounter = 0;\n if ((timeout || 0) > 0) {\n timeoutCounter = setTimeout(() => {\n timeoutCounter = 0;\n controller.abort();\n }, timeout);\n }\n if (redirect) {\n fetchRequestObject.redirect = redirect;\n }\n return fetch(url, fetchRequestObject).then(async (x) => {\n if (timeoutCounter) {\n clearTimeout(timeoutCounter);\n }\n const _status = x.status;\n const _statusText = x.statusText;\n let _data = null;\n try {\n const response2 = x.clone();\n if (responseType === \"json\") {\n _data = await response2.json();\n } else if (responseType === \"text\") {\n _data = await response2.text();\n } else if (responseType === \"arraybuffer\") {\n _data = await response2.arrayBuffer();\n } else if (responseType === \"blob\") {\n _data = await response2.blob();\n } else if (responseType === \"stream\") {\n _data = (await response2.blob()).stream();\n } else {\n _data = await response2.text();\n }\n } catch (ex) {\n _data = await x.clone().text();\n }\n if (transformResponse) {\n if (transformResponse && Array.isArray(transformResponse) && transformResponse.length > 0) {\n for (var i2 = 0; i2 < (transformResponse || []).length; i2++) {\n if (transformResponse && transformResponse[i2]) {\n _data = transformResponse[i2](_data);\n }\n }\n }\n }\n const _headers = x.headers;\n const _config = {\n url,\n baseURL,\n method,\n headers,\n params,\n data,\n timeout,\n withCredentials,\n auth,\n paramsSerializer,\n redirect,\n responseType\n };\n let isValidStatus = true;\n if (validateStatus) {\n isValidStatus = validateStatus(_status);\n } else {\n isValidStatus = _status >= 200 && _status <= 303;\n }\n let response = null;\n let error = null;\n if (isValidStatus) {\n response = {\n status: _status,\n statusText: _statusText,\n data: _data,\n headers: _headers,\n config: _config\n };\n } else {\n error = {\n response: {\n status: _status,\n statusText: _statusText,\n data: _data,\n headers: _headers\n },\n config: _config\n };\n }\n if (this.interceptors.response.list.length > 0) {\n for (const interceptor of this.interceptors.response.list) {\n if (interceptor) {\n const { fulfilled, rejected } = interceptor;\n if (fulfilled && response) {\n response = await fulfilled(response);\n }\n if (rejected && error) {\n error = await rejected(error);\n }\n }\n }\n }\n if (error) {\n return Promise.reject(error);\n }\n return Promise.resolve(response);\n });\n}\naxiod._request = request;\naxiod.request = request;\naxiod.get = (url, config) => {\n return axiod.request(\n Object.assign({}, { url }, config, { method: \"get\" })\n );\n};\naxiod.post = (url, data, config) => {\n return axiod.request(\n Object.assign({}, { url }, config, { method: \"post\", data })\n );\n};\naxiod.put = (url, data, config) => {\n return axiod.request(\n Object.assign({}, { url }, config, { method: \"put\", data })\n );\n};\naxiod.delete = (url, data, config) => {\n return axiod.request(\n Object.assign({}, { url }, config, { method: \"delete\", data })\n );\n};\naxiod.options = (url, data, config) => {\n return axiod.request(\n Object.assign({}, { url }, config, { method: \"options\", data })\n );\n};\naxiod.head = (url, data, config) => {\n return axiod.request(\n Object.assign({}, { url }, config, { method: \"head\", data })\n );\n};\naxiod.connect = (url, data, config) => {\n return axiod.request(\n Object.assign({}, { url }, config, { method: \"connect\", data })\n );\n};\naxiod.trace = (url, data, config) => {\n return axiod.request(\n Object.assign({}, { url }, config, { method: \"trace\", data })\n );\n};\naxiod.patch = (url, data, config) => {\n return axiod.request(\n Object.assign({}, { url }, config, { method: \"patch\", data })\n );\n};\naxiod.interceptors = {\n request: addInterceptor(),\n response: addInterceptor()\n};\nvar mod_default = axiod;\n\n// languageAdapter.ts\nvar LangAdapter = class {\n constructor(context) {\n }\n async getLanguageSource(address) {\n if (address.substring(0, 2) != \"Qm\") {\n console.error(\"LanguageLanguage.getLanguageSource(): The address is not a valid hash\");\n return \"\";\n }\n const cid = address.toString();\n let presignedUrl;\n try {\n const getPresignedUrl = await mod_default.get(PROXY_URL + `?key=${cid}`);\n presignedUrl = getPresignedUrl.data.url;\n } catch (e) {\n console.error(\"Get language source failed at getting presigned url\", address);\n throw e;\n }\n let languageSource;\n try {\n const getLanguageSource = await mod_default.get(presignedUrl);\n languageSource = getLanguageSource.data;\n } catch (e) {\n console.error(\"Get language source failed at getting language source\", address);\n throw e;\n }\n return languageSource;\n }\n};\n\n// putAdapter.ts\nvar CloudflarePutAdapter = class {\n #agent;\n constructor(context) {\n this.#agent = context.agent;\n }\n async createPublic(language) {\n const hash = UTILS.hash(language.bundle.toString());\n if (hash != language.meta.address)\n throw new Error(`Language Persistence: Can't store language. Address stated in meta differs from actual file\nWanted: ${language.meta.address}\nGot: ${hash}`);\n const agent = this.#agent;\n const expression = agent.createSignedExpression(language.meta);\n const key = `meta-${hash}`;\n const metaPostData = {\n key,\n // Content of the new object.\n value: JSON.stringify(expression)\n };\n try {\n const metaPostResult = await mod_default.post(PROXY_URL, metaPostData);\n if (metaPostResult.status != 200) {\n console.error(\"Upload language meta data gets error: \", metaPostResult);\n }\n const languageBundleBucketParams = {\n key: hash,\n // Content of the new object.\n value: language.bundle.toString()\n };\n const bundlePostResult = await mod_default.post(PROXY_URL, languageBundleBucketParams);\n if (bundlePostResult.status != 200) {\n console.error(\"Upload language bundle data gets error: \", metaPostResult);\n }\n return hash;\n } catch (e) {\n if (e.response.status == 400 && e.response.data.includes(\"Key already exists\")) {\n console.log(\"[Cloudflare-based Language Language]: Tried to replace existing language. Ignoring...\");\n return hash;\n }\n console.error(\"[Cloudflare-based Language Language]: Error storing Language: \", e.response.data);\n throw e;\n }\n }\n};\n\n// adapter.ts\nvar Adapter = class {\n constructor(context) {\n this.putAdapter = new CloudflarePutAdapter(context);\n }\n async get(address) {\n if (address.substring(0, 2) != \"Qm\") {\n console.error(\"LanguageLanguage.get(): The address is not a valid hash\");\n return null;\n }\n const metaDataKey = `meta-${address}`;\n let presignedUrl;\n try {\n const getPresignedUrl = await mod_default.get(PROXY_URL + `?key=${metaDataKey}`);\n presignedUrl = getPresignedUrl.data.url;\n } catch (e) {\n console.error(\"Get meta information failed at getting presigned url\", address);\n return null;\n }\n let metaObject;\n try {\n const getMetaObject = await mod_default.get(presignedUrl);\n metaObject = getMetaObject.data;\n } catch (e) {\n console.error(\"Get meta information failed at getting meta information\", presignedUrl);\n return null;\n }\n return metaObject;\n }\n};\n\n// index.ts\nvar name = \"languages\";\nvar PROXY_URL = \"https://bootstrap-store-gateway.perspect3vism.workers.dev\";\nfunction interactions(expression) {\n return [];\n}\nasync function create(context) {\n const expressionAdapter = new Adapter(context);\n const languageAdapter = new LangAdapter(context);\n return {\n name,\n expressionAdapter,\n languageAdapter,\n interactions\n };\n}\nexport {\n PROXY_URL,\n create as default,\n name\n};\n" From 455801a5bacae134d34cef74ff00a636fe79b99d Mon Sep 17 00:00:00 2001 From: Nicolas Luck Date: Wed, 21 Feb 2024 00:22:53 +0100 Subject: [PATCH 4/7] Rename recv_send_remote_signal to recv_remote_signal --- .../hc-dna/zomes/perspective_diff_sync/src/lib.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/lib.rs b/bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/lib.rs index f3f2e10b3..57e76eaa6 100644 --- a/bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/lib.rs +++ b/bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/lib.rs @@ -27,7 +27,7 @@ fn init(_: ()) -> ExternResult { let mut functions = BTreeSet::new(); functions.insert((zome_info()?.name, "get_online_status".into())); //TODO; is this next function needed? - functions.insert((zome_info()?.name, "recv_send_remote_signal".into())); + functions.insert((zome_info()?.name, "recv_remote_signal".into())); let functions: GrantedFunctions = GrantedFunctions::Listed(functions); @@ -100,19 +100,19 @@ pub fn update_current_revision(_hash: Hash) -> ExternResult<()> { /// Signal handling #[hdk_extern] -fn recv_send_remote_signal(signal: SerializedBytes) -> ExternResult<()> { - info!("recv_send_remote_signal"); +fn recv_remote_signal(signal: SerializedBytes) -> ExternResult<()> { + info!("recv_remote_signal"); //Check if its a normal diff expression signal match HashBroadcast::try_from(signal.clone()) { Ok(broadcast) => { - info!("recv_send_remote_signal broadcast: {:?}", broadcast); + info!("recv_remote_signal broadcast: {:?}", broadcast); link_adapter::pull::handle_broadcast::(broadcast) .map_err(|err| utils::err(&format!("{}", err)))?; } //Check if its a broadcast message Err(_) => match PerspectiveExpression::try_from(signal.clone()) { Ok(sig) => { - info!("recv_send_remote_signal signal: {:?}", sig); + info!("recv_remote_signal signal: {:?}", sig); emit_signal(sig)? } //Check if its an online ping From 359d0d98809ef4d38aea904b4dc0b98cd2c8f5be Mon Sep 17 00:00:00 2001 From: Nicolas Luck Date: Wed, 21 Feb 2024 00:25:05 +0100 Subject: [PATCH 5/7] new mainnet seed with recv_remote_signal fix --- cli/mainnet_seed.json | 2 +- rust-executor/src/mainnet_seed.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/mainnet_seed.json b/cli/mainnet_seed.json index 70abec24b..912c54533 100644 --- a/cli/mainnet_seed.json +++ b/cli/mainnet_seed.json @@ -4,7 +4,7 @@ "did:key:z6MkvPpWxwXAnLtMcoc9sX7GEoJ96oNnQ3VcQJRLspNJfpE7" ], "knownLinkLanguages": [ - "QmzSYwdok9VqCQC4zqLSLWmLhU3FN1C33aaq32972pz26YaF4uG", + "QmzSYwdngLyetZj89L1Kv2Y2bsBDAPKC7JBGTpwNAiuiPMX8DPX", "QmzSYwddjYfNpgFk69C1DfWeNc3uPS1rKNJEj5TqouhCcAgzPUx", "QmzSYwdnHrRH8MmuPWKKrDvFoVyW5CophNpT1ipQUCcenPVTQnd" ], diff --git a/rust-executor/src/mainnet_seed.json b/rust-executor/src/mainnet_seed.json index 70abec24b..912c54533 100644 --- a/rust-executor/src/mainnet_seed.json +++ b/rust-executor/src/mainnet_seed.json @@ -4,7 +4,7 @@ "did:key:z6MkvPpWxwXAnLtMcoc9sX7GEoJ96oNnQ3VcQJRLspNJfpE7" ], "knownLinkLanguages": [ - "QmzSYwdok9VqCQC4zqLSLWmLhU3FN1C33aaq32972pz26YaF4uG", + "QmzSYwdngLyetZj89L1Kv2Y2bsBDAPKC7JBGTpwNAiuiPMX8DPX", "QmzSYwddjYfNpgFk69C1DfWeNc3uPS1rKNJEj5TqouhCcAgzPUx", "QmzSYwdnHrRH8MmuPWKKrDvFoVyW5CophNpT1ipQUCcenPVTQnd" ], From d0b34a7a8e64b542cd6544f24c46d2182fca6f8e Mon Sep 17 00:00:00 2001 From: Nicolas Luck Date: Wed, 21 Feb 2024 01:06:41 +0100 Subject: [PATCH 6/7] Revert "activate debug outputs in p-diff-sync" This reverts commit 89255999dd7f8baafdcc619f8087295667400c35. # Conflicts: # bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/lib.rs --- .../zomes/perspective_diff_sync/src/lib.rs | 6 +--- .../src/link_adapter/pull.rs | 6 ++-- .../src/telepresence/signal.rs | 10 +++---- .../p-diff-sync/linksAdapter.ts | 29 ++++++++----------- 4 files changed, 21 insertions(+), 30 deletions(-) diff --git a/bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/lib.rs b/bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/lib.rs index 57e76eaa6..02caea79f 100644 --- a/bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/lib.rs +++ b/bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/lib.rs @@ -101,7 +101,6 @@ pub fn update_current_revision(_hash: Hash) -> ExternResult<()> { #[hdk_extern] fn recv_remote_signal(signal: SerializedBytes) -> ExternResult<()> { - info!("recv_remote_signal"); //Check if its a normal diff expression signal match HashBroadcast::try_from(signal.clone()) { Ok(broadcast) => { @@ -111,10 +110,7 @@ fn recv_remote_signal(signal: SerializedBytes) -> ExternResult<()> { } //Check if its a broadcast message Err(_) => match PerspectiveExpression::try_from(signal.clone()) { - Ok(sig) => { - info!("recv_remote_signal signal: {:?}", sig); - emit_signal(sig)? - } + Ok(sig) => emit_signal(sig)?, //Check if its an online ping Err(_) => return Err(utils::err(&format!("Signal not recognized: {:?}", signal))), }, diff --git a/bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/link_adapter/pull.rs b/bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/link_adapter/pull.rs index 43c303507..5897c3435 100644 --- a/bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/link_adapter/pull.rs +++ b/bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/link_adapter/pull.rs @@ -214,7 +214,7 @@ pub fn pull( pub fn handle_broadcast( broadcast: HashBroadcast, ) -> SocialContextResult<()> { - debug!("===PerspectiveDiffSync.handle_broadcast(): Function start"); + // debug!("===PerspectiveDiffSync.fast_forward_signal(): Function start"); // let fn_start = get_now()?.time(); let diff_reference = broadcast.reference.clone(); let revision = broadcast.reference_hash.clone(); @@ -224,10 +224,10 @@ pub fn handle_broadcast( if current_revision.is_some() { let current_revision = current_revision.unwrap(); if revision == current_revision.hash { - debug!("===PerspectiveDiffSync.handle_broadcast(): Revision is the same as current"); + // debug!("===PerspectiveDiffSync.fast_forward_signal(): Revision is the same as current"); }; if diff_reference.parents == Some(vec![current_revision.hash]) { - debug!("===PerspectiveDiffSync.handle_broadcast(): Revisions parent is the same as current, we can fast forward our current"); + // debug!("===PerspectiveDiffSync.fast_forward_signal(): Revisions parent is the same as current, we can fast forward our current"); update_current_revision::(revision, get_now()?)?; emit_signal(broadcast.diff.clone())?; }; diff --git a/bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/telepresence/signal.rs b/bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/telepresence/signal.rs index b57c28cfe..e7d616970 100644 --- a/bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/telepresence/signal.rs +++ b/bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/telepresence/signal.rs @@ -7,10 +7,10 @@ use crate::{errors::SocialContextResult, inputs::SignalData}; pub fn send_signal(signal_data: SignalData) -> SocialContextResult { let agent = get_dids_agent_key(signal_data.remote_agent_did.clone())?; - debug!( - "PerspectiveDiffSync.send_signal() to DID: {:?} / HC: {:?}", - signal_data.remote_agent_did, agent - ); + // debug!( + // "PerspectiveDiffSync.send_signal() to DID: {:?} / HC: {:?}", + // signal_data.remote_agent_did, agent + // ); match agent { Some(agent) => send_remote_signal(signal_data.payload.clone().get_sb()?, vec![agent])?, None => { @@ -23,7 +23,7 @@ pub fn send_signal(signal_data: SignalData) -> SocialContextResult SocialContextResult { let active_agents = get_active_agents()?; - debug!("PerspectiveDiffSync.send_broadcast() to: {:?}", active_agents); + //debug!("PerspectiveDiffSync.send_broadcast() to: {:?}", active_agents); send_remote_signal(data.clone().get_sb()?, active_agents)?; Ok(data) diff --git a/bootstrap-languages/p-diff-sync/linksAdapter.ts b/bootstrap-languages/p-diff-sync/linksAdapter.ts index 53764a557..05d64b24a 100644 --- a/bootstrap-languages/p-diff-sync/linksAdapter.ts +++ b/bootstrap-languages/p-diff-sync/linksAdapter.ts @@ -50,9 +50,9 @@ export class LinkAdapter implements LinkSyncAdapter { } async sync(): Promise { - console.log("PerspectiveDiffSync.sync(); Getting lock"); + //console.log("PerspectiveDiffSync.sync(); Getting lock"); const release = await this.generalMutex.acquire(); - console.log("PerspectiveDiffSync.sync(); Got lock"); + //console.log("PerspectiveDiffSync.sync(); Got lock"); try { //@ts-ignore let current_revision = await this.hcDna.call(DNA_NICK, ZOME_NAME, "sync", null); @@ -70,7 +70,6 @@ export class LinkAdapter implements LinkSyncAdapter { } async gossip() { - console.log("PerspectiveDiffSync.gossip()"); this.gossipLogCount += 1; let lostPeers: DID[] = []; @@ -93,8 +92,6 @@ export class LinkAdapter implements LinkSyncAdapter { // Lexically sort the peers peers.sort(); - console.log("PerspectiveDiffSync.gossip(); peers:", peers); - // If we are the first peer, we are the scribe let is_scribe = peers[0] == this.me; @@ -196,7 +193,6 @@ export class LinkAdapter implements LinkSyncAdapter { } async commit(diff: PerspectiveDiff): Promise { - console.log("PerspectiveDiffSync.commit()"); //console.log("PerspectiveDiffSync.commit(); Getting lock"); const release = await this.generalMutex.acquire(); try { @@ -228,20 +224,19 @@ export class LinkAdapter implements LinkSyncAdapter { } async handleHolochainSignal(signal: any): Promise { - console.log("PerspectiveDiffSync.handleHolochainSignal(); signal", signal); const { diff, reference_hash, reference, broadcast_author } = signal.payload; //Check if this signal came from another agent & contains a diff and reference_hash if (diff && reference_hash && reference && broadcast_author) { - console.log(`PerspectiveDiffSync.handleHolochainSignal: - diff: ${JSON.stringify(diff)} - reference_hash: ${reference_hash.toString('base64')} - reference: { - diff: ${reference.diff?.toString('base64')} - parents: ${reference.parents ? reference.parents.map( (parent: Buffer) => parent ? parent.toString('base64') : 'null').join(', '):'none'} - diffs_since_snapshot: ${reference?.diffs_since_snapshot} - } - broadcast_author: ${broadcast_author} - `) + // console.log(`PerspectiveDiffSync.handleHolochainSignal: + // diff: ${JSON.stringify(diff)} + // reference_hash: ${reference_hash.toString('base64')} + // reference: { + // diff: ${reference.diff?.toString('base64')} + // parents: ${reference.parents ? reference.parents.map( (parent: Buffer) => parent ? parent.toString('base64') : 'null').join(', '):'none'} + // diffs_since_snapshot: ${reference?.diffs_since_snapshot} + // } + // broadcast_author: ${broadcast_author} + // `) try { //console.log("PerspectiveDiffSync.handleHolochainSignal: Getting lock"); From d5db7330fe48c97273bbb295d5df27a5d45ccb0b Mon Sep 17 00:00:00 2001 From: Nicolas Luck Date: Wed, 21 Feb 2024 01:12:00 +0100 Subject: [PATCH 7/7] mainnet seed for p-diff build without debug clutter --- cli/mainnet_seed.json | 2 +- rust-executor/src/mainnet_seed.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/mainnet_seed.json b/cli/mainnet_seed.json index 912c54533..60f30b331 100644 --- a/cli/mainnet_seed.json +++ b/cli/mainnet_seed.json @@ -4,7 +4,7 @@ "did:key:z6MkvPpWxwXAnLtMcoc9sX7GEoJ96oNnQ3VcQJRLspNJfpE7" ], "knownLinkLanguages": [ - "QmzSYwdngLyetZj89L1Kv2Y2bsBDAPKC7JBGTpwNAiuiPMX8DPX", + "QmzSYwdbfoeiJ1UW1MFdRNSh6txNnNCS5uYqgfJjzJjsu2GRbWx", "QmzSYwddjYfNpgFk69C1DfWeNc3uPS1rKNJEj5TqouhCcAgzPUx", "QmzSYwdnHrRH8MmuPWKKrDvFoVyW5CophNpT1ipQUCcenPVTQnd" ], diff --git a/rust-executor/src/mainnet_seed.json b/rust-executor/src/mainnet_seed.json index 912c54533..60f30b331 100644 --- a/rust-executor/src/mainnet_seed.json +++ b/rust-executor/src/mainnet_seed.json @@ -4,7 +4,7 @@ "did:key:z6MkvPpWxwXAnLtMcoc9sX7GEoJ96oNnQ3VcQJRLspNJfpE7" ], "knownLinkLanguages": [ - "QmzSYwdngLyetZj89L1Kv2Y2bsBDAPKC7JBGTpwNAiuiPMX8DPX", + "QmzSYwdbfoeiJ1UW1MFdRNSh6txNnNCS5uYqgfJjzJjsu2GRbWx", "QmzSYwddjYfNpgFk69C1DfWeNc3uPS1rKNJEj5TqouhCcAgzPUx", "QmzSYwdnHrRH8MmuPWKKrDvFoVyW5CophNpT1ipQUCcenPVTQnd" ],