Skip to content

Commit

Permalink
feat: add new DCL address restricted to Zone deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
aleortega committed Dec 28, 2023
1 parent 47c37d4 commit a97a5ab
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 20 deletions.
7 changes: 7 additions & 0 deletions content/src/Environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const DEFAULT_HTTP_SERVER_HOST = '0.0.0.0'
const DEFAULT_DENYLIST_FILE_NAME = 'denylist.txt'
const DEFAULT_DENYLIST_URLS = 'https://config.decentraland.org/denylist'
const DECENTRALAND_ADDRESS: EthAddress = '0x1337e0507eb4ab47e08a179573ed4533d9e22a7b'
const DECENTRALAND_ZONE_ADDRESS: EthAddress = '0x85eB159d27aA98a23faD01300F1d7A445c6F923b'

const DEFAULT_FOLDER_MIGRATION_MAX_CONCURRENCY = 1000
export const DEFAULT_ENTITIES_CACHE_SIZE = 150000
Expand Down Expand Up @@ -124,6 +125,7 @@ export enum EnvironmentConfig {
LOG_REQUESTS,
UPDATE_FROM_DAO_INTERVAL,
DECENTRALAND_ADDRESS,
DECENTRALAND_ZONE_ADDRESS,
DEPLOYMENTS_DEFAULT_RATE_LIMIT_TTL,
DEPLOYMENTS_DEFAULT_RATE_LIMIT_MAX,
ETH_NETWORK,
Expand Down Expand Up @@ -232,6 +234,11 @@ export class EnvironmentBuilder {
() => process.env.UPDATE_FROM_DAO_INTERVAL ?? ms('30m')
)
this.registerConfigIfNotAlreadySet(env, EnvironmentConfig.DECENTRALAND_ADDRESS, () => DECENTRALAND_ADDRESS)
this.registerConfigIfNotAlreadySet(
env,
EnvironmentConfig.DECENTRALAND_ZONE_ADDRESS,
() => DECENTRALAND_ZONE_ADDRESS
)
this.registerConfigIfNotAlreadySet(env, EnvironmentConfig.DEPLOYMENTS_DEFAULT_RATE_LIMIT_TTL, () =>
Math.floor(ms((process.env.DEPLOYMENTS_DEFAULT_RATE_LIMIT_TTL ?? '1m') as string) / 1000)
)
Expand Down
11 changes: 9 additions & 2 deletions content/src/components.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createFolderBasedFileSystemContentStorage, createFsComponent } from '@dcl/catalyst-storage'
import { ValidateFn } from '@dcl/content-validator'
import { EntityType } from '@dcl/schemas'
import { EntityType, EthAddress } from '@dcl/schemas'
import { createSynchronizer } from '@dcl/snapshots-fetcher'
import { createJobQueue } from '@dcl/snapshots-fetcher/dist/job-queue-port'
import { createFetchComponent } from '@well-known-components/fetch-component'
Expand Down Expand Up @@ -108,7 +108,14 @@ export async function initComponentsWithEnv(env: Environment): Promise<AppCompon
? await createDAOComponent({ l1Provider }, ethNetwork as L1Network)
: createCustomDAOComponent(customDAO)

const authenticator = new ContentAuthenticator(l1Provider, env.getConfig(EnvironmentConfig.DECENTRALAND_ADDRESS))
const decentralandAddresses =
env.getConfig(EnvironmentConfig.ETH_NETWORK) === 'mainnet'
? [env.getConfig(EnvironmentConfig.DECENTRALAND_ADDRESS)]
: [
env.getConfig(EnvironmentConfig.DECENTRALAND_ADDRESS),
env.getConfig(EnvironmentConfig.DECENTRALAND_ZONE_ADDRESS)
]
const authenticator = new ContentAuthenticator(l1Provider, decentralandAddresses as EthAddress[])

const contentCluster = new ContentCluster(
{
Expand Down
4 changes: 2 additions & 2 deletions content/src/service/auth/Authenticator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { AuthChain, Authenticator, EthAddress, ValidationResult } from '@dcl/cry
import { HTTPProvider } from 'eth-connect'

export class ContentAuthenticator {
constructor(private readonly provider: HTTPProvider, private readonly decentralandAddress: EthAddress) {}
constructor(private readonly provider: HTTPProvider, private readonly decentralandAddresses: EthAddress[]) {}

/** Return whether the given address used is owned by Decentraland */
isAddressOwnedByDecentraland(address: EthAddress): boolean {
return address.toLowerCase() === this.decentralandAddress.toLowerCase()
return !!this.decentralandAddresses.find((dclAddress) => dclAddress.toLowerCase() === address.toLowerCase())
}

/** Validate that the signature belongs to the Ethereum address */
Expand Down
2 changes: 1 addition & 1 deletion content/test/unit/ports/activeEntities.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ async function buildComponents() {
const pointerManager = NoOpPointerManager.build()
const authenticator = new ContentAuthenticator(
new HTTPProvider('https://rpc.decentraland.org/mainnet?project=catalyst-ci'),
DECENTRALAND_ADDRESS
[DECENTRALAND_ADDRESS]
)
const deployedEntitiesBloomFilter = createDeployedEntitiesBloomFilter({ database, logs, clock })
env.setConfig(EnvironmentConfig.ENTITIES_CACHE_SIZE, DEFAULT_ENTITIES_CACHE_SIZE)
Expand Down
2 changes: 1 addition & 1 deletion content/test/unit/ports/deployer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ describe('Deployer', function () {
const pointerManager = NoOpPointerManager.build()
const authenticator = new ContentAuthenticator(
new HTTPProvider('https://rpc.decentraland.org/mainnet?project=catalyst-ci'),
DECENTRALAND_ADDRESS
[DECENTRALAND_ADDRESS]
)
const deployedEntitiesBloomFilter = createDeployedEntitiesBloomFilter({ database, logs, clock })
env.setConfig(EnvironmentConfig.ENTITIES_CACHE_SIZE, DEFAULT_ENTITIES_CACHE_SIZE)
Expand Down
23 changes: 9 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2711,7 +2711,7 @@ [email protected], destroy@^1.2.0:
resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.2.0.tgz#4803735509ad8be552934c67df614f94e66fa015"
integrity sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==

detect-libc@^2.0.0, detect-libc@^2.0.1, detect-libc@^2.0.2:
detect-libc@^2.0.0, detect-libc@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-2.0.2.tgz#8ccf2ba9315350e1241b88d0ac3b0e1fbd99605d"
integrity sha512-UX6sGumvvqSaXgdKGUsgZWqcUyIXZ/vZTrlRT/iobiKhGL0zL4d3osHj3uqllWJK+i+sixDS/3COVEOFbupFyw==
Expand Down Expand Up @@ -4949,11 +4949,6 @@ node-abi@^3.3.0:
dependencies:
semver "^7.3.5"

node-addon-api@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-5.0.0.tgz#7d7e6f9ef89043befdb20c1989c905ebde18c501"
integrity sha512-CvkDw2OEnme7ybCykJpVcKH+uAOLV2qLqiyla128dN9TkEWfrYmxG6C2boDe5KcNQqZF3orkqzGgOMvZ/JNekA==

node-addon-api@^6.1.0:
version "6.1.0"
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-6.1.0.tgz#ac8470034e58e67d0c6f1204a18ae6995d9c0d76"
Expand Down Expand Up @@ -5853,18 +5848,18 @@ [email protected]:
resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.2.0.tgz#66c9a24a73f9fc28cbe66b09fed3d33dcaf1b424"
integrity sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==

sharp@0.30.7:
version "0.30.7"
resolved "https://registry.yarnpkg.com/sharp/-/sharp-0.30.7.tgz#7862bda98804fdd1f0d5659c85e3324b90d94c7c"
integrity sha512-G+MY2YW33jgflKPTXXptVO28HvNOo9G3j0MybYAHeEmby+QuD2U98dT6ueht9cv/XDqZspSpIhoSW+BAKJ7Hig==
sharp@0.32.6:
version "0.32.6"
resolved "https://registry.yarnpkg.com/sharp/-/sharp-0.32.6.tgz#6ad30c0b7cd910df65d5f355f774aa4fce45732a"
integrity sha512-KyLTWwgcR9Oe4d9HwCwNM2l7+J0dUQwn/yf7S0EnTtb0eVS4RxO0eUSvxPtzT4F3SY+C4K6fqdv/DO27sJ/v/w==
dependencies:
color "^4.2.3"
detect-libc "^2.0.1"
node-addon-api "^5.0.0"
detect-libc "^2.0.2"
node-addon-api "^6.1.0"
prebuild-install "^7.1.1"
semver "^7.3.7"
semver "^7.5.4"
simple-get "^4.0.1"
tar-fs "^2.1.1"
tar-fs "^3.0.4"
tunnel-agent "^0.6.0"

sharp@^0.32.0:
Expand Down

0 comments on commit a97a5ab

Please sign in to comment.