diff --git a/.env b/.env index f7686569..637deb0a 100644 --- a/.env +++ b/.env @@ -100,13 +100,12 @@ GRAFANA_IMAGE_NAME=grafana/grafana GRAFANA_IMAGE_TAG=8.5.16 ### Sourcify #### -#Sourcify Common -SOURCIFY_TESTING=false SOURCIFY_TAG=main -SOURCIFY_UI_DOMAIN_NAME=localhost -SOURCIFY_SERVER_REPOSITORY_PATH=/data + #Sourcify Server -SOURCIFY_SERVER_SOLC_REPO=/data/solc-bin/linux-amd64 -SOURCIFY_SERVER_SOLJSON_REPO=/data/solc-bin/soljson -SOURCIFY_SERVER_CREATE2_VERIFICATION=false -SOURCIFY_USE_LOCAL_NODE=true \ No newline at end of file +SOURCIFY_SERVER_PORT=5555 +SOURCIFY_NODE_ENV=development + +#Sourcify ui +SOURCIFY_UI_PORT=1234 +SOURCIFY_REPOSITORY_PORT=10000 \ No newline at end of file diff --git a/compose-network/explorer/networks-config.json b/compose-network/explorer/networks-config.json new file mode 100644 index 00000000..a21f4be9 --- /dev/null +++ b/compose-network/explorer/networks-config.json @@ -0,0 +1,54 @@ +[ + { + "name": "mainnet", + "displayName": "MAINNET", + "url": "https://mainnet-public.mirrornode.hedera.com/", + "ledgerID": "00", + "sourcifySetup": { + "activate": true, + "repoURL": "http://localhost:10000/contracts/", + "serverURL": "http://localhost:5002/", + "verifierURL": "http://localhost:3000/#/", + "chainID": 295 + } + }, + { + "name": "testnet", + "displayName": "TESTNET", + "url": "https://testnet.mirrornode.hedera.com/", + "ledgerID": "01", + "sourcifySetup": { + "activate": true, + "repoURL": "http://localhost:10000/contracts/", + "serverURL": "http://localhost:5002/", + "verifierURL": "http://localhost:3000/#/", + "chainID": 296 + } + }, + { + "name": "previewnet", + "displayName": "PREVIEWNET", + "url": "https://previewnet.mirrornode.hedera.com/", + "ledgerID": "02", + "sourcifySetup": { + "activate": true, + "repoURL": "http://localhost:10000/contracts/", + "serverURL": "http://localhost:5002/", + "verifierURL": "http://localhost:3000/#/", + "chainID": 297 + } + }, + { + "name": "localnode", + "displayName": "LOCAL NODE", + "url": "http://127.0.0.1:5551", + "ledgerID": "FF", + "sourcifySetup": { + "activate": true, + "repoURL": "http://localhost:10000/contracts/", + "serverURL": "http://localhost:5555/", + "verifierURL": "http://localhost:5555/#/", + "chainID": 298 + } + } +] \ No newline at end of file diff --git a/compose-network/sourcify/local.js b/compose-network/sourcify/local.js new file mode 100644 index 00000000..bd88f8f5 --- /dev/null +++ b/compose-network/sourcify/local.js @@ -0,0 +1,49 @@ +//diff sourcify/services/server/src/config/default.js ./local.js +module.exports = { + server: { + port: 5555, + maxFileSize: 30 * 1024 * 1024, // 30 MB + }, + // Deprecated repository + repositoryV1: { + path: "/tmp/sourcify/repository", + serverUrl: "http://localhost:10000", // Need to keep this as it's used in IpfsRepositoryService.ts fetchAllFileUrls. + }, + // Disable repositoryV2 by default for now, we will enable it once we start the synchronization script + // repositoryV2: { + // path: "/tmp/sourcify/repositoryV2", + // }, + solcRepo: "/tmp/solc-bin/linux-amd64", + solJsonRepo: "/tmp/solc-bin/soljson", + session: { + secret: process.env.SESSION_SECRET || "CHANGE_ME", + maxAge: 12 * 60 * 60 * 1000, // 12 hrs in millis + secure: false, // Set Secure in the Set-Cookie header i.e. require https + storeType: "memory", // Where to save the session info. "memory" is only good for testing and local development. Don't use it in production! + }, + // It is possible to outsource the compilation to a lambda function instead of running locally. Turned on in production. + // Requires env vars AWS_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY + lambdaCompiler: { + enabled: false, + // functionName: "compile", + }, + corsAllowedOrigins: [ + /^https?:\/\/(?:.+\.)?sourcify.dev$/, // sourcify.dev and subdomains + /^https?:\/\/(?:.+\.)?sourcify.eth$/, // sourcify.eth and subdomains + /^https?:\/\/(?:.+\.)?sourcify.eth.link$/, // sourcify.eth.link and subdomains + /^https?:\/\/(?:.+\.)?ipfs.dweb.link$/, // dweb links used by Brave browser etc. + process.env.NODE_ENV !== "production" && /^https?:\/\/localhost(?::\d+)?$/, // localhost on any port + ], + rateLimit: { + enabled: false, + // Check done with "startsWith" + whitelist: [ + "10.", // internal IP range + "::ffff:10.", + "127.0.0.1", + "::ffff:127.0.0.1", + "::1", + ], + }, + }; + \ No newline at end of file diff --git a/compose-network/sourcify/servers.yaml b/compose-network/sourcify/servers.yaml new file mode 100644 index 00000000..38c7b169 --- /dev/null +++ b/compose-network/sourcify/servers.yaml @@ -0,0 +1,8 @@ +- description: The current REST API server + url: "" +- description: The production REST API server + url: "https://server-verify.hashscan.io" +- description: The staging REST API server + url: "https://server-sourcify.hedera-devops.com" +- description: Local development server address on default port 5555 + url: "http://localhost:5555" diff --git a/compose-network/sourcify/sourcify-chains.json b/compose-network/sourcify/sourcify-chains.json new file mode 100644 index 00000000..9606b1dc --- /dev/null +++ b/compose-network/sourcify/sourcify-chains.json @@ -0,0 +1,22 @@ +{ + "295": { + "sourcifyName": "Hedera Mainnet", + "supported": true + }, + "296": { + "sourcifyName": "Hedera Testnet", + "supported": true + }, + "297": { + "sourcifyName": "Hedera Previewnet", + "supported": true + }, + "298": { + "sourcifyName": "Hedera Localnet", + "supported": true, + "rpc": [ + "http://host.docker.internal:7546" + ] + } + } + \ No newline at end of file diff --git a/sourcify-ui-docker-config.json b/compose-network/sourcify/ui-config.json similarity index 87% rename from sourcify-ui-docker-config.json rename to compose-network/sourcify/ui-config.json index c2853343..45ff7139 100644 --- a/sourcify-ui-docker-config.json +++ b/compose-network/sourcify/ui-config.json @@ -1,5 +1,5 @@ - { - "SERVER_URL": "http://localhost:5002", +{ + "SERVER_URL": "http://localhost:5555", "REPOSITORY_SERVER_URL": "http://localhost:10000", "EXPLORER_URL": "http://localhost:8080", "BRAND_PRODUCT_LOGO_URL": "", @@ -10,4 +10,4 @@ "JSON_IMPORT": false, "OPEN_IN_REMIX": false, "CREATE2_VERIFICATION": false - } \ No newline at end of file + } diff --git a/docker-compose.yml b/docker-compose.yml index 2ec23065..b0848481 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -286,7 +286,7 @@ services: ports: - "8080:8080" volumes: - - ./networks-config.json:/app/networks-config.json + - ./compose-network/explorer/networks-config.json:/app/networks-config.json web3: image: "${MIRROR_IMAGE_PREFIX}hedera-mirror-web3:${MIRROR_IMAGE_TAG}" @@ -494,56 +494,39 @@ services: network-node-bridge: ipv4_address: 172.27.0.50 - sourcify-repository: - image: ghcr.io/hashgraph/hedera-sourcify:repository-${SOURCIFY_TAG} - restart: unless-stopped - container_name: sourcify-repository-${SOURCIFY_TAG} - ports: - - "10000:80" - volumes: - - sourcify-repository:/data:ro - networks: - - mirror-node - environment: - REPOSITORY_PATH: "${SOURCIFY_SERVER_REPOSITORY_PATH}" - REPOSITORY_SERVER_EXTERNAL_PORT: 10000 - UI_DOMAIN_NAME: "${SOURCIFY_UI_DOMAIN_NAME}" - TESTING: "${SOURCIFY_TESTING}" - TAG: "${SOURCIFY_TAG}" - sourcify-server: - image: ghcr.io/hashgraph/hedera-sourcify:server-${SOURCIFY_TAG} + image: ghcr.io/hashgraph/hedera-sourcify/server:${SOURCIFY_TAG} restart: unless-stopped container_name: sourcify-server-${SOURCIFY_TAG} + environment: + NODE_ENV: ${SOURCIFY_NODE_ENV} ports: - - "5002:5002" + - "${SOURCIFY_SERVER_PORT}:5555" volumes: - - sourcify-repository:/data - networks: - - mirror-node - environment: - SERVER_PORT: "5002" - UI_DOMAIN_NAME: "${SOURCIFY_UI_DOMAIN_NAME}" - SERVER_CREATE2_VERIFICATION: "${SOURCIFY_SERVER_CREATE2_VERIFICATION}" - TESTING: "${SOURCIFY_TESTING}" - TAG: "${SOURCIFY_TAG}" - SOLC_REPO: "${SOURCIFY_SERVER_SOLC_REPO}" - SOLJSON_REPO: "${SOURCIFY_SERVER_SOLJSON_REPO}" - REPOSITORY_PATH: "${SOURCIFY_SERVER_REPOSITORY_PATH}" - REPOSITORY_SERVER_URL: "http://sourcify-repository-${SOURCIFY_TAG}" - USE_LOCAL_NODE: "${SOURCIFY_USE_LOCAL_NODE}" + - type: bind + source: ./compose-network/sourcify/servers.yaml + target: /home/app/services/server/dist/servers.yaml + - type: bind + source: ./compose-network/sourcify/sourcify-chains.json + target: /home/app/services/server/dist/sourcify-chains.json + - type: bind + source: ./compose-network/sourcify/local.js + target: /home/app/services/server/dist/config/local.js + - type: volume + source: sourcify-data + target: /data healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:5002/health"] + test: ["CMD", "curl", "-f", "http://localhost:${SOURCIFY_SERVER_PORT}/health"] interval: 30s timeout: 10s retries: 10 - sourcify-ui: - image: ghcr.io/hashgraph/hedera-sourcify:ui-${SOURCIFY_TAG} + sourcify-sourcify-ui: + image: ghcr.io/hashgraph/hedera-sourcify/ui:${SOURCIFY_TAG} restart: unless-stopped container_name: sourcify-ui-${SOURCIFY_TAG} ports: - - "1234:80" + - "${SOURCIFY_UI_PORT}:80" healthcheck: test: ["CMD", "curl", "-f", "http://localhost"] interval: 30s @@ -551,10 +534,23 @@ services: retries: 10 volumes: - type: bind - source: ./sourcify-ui-docker-config.json + source: ./compose-network/sourcify/ui-config.json target: /usr/share/nginx/html/config.json - networks: - - mirror-node + + sourcify-repository: + image: ghcr.io/hashgraph/hedera-sourcify/repository:${SOURCIFY_TAG} + restart: unless-stopped + container_name: sourcify-repository-${SOURCIFY_TAG} + environment: + SOURCIFY_SERVER: "http://host.docker.internal:${SOURCIFY_SERVER_PORT}" + SERVER_URL: "http://localhost:${SOURCIFY_SERVER_PORT}" + volumes: + - type: volume + source: sourcify-data + target: /data + read_only: true + ports: + - "${SOURCIFY_REPOSITORY_PORT}:80" networks: network-node-bridge: @@ -582,5 +578,5 @@ volumes: name: prometheus-data grafana-data: name: grafana-data - sourcify-repository: - name: sourcify-repository \ No newline at end of file + sourcify: + name: sourcify-data \ No newline at end of file diff --git a/networks-config.json b/networks-config.json deleted file mode 100644 index 760fb05a..00000000 --- a/networks-config.json +++ /dev/null @@ -1,54 +0,0 @@ -[ - { - "name": "mainnet", - "displayName": "MAINNET", - "url": "https://mainnet-public.mirrornode.hedera.com/", - "ledgerID": "00", - "sourcifySetup": { - "activate": true, - "repoURL": "https://repository.local/contracts/", - "serverURL": "https://localhost/server/", - "verifierURL": "https://localhost/#/", - "chainID": 295 - } - }, - { - "name": "testnet", - "displayName": "TESTNET", - "url": "https://testnet.mirrornode.hedera.com/", - "ledgerID": "01", - "sourcifySetup": { - "activate": true, - "repoURL": "https://repository.local/contracts/", - "serverURL": "https://localhost/server/", - "verifierURL": "https://localhost/#/", - "chainID": 296 - } - }, - { - "name": "previewnet", - "displayName": "PREVIEWNET", - "url": "https://previewnet.mirrornode.hedera.com/", - "ledgerID": "02", - "sourcifySetup": { - "activate": true, - "repoURL": "https://repository.local/contracts/", - "serverURL": "https://localhost/server/", - "verifierURL": "https://localhost/#/", - "chainID": 297 - } - }, - { - "name": "local", - "displayName": "LOCALNET", - "url": "http://localhost:5551/", - "ledgerID": "03", - "sourcifySetup": { - "activate": true, - "repoURL": "http://localhost:10000/", - "serverURL": "http://localhost:5002/", - "verifierURL": "http://localhost:1234/#/", - "chainID": 298 - } - } - ] \ No newline at end of file