Modify mobymask container to stop running server and update readmes

This commit is contained in:
nabarun 2023-04-05 12:20:03 +05:30
parent dfaeb4a65a
commit 484a9e015d
13 changed files with 25 additions and 180 deletions

View File

@ -55,7 +55,7 @@ services:
entrypoint: "sh"
command: "/run-op-geth.sh"
ports:
- "8545"
- "0.0.0.0:8545:8545"
healthcheck:
test: ["CMD", "nc", "-vz", "localhost:8545"]
interval: 30s
@ -77,7 +77,7 @@ services:
- l2_accounts:/l2-accounts:ro
command: ["sh", "/app/run-op-node.sh"]
ports:
- "8547"
- "0.0.0.0:8547:8547"
healthcheck:
test: ["CMD", "nc", "-vz", "localhost:8547"]
interval: 30s

View File

@ -1,25 +0,0 @@
version: "3.2"
services:
laconicd:
restart: unless-stopped
image: cerc/laconicd:local
command: ["sh", "/docker-entrypoint-scripts.d/create-fixturenet.sh"]
volumes:
- ../config/fixturenet-laconicd/create-fixturenet.sh:/docker-entrypoint-scripts.d/create-fixturenet.sh
ports:
- "9473"
- "8545"
- "8546"
- "1317"
healthcheck:
test: ["CMD", "nc", "-v", "localhost", "8545"]
interval: 20s
timeout: 5s
retries: 15
start_period: 10s
networks:
# https://docs.docker.com/compose/networking/#configure-the-default-network
default:
name: mobymask-v2-network

View File

@ -39,7 +39,6 @@ services:
- ../config/wait-for-it.sh:/app/packages/server/wait-for-it.sh
- ../config/watcher-mobymask-v2/secrets-template.json:/app/packages/server/secrets-template.json
- ../config/watcher-mobymask-v2/deploy-and-generate-invite.sh:/app/packages/server/deploy-and-generate-invite.sh
- ../container-build/cerc-mobymask/scripts/deploy-and-generate-invite.ts:/app/packages/server/deploy-and-generate-invite.ts
- moby_data_server:/app/packages/server
- fixturenet_geth_accounts:/geth-accounts:ro
extra_hosts:

View File

@ -1,8 +1,13 @@
# Change if pointing to an external L1 endpoint
L1_RPC="http://fixturenet-eth-geth-1:8545"
# L1 endpoint
L1_CHAIN_ID=1212
L1_RPC="http://fixturenet-eth-geth-1:8545"
L1_HOST="fixturenet-eth-geth-1"
L1_PORT=8545
# Credentials for accounts on L1 to send balance to Optimism Proxy contract from
# (enables them to do transactions on L2)
L1_ADDRESS=
L1_PRIV_KEY=
L1_ADDRESS_2=

View File

@ -19,4 +19,4 @@ jq --arg privateKey "$PRIVATE_KEY_DEPLOYER" '.privateKey = $privateKey' secrets-
export L2_GETH_URL="http://${L2_GETH_HOST}:${L2_GETH_PORT}"
jq --arg rpcUrl "$L2_GETH_URL" '.rpcUrl = $rpcUrl' secrets.json > secrets_updated.json && mv secrets_updated.json secrets.json
npx ts-node deploy-and-generate-invite.ts
npm run deployAndGenerateInvite

View File

@ -1,7 +1,12 @@
# Change if pointing to an external optimism geth endpoint
# L2 endpoints
# TODO: Add another env for complete URL to handle https
L2_GETH_HOST="op-geth"
L2_GETH_PORT=8545
L2_NODE_HOST="op-node"
L2_NODE_PORT=8547
# Credentials for accounts to perform txs on L2
PRIVATE_KEY_DEPLOYER=
PRIVATE_KEY_PEER=

View File

@ -1,133 +0,0 @@
import { ethers } from "ethers";
import fs from 'fs';
import path from 'path';
// Workaround for missing types
const { generateUtil } = require('eth-delegatable-utils');
const phisherRegistryArtifacts = require('../hardhat/artifacts/contracts/PhisherRegistry.sol/PhisherRegistry.json');
const { privateKey, rpcUrl, baseURI } = require('./secrets.json');
const DEFAULT_BASE_URI = 'https://mobymask.com/#';
const configPath = path.join(__dirname, './config.json');
const { abi } = phisherRegistryArtifacts;
let provider = new ethers.providers.JsonRpcProvider(rpcUrl);
let signer: ethers.Wallet;
let _chainId: string;
let _name: string = 'MobyMask';
setupSigner()
.then(setupContract)
.then(signDelegation)
.catch(console.error);
async function setupSigner () {
if (privateKey) {
signer = new ethers.Wallet(privateKey, provider)
}
}
async function setupContract (): Promise<ethers.Contract> {
try {
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
const { address, chainId, name } = config;
_name = name;
_chainId = chainId;
return attachToContract(address)
} catch (err) {
console.log('No config detected, deploying contract and creating one.');
return deployContract()
}
}
async function deployContract () {
const Registry = new ethers.ContractFactory(abi, phisherRegistryArtifacts.bytecode, signer);
const _name = 'MobyMask';
const registry = await Registry.deploy(_name);
const address = registry.address;
fs.writeFileSync(configPath, JSON.stringify({ address, name: _name, chainId: registry.deployTransaction.chainId }, null, 2));
try {
return await registry.deployed();
} catch (err) {
console.log('Deployment failed, trying to attach to existing contract.', err);
throw err;
}
}
async function attachToContract(address: string) {
const Registry = new ethers.Contract(address, abi, signer);
const registry = await Registry.attach(address);
console.log('Attaching to existing contract');
const deployed = await registry.deployed();
return deployed;
}
type Invocation = {
transaction: Transaction,
authority: SignedDelegation[],
};
type Transaction = {
to: string,
gasLimit: string,
data: string,
};
type SignedDelegation = {
delegation: Delegation,
signature: string,
}
type Delegation = {
delegate: string,
authority: string,
caveats: Caveat[],
};
type Caveat = {
enforcer: string,
terms: string,
}
type SignedInvocation = {
invocation: Invocation,
signature: string,
}
async function signDelegation (registry: ethers.Contract) {
const { chainId } = await provider.getNetwork();
const utilOpts = {
chainId,
verifyingContract: registry.address,
name: _name,
};
console.log('util opts', utilOpts);
const util = generateUtil(utilOpts)
const delegate = ethers.Wallet.createRandom();
// Prepare the delegation message.
// This contract is also a revocation enforcer, so it can be used for caveats:
const delegation = {
delegate: delegate.address,
authority: '0x0000000000000000000000000000000000000000000000000000000000000000',
caveats: [{
enforcer: registry.address,
terms: '0x0000000000000000000000000000000000000000000000000000000000000000',
}],
};
// Owner signs the delegation:
const signedDelegation = util.signDelegation(delegation, signer.privateKey);
const invitation = {
v:1,
signedDelegations: [signedDelegation],
key: delegate.privateKey,
}
console.log('A SIGNED DELEGATION/INVITE LINK:');
console.log(JSON.stringify(invitation, null, 2));
console.log((baseURI ?? DEFAULT_BASE_URI) + '/members?invitation=' + encodeURIComponent(JSON.stringify(invitation)));
}

View File

@ -15,7 +15,8 @@ watcher-erc20
watcher-erc721
watcher-uniswap-v3
watcher-mobymask-v2
mobymask-laconicd
mobymask-app
peer-test-app
test
eth-probe
keycloak

View File

@ -76,8 +76,10 @@ Clear volumes created by this stack:
# List all relevant volumes
docker volume ls -q --filter name=laconic*
docker volume ls -q --filter "name=.*fixturenet_geth_accounts|.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data"
# Remove all the listed volumes
docker volume rm $(docker volume ls -q --filter name=laconic*)
docker volume rm $(docker volume ls -q --filter "name=.*fixturenet_geth_accounts|.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data")
```
## Troubleshooting

View File

@ -76,10 +76,10 @@ Clear volumes created by this stack:
```bash
# List all relevant volumes
docker volume ls -q --filter name=laconic*
docker volume ls -q --filter "name=.*fixturenet_geth_accounts|.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data"
# Remove all the listed volumes
docker volume rm $(docker volume ls -q --filter name=laconic*)
docker volume rm $(docker volume ls -q --filter "name=.*fixturenet_geth_accounts|.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data")
```
## Troubleshooting

View File

@ -132,11 +132,11 @@ Clear volumes:
* List all relevant volumes:
```bash
docker volume ls -q --filter name=laconic*
docker volume ls -q --filter "name=.*mobymask_watcher_db_data|.*moby_data_server|.*fixturenet_geth_accounts|.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data"
```
* Remove all the listed volumes:
```bash
docker volume rm $(docker volume ls -q --filter name=laconic*)
docker volume rm $(docker volume ls -q --filter "name=.*mobymask_watcher_db_data|.*moby_data_server|.*fixturenet_geth_accounts|.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data")
```

View File

@ -4,9 +4,6 @@
```bash
laconic-so --stack mobymask-v2 deploy-system logs mobymask
# If only running watcher-mobymask-v2 pod
laconic-so --stack mobymask-v2 deploy-system --include watcher-mobymask-v2 logs mobymask
```
The invite link is seen at the end of the logs. Example log:
@ -38,9 +35,6 @@
```bash
laconic-so --stack mobymask-v2 deploy-system ps | grep mobymask-watcher-server
# If only running watcher-mobymask-v2 pod
laconic-so --stack mobymask-v2 deploy-system --include watcher-mobymask-v2 ps | grep mobymask-watcher-server
```
* Check logs:
@ -81,9 +75,6 @@
```bash
laconic-so --stack mobymask-v2 deploy-system exec mobymask-app "cat src/config.json"
# If only running watcher-mobymask-v2 pod
laconic-so --stack mobymask-v2 deploy-system --include watcher-mobymask-v2 exec mobymask-app "cat src/config.json"
```
The value of `address` field is the deployed contract address

View File

@ -106,7 +106,7 @@ Clear volumes created by this stack:
```bash
# List all relevant volumes
docker volume ls -q --filter name=laconic*
docker volume ls -q --filter "name=.*mobymask_watcher_db_data|.*moby_data_server|.*fixturenet_geth_accounts"
# Remove all the listed volumes
docker volume rm $(docker volume ls -q --filter name=laconic*)
docker volume rm $(docker volume ls -q --filter "name=.*mobymask_watcher_db_data|.*moby_data_server|.*fixturenet_geth_accounts")
```