Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): fix/renovate/graphprotocol graph node 0.33.3 #13185

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ yarn-error.log
.netlify
.vercel
governance/.openzeppelin/unknown-31337.json

# log files
nohup.out
3 changes: 3 additions & 0 deletions docker/development.env
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ SMTP_HOST=smtp_host
SMTP_USERNAME=smtp_username
SMTP_PASSWORD=smtp_password
BASE64_WEDLOCKS_PRIVATE_KEY=pk

# postgres
POSTGRES_USER=graph-node
POSTGRES_PASSWORD=let-me-in
POSTGRES_DB=graph-node
POSTGRES_INITDB_ARGS="-E UTF8 --locale=C" # required by graph-node since 0.30.0

# for subgraph config
postgres_host=postgres
Expand Down
12 changes: 9 additions & 3 deletions docker/development/eth-node/scripts/provision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,14 @@ async function main() {
/**
* 3. Deploy UNLOCK contracts
*/
const { unlock: unlockContract } = await unlock.deployProtocol()
log('UNLOCK PROTOCOL DEPLOYED')
const { unlock: unlockContract } = await unlock.deployProtocol(12, 13)
const [publicLockVersion, unlockVersion] = await Promise.all([
await unlockContract.publicLockLatestVersion(),
await unlockContract.unlockVersion(),
])
log(
`UNLOCK PROTOCOL DEPLOYED : Unlock v${unlockVersion}, PublicLock v${publicLockVersion}`
)

// grant Unlock minting permissions
await udt.addMinter(unlockContract.address)
Expand All @@ -104,7 +110,7 @@ async function main() {
// Finally, deploy locks and for each of them, if it's an ERC20, approve it for locksmith purchases
await Promise.all(
locksArgs(erc20.address).map(async (lockParams) => {
const { lock } = await unlock.createLock(lockParams)
const { lock } = await unlock.createLock({ ...lockParams, version: 13 })

log(`LOCK "${await lockParams.name}" DEPLOYED TO ${lock.address}`)

Expand Down
915 changes: 438 additions & 477 deletions docker/development/eth-node/yarn.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docker/docker-compose.integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ services:
'/opt/startup.sh',
]
volumes:
- ./development/subgraph/startup.sh:/opt/startup.sh
- ./development/subgraph/networks.json:/home/unlock/subgraph/networks.json
- ./development/eth-node/startup.sh:/opt/startup.sh
- ./development/eth-node/networks.json:/home/unlock/subgraph/networks.json
- ./development/wait-for-it/wait-for-it.sh:/opt/wait-for-it.sh
depends_on:
- graph-node
Expand All @@ -60,7 +60,7 @@ services:
BUILD_DIR: tests
env_file: test.env
volumes:
- ./development/subgraph/networks.json:/home/unlock/networks.json
- ./development/eth-node/networks.json:/home/unlock/networks.json
depends_on:
- graph-node
- eth-node
2 changes: 1 addition & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3.2'
services:
graph-node:
image: graphprotocol/graph-node:v0.29.0
image: graphprotocol/graph-node:v0.33.0
ports:
- '8000:8000'
- '8001:8001'
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"bump": "yarn packages:version patch && yarn version:apply",
"release": "yarn build && yarn bump && yarn packages:publish",
"start": "./scripts/start.sh",
"stop": "./scripts/stop.sh",
"nuke": "./scripts/nuke.sh",
"lint": "yarn packages --parallel run lint",
"lint:contracts": "yarn workspace @unlock-protocol/smart-contracts lint:contracts --fix",
Expand Down
84 changes: 84 additions & 0 deletions packages/networks/bin/localhost.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import fs from 'fs-extra'
import path from 'path'

// We use Partial<NetworkConfig> for localhost as we don't have all the information
const defaultLocalhost = {
chain: 'localhost',
description: 'Localhost network.',
featured: false,
fullySubsidizedGas: true,
id: 31337,
isTestNetwork: true,
name: 'Localhost',
nativeCurrency: {
coingecko: 'ethereum',
decimals: 18,
name: 'ETH',
symbol: 'ETH',
},
provider: 'http://127.0.0.1:8545',
publicLockVersionToDeploy: 13,
publicProvider: 'http://127.0.0.1:8545',
subgraph: {
endpoint: '',
},
}

const generateLocalhostNetworkFile = ({
unlockAddress,
subgraphEnpoint = 'http://localhost:8000/subgraphs/name/testgraph',
}) => {
const localhost = {
...defaultLocalhost,
subgraph: {
endpoint: subgraphEnpoint,
},
unlockAddress,
}

// log for debug purposes
console.log(localhost)

// output to js file
const parsed = `import { NetworkConfig } from '@unlock-protocol/types'

// We use Partial<NetworkConfig> for localhost as we don't have all the information
export const localhost: Partial<NetworkConfig> = ${JSON.stringify(localhost)}

export default localhost
`
return parsed
}

const run = async () => {
const [networkInfoPath, subgraphEnpoint] = process.argv.slice(2)

const networkInfo = await fs.readJSON(networkInfoPath)
const {
localhost: {
Unlock: { address: unlockAddress },
},
} = networkInfo

console.log(networkInfo)

console.log(`Creating localhost file for unlockAddress ${unlockAddress}`)

if (!unlockAddress) {
throw new Error('Missing unlockAddress arg')
}

const fileContent = generateLocalhostNetworkFile({
subgraphEnpoint,
unlockAddress,
})

const filePath = path.resolve('./src/networks/localhost.ts')

await fs.writeFile(filePath, fileContent)
}
run()
.then(() => console.log('done'))
.catch((err) => {
throw err
})
4 changes: 3 additions & 1 deletion packages/networks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"lint": "eslint --resolve-plugins-relative-to ../eslint-config --ext .tsx,.ts,.js src/",
"build": "tsup src/index.ts --dts --format esm,cjs",
"check-tokens": "tsx ./bin/check-tokens",
"create-localhost": "tsx ./bin/localhost",
"clean": "rm -rf ./dist",
"check": "tsx ./bin/keys",
"prepublish": "yarn build",
Expand All @@ -33,7 +34,8 @@
"@unlock-protocol/types": "workspace:^",
"eslint": "8.54.0",
"tsup": "8.0.2",
"typescript": "5.3.3"
"typescript": "5.3.3",
"fs-extra": "11.2.0"
},
"files": [
"dist"
Expand Down
2 changes: 1 addition & 1 deletion scripts/run-stack-dockerized.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ docker-compose $COMPOSE_CONFIG up -d postgres ipfs graph-node eth-node
docker-compose $COMPOSE_CONFIG exec -T eth-node yarn provision --network docker

# Make the correct subgraph config
docker-compose $COMPOSE_CONFIG exec -T eth-node cat networks.json > $BASE_DOCKER_FOLDER/development/subgraph/networks.json
docker-compose $COMPOSE_CONFIG exec -T eth-node cat networks.json > $BASE_DOCKER_FOLDER/development/eth-node/networks.json

# show subgraph networks config (for debug purposes)
docker-compose $COMPOSE_CONFIG exec -T eth-node cat networks.json
Expand Down
68 changes: 0 additions & 68 deletions scripts/run-stack-local.sh

This file was deleted.

80 changes: 67 additions & 13 deletions scripts/start.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,69 @@
#!/usr/bin/env bash

# This script starts the application.
# Based on the environment it may also deploy the smart contracts.

if [ -n "$CI" ]; then
# We need to deploy the locks
cd unlock-app
yarn deploy-unlock-contract
cd ".."
fi

# Start the application
cd unlock-app
yarn start
#
# This will run an instance of the unlock protocol tooling (deploy contracts, graph, and apps)
# from the local repository. This is useful when developing and testing things locally.
#
# You are required to run first `yarn && yarn build` from the root of this repo, to install and
# prepare deps. Docker is required to run instances of infrastructure providers such as
# Ethereum node, Graph node, Postgres db and IPFS.
#
# To run the protocol entirely with docker , see `run-stack-dockerized.sh`

set -e

REPO_ROOT=`pwd`/`dirname "$0"`/..
echo "running from: $REPO_ROOT"
COMPOSE_CONFIG="-f $REPO_ROOT/docker/docker-compose.yml -f $REPO_ROOT/docker/docker-compose.integration.yml"

# Setting the right env var
export UNLOCK_ENV=test

# clean things up
./scripts/stop.sh

# Take db, IPFS, graph and postgres nodes up
docker-compose $COMPOSE_CONFIG up -d postgres ipfs graph-node eth-node

# deploy contracts
cd $REPO_ROOT/docker/development/eth-node
yarn
yarn provision --network localhost

# prepare subgraph deployment
cd $REPO_ROOT/subgraph
yarn prepare:abis

# copy local networks files
yarn prepare:test
yarn graph codegen
yarn graph build --network localhost

# now deploy the subgraph
yarn workspace @unlock-protocol/subgraph graph create testgraph --node http://localhost:8020/
yarn graph deploy testgraph --node=http://localhost:8020/ --ipfs=http://localhost:5001 --version-label=v0.0.1 --network=localhost

# create localhost file in networks package
yarn workspace @unlock-protocol/networks create-localhost ../../docker/development/eth-node/networks.json
yarn workspace @unlock-protocol/networks build

# rebuild unlock-js to get latest networks package
yarn workspace @unlock-protocol/unlock-js build

# start 2nd postgres instance for locksmith
docker run --name locksmith-postgres -p 5433:5432 -e POSTGRES_PASSWORD=postgres -e POSTGRES_USER=postgres -e POSTGRES_DB=locksmith -d postgres

# setup db
export DATABASE_URL=postgresql://postgres:postgres@127.0.0.1:5433/locksmith
yarn workspace @unlock-protocol/locksmith db:migrate

# run locksmith + workers (detached)
nohup yarn workspace @unlock-protocol/locksmith dev &
# nohup yarn workspace @unlock-protocol/locksmith worker:dev &

# run unlock-app
export NEXT_PUBLIC_LOCKSMITH_URI=http://localhost:8080
export NEXT_PUBLIC_UNLOCK_ENV=dev
yarn workspace @unlock-protocol/unlock-app start


29 changes: 29 additions & 0 deletions scripts/stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

#
# This will run an instance of the unlock protocol tooling (deploy contracts, graph, and apps)
# from the local repository. This is useful when developing and testing things locally.
#
# You are required to run first `yarn && yarn build` from the root of this repo, to install and
# prepare deps. Docker is required to run instances of infrastructure providers such as
# Ethereum node, Graph node, Postgres db and IPFS.
#
# To run the protocol entirely with docker , see `run-stack-dockerized.sh`

set -e

REPO_ROOT=`pwd`/`dirname "$0"`/..
echo "running from: $REPO_ROOT"
COMPOSE_CONFIG="-f $REPO_ROOT/docker/docker-compose.yml -f $REPO_ROOT/docker/docker-compose.integration.yml"

# bring containers down
docker-compose $COMPOSE_CONFIG down

# delete locksmith db
locksmith_postgres_instance=$(docker ps -a --no-trunc -q --filter name=^/locksmith-postgres)
if [ -n "$locksmith_postgres_instance" ]; then
docker rm -f $locksmith_postgres_instance
fi

# kill possible running apps
# kill $(ps aux | grep unlock | awk '{print $2}')
Loading