From da804e39629caa59b074db9ae051f11a13fe18c5 Mon Sep 17 00:00:00 2001 From: Alejo Thomas Ortega Date: Fri, 11 Oct 2024 10:09:53 -0300 Subject: [PATCH] fix: profiles sync deployment (#1815) * fix: profiles sync deployment * feat: add hash image validaiton on profile deployment * chore: bump libraries to latest --- content/package.json | 4 ++-- content/src/logic/deployments.ts | 1 + content/src/service/validations/validator.ts | 20 ++++++++++++++++++- yarn.lock | 21 ++++++++++++-------- 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/content/package.json b/content/package.json index 6b6ac8084..d8a175080 100644 --- a/content/package.json +++ b/content/package.json @@ -24,11 +24,11 @@ "@dcl/catalyst-api-specs": "^3.3.0", "@dcl/catalyst-contracts": "^4.4.2", "@dcl/catalyst-storage": "^4.2.0", - "@dcl/content-validator": "^5.6.1", + "@dcl/content-validator": "^6.0.0", "@dcl/crypto": "^3.4.5", "@dcl/hashing": "^3.0.4", "@dcl/schemas": "^14.0.0", - "@dcl/snapshots-fetcher": "^9.0.3", + "@dcl/snapshots-fetcher": "^9.1.0", "@dcl/urn-resolver": "^3.6.0", "@well-known-components/env-config-provider": "^1.2.0", "@well-known-components/fetch-component": "^2.0.2", diff --git a/content/src/logic/deployments.ts b/content/src/logic/deployments.ts index 9befe2e9a..2edc4bf03 100644 --- a/content/src/logic/deployments.ts +++ b/content/src/logic/deployments.ts @@ -75,6 +75,7 @@ export async function retryFailedDeploymentExecution( for (const failedDeployment of failedDeployments) { // Build Deployment from other servers const { entityId, entityType, authChain } = failedDeployment + if (authChain) { logs.debug(`Will retry to deploy entity`, { entityId, entityType }) try { diff --git a/content/src/service/validations/validator.ts b/content/src/service/validations/validator.ts index 4e061e56c..7024d94cb 100644 --- a/content/src/service/validations/validator.ts +++ b/content/src/service/validations/validator.ts @@ -30,6 +30,8 @@ import { createItemChecker, createL1Checker, createL2Checker } from '../../logic import { AppComponents } from '../../types' import { createThirdPartyItemChecker } from '../../logic/third-party-item-checker' import { createThirdPartyContractRegistry } from '../../logic/third-party-contract-registry' +import { hashV0, hashV1 } from '@dcl/hashing' +import { Readable } from 'stream' const createEthereumProvider = (httpProvider: HTTPProvider): EthereumProvider => { const reqMan = new RequestManager(httpProvider) @@ -46,6 +48,21 @@ const createEthereumProvider = (httpProvider: HTTPProvider): EthereumProvider => export async function createExternalCalls( components: Pick ): Promise { + async function calculateFilesHashes( + files: Map + ): Promise> { + const resultMap = new Map() + + for (const [key, value] of files.entries()) { + const hashGenerationFn = key.startsWith('Qm') ? hashV0 : hashV1 + const readableContent = Readable.from(value) + const calculatedHash = await hashGenerationFn(readableContent) + resultMap.set(key, { calculatedHash, buffer: value }) + } + + return resultMap + } + return { isContentStoredAlready: (hashes) => components.storage.existMultiple(hashes), fetchContentFileSize: async (hash) => { @@ -60,7 +77,8 @@ export async function createExternalCalls( ownerAddress: (auditInfo) => Authenticator.ownerAddress(auditInfo.authChain), isAddressOwnedByDecentraland: (address: string) => components.authenticator.isAddressOwnedByDecentraland(address), validateSignature: (entityId, auditInfo, timestamp) => - components.authenticator.validateSignature(entityId, auditInfo.authChain, timestamp) + components.authenticator.validateSignature(entityId, auditInfo.authChain, timestamp), + calculateFilesHashes } } diff --git a/yarn.lock b/yarn.lock index d7b3bf13f..4d449ba82 100644 --- a/yarn.lock +++ b/yarn.lock @@ -350,10 +350,10 @@ dependencies: ethers "^5.6.8" -"@dcl/content-validator@^5.6.1": - version "5.6.1" - resolved "https://registry.npmjs.org/@dcl/content-validator/-/content-validator-5.6.1.tgz" - integrity sha512-KFJNtKaxy01mp6N/IRP0DnhV7PxDJ3T0F32vifYGiuZeyYBg6Ya7i1KN1fMpsMRXQllk3BEE4MPJo+dcKujD2w== +"@dcl/content-validator@^6.0.0": + version "6.0.0" + resolved "https://registry.yarnpkg.com/@dcl/content-validator/-/content-validator-6.0.0.tgz#a442f62a43d9f0058ec9c94b8054f63569969142" + integrity sha512-oneaM8V22cGxE9APd8FfuFjzfklLcVinBaZW7YH/KcWJSeo5ONxwFFil06DsaJ95do7BpgyD4ptmzp8eO9rm/Q== dependencies: "@dcl/block-indexer" "^1.1.2" "@dcl/content-hash-tree" "^1.1.4" @@ -419,10 +419,10 @@ ajv-errors "^3.0.0" ajv-keywords "^5.1.0" -"@dcl/snapshots-fetcher@^9.0.3": - version "9.0.3" - resolved "https://registry.npmjs.org/@dcl/snapshots-fetcher/-/snapshots-fetcher-9.0.3.tgz" - integrity sha512-IQutxo1bHCDuINFnMfU8fORTMIXfVdwRSdh3mVrpk7PepgPdbvXRHFXvnPF7KL8onkKbsHLLTma0QeaT84IPRw== +"@dcl/snapshots-fetcher@^9.1.0": + version "9.1.0" + resolved "https://registry.yarnpkg.com/@dcl/snapshots-fetcher/-/snapshots-fetcher-9.1.0.tgz#e6a55ca2db6926de92db2e52fdf87e60621af8dd" + integrity sha512-Fxjw97Atmx7SA6KMui5+5Fe42cVU3ogUnSiFYl2X1a55SOZzlRhpa57qC2i5p6ZroKyrdG9Hk9YOpj1tF/fM7Q== dependencies: "@dcl/catalyst-storage" "^4.0.0" "@dcl/hashing" "^3.0.3" @@ -5453,6 +5453,11 @@ path-to-regexp@0.1.10: resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.10.tgz#67e9108c5c0551b9e5326064387de4763c4d5f8b" integrity sha512-7lf7qcQidTku0Gu3YDPc8DJ1q7OOucfa/BSsIwjuh56VU7katFvuM8hULfkwB3Fns/rsVF7PwPKVw1sl5KQS9w== +path-to-regexp@0.1.7: + version "0.1.7" + resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c" + integrity sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ== + path-to-regexp@^1.7.0: version "1.8.0" resolved "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.8.0.tgz"