Skip to content

Commit

Permalink
fix: profiles sync deployment (#1815)
Browse files Browse the repository at this point in the history
* fix: profiles sync deployment

* feat: add hash image validaiton on profile deployment

* chore: bump libraries to latest
  • Loading branch information
aleortega authored Oct 11, 2024
1 parent fe67a84 commit da804e3
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 11 deletions.
4 changes: 2 additions & 2 deletions content/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions content/src/logic/deployments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
20 changes: 19 additions & 1 deletion content/src/service/validations/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -46,6 +48,21 @@ const createEthereumProvider = (httpProvider: HTTPProvider): EthereumProvider =>
export async function createExternalCalls(
components: Pick<AppComponents, 'storage' | 'authenticator' | 'env' | 'logs'>
): Promise<ExternalCalls> {
async function calculateFilesHashes(
files: Map<string, Uint8Array>
): Promise<Map<string, { calculatedHash: string; buffer: Uint8Array }>> {
const resultMap = new Map<string, { calculatedHash: string; buffer: Uint8Array }>()

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) => {
Expand All @@ -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
}
}

Expand Down
21 changes: 13 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -5453,6 +5453,11 @@ [email protected]:
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.10.tgz#67e9108c5c0551b9e5326064387de4763c4d5f8b"
integrity sha512-7lf7qcQidTku0Gu3YDPc8DJ1q7OOucfa/BSsIwjuh56VU7katFvuM8hULfkwB3Fns/rsVF7PwPKVw1sl5KQS9w==

[email protected]:
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"
Expand Down

0 comments on commit da804e3

Please sign in to comment.