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

Ppe/gcp #158

Open
wants to merge 96 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
1e2aa36
adapt to gcp
ppedziwiatr Mar 18, 2023
7e9056b
chore: logging
ppedziwiatr Mar 24, 2023
f990346
fix: path fix
ppedziwiatr Mar 24, 2023
b597db5
fix: issue with pubsub config path
ppedziwiatr Mar 26, 2023
abb6530
fix: issue with pubsub config path
ppedziwiatr Mar 26, 2023
d161aa6
feat: access log middleware
ppedziwiatr Mar 26, 2023
95d622b
feat: alive route
ppedziwiatr Mar 26, 2023
803930f
fix: don't log health checks...
ppedziwiatr Mar 26, 2023
1c4031f
restore original lock timeout
ppedziwiatr Mar 27, 2023
96870d9
fix: sortKey-lastSortKey sanity chceck
ppedziwiatr Mar 27, 2023
4a2b399
cache network info
ppedziwiatr Mar 28, 2023
7142b52
network info check fix
ppedziwiatr Mar 28, 2023
52d92ad
stop loggin' shit
ppedziwiatr Apr 12, 2023
62d030c
feat: errors handling middleware
ppedziwiatr Apr 7, 2023
255054d
do not log arweave/info
ppedziwiatr Apr 13, 2023
faf12b1
remove logging
ppedziwiatr Apr 13, 2023
4fc8c1b
logging fix
ppedziwiatr Apr 18, 2023
ea21dd2
feat: async bundling
ppedziwiatr Feb 27, 2023
807c314
feat: remove data from data item when logging error
asiaziola Apr 27, 2023
d24b141
access log fix
ppedziwiatr Apr 27, 2023
71c6461
log format
ppedziwiatr Apr 27, 2023
6171a6e
fix: change new line regex
asiaziola Apr 27, 2023
fa97e63
trx ooops
ppedziwiatr Apr 28, 2023
4b4be53
extending endpoint /gcp/alive to include some database connection status
Tadeuchi Apr 25, 2023
afef478
extending endpoint /gcp/alive to include some database connection sta…
Tadeuchi Apr 25, 2023
fcaa316
feat: interaction tags size limit verification
asiaziola May 22, 2023
40bde13
fix: set lastSortKey in interaction
ppedziwiatr Jun 5, 2023
93e44c1
fix: contract data for nested bundle contracts (#170)
asiaziola Jun 19, 2023
c4461bb
fix: get chached network info only if not in replica (#171)
asiaziola Jun 19, 2023
fa9b451
feat: interaction data items endpoint (#172)
asiaziola Jun 28, 2023
c19c82a
temp interaction conf. status
ppedziwiatr Jul 21, 2023
089b085
fix: block height should be get after locking transaction (#174)
asiaziola Jul 27, 2023
a242eda
feat: add srcTxId to register contract messages
ppedziwiatr Aug 4, 2023
a863301
fix: srcTxId in contractsMetadata
ppedziwiatr Aug 4, 2023
cbdbe0f
fix: pass srcTxId to a published message
ppedziwiatr Aug 4, 2023
00bf41c
temp
ppedziwiatr Jun 5, 2023
1532c7d
feat: new L1 syncer
ppedziwiatr Jun 5, 2023
72d1c27
chore: logging
ppedziwiatr Jun 6, 2023
c559782
fix: finishedBlockTimestamp
ppedziwiatr Jun 6, 2023
3f9c03c
fix: code formatter...
ppedziwiatr Jun 6, 2023
a366c9b
validation
ppedziwiatr Jun 6, 2023
b8ad42a
chore: naqrwiaj only 1
ppedziwiatr Jun 7, 2023
4ef22b7
feat: env - local,dev,main
ppedziwiatr Jun 13, 2023
8665fda
chore: nakurwiaj, but not so much
ppedziwiatr Jun 20, 2023
2482fc7
chore: null is cool
ppedziwiatr Jun 20, 2023
dbf1a2e
chore: nakurwiaj to L1 and L2
ppedziwiatr Jun 21, 2023
20abfb8
fix: interactions, not contracts
ppedziwiatr Jun 23, 2023
0b31d0d
chore: naq
ppedziwiatr Jun 24, 2023
46071b8
chore: warp wallet in naq
ppedziwiatr Jun 24, 2023
e58f738
adjust data item sequencer endpoint
asiaziola Aug 3, 2023
627186b
new nakurwiaj
asiaziola Aug 3, 2023
5e49ac7
chore: save errors on exit
ppedziwiatr Aug 3, 2023
f4e645b
exit properly from nakurwiaj
ppedziwiatr Aug 3, 2023
3192e98
chore: return sortKey from sequencer
ppedziwiatr Aug 8, 2023
891cd40
fix: tags size limit should be checked when preparing tags for nested…
asiaziola Sep 15, 2023
284eac2
feat: return original src tx id from contract endpoint
ppedziwiatr Sep 18, 2023
f7a741b
Endpoint with sequencer address
szynwelski Oct 27, 2023
fb7f783
Merge pull request #182 from warp-contracts/szynek/sequencer-address
szynwelski Nov 8, 2023
24007bb
feat: contracts by tag route (#184)
asiaziola Nov 9, 2023
4c0f17b
feat: register contracts based on metadata from Arweave gql (#185)
asiaziola Nov 14, 2023
17b43b2
feat: add srcTxId to contracts-by-tag route
asiaziola Nov 14, 2023
71a445c
contracts-by-source route - remove interactions count (#186)
asiaziola Nov 16, 2023
f989f28
sql: contract_tx_tags_idx
asiaziola Nov 16, 2023
5a6d978
contracts-by-tags - accept tags list (#188)
asiaziola Nov 17, 2023
f63cf3b
chore: refactor arweave network info cache
ppedziwiatr Nov 16, 2023
b04b3a4
chore: reduce max connections
ppedziwiatr Nov 21, 2023
6c26934
chore: reduce max connections
ppedziwiatr Nov 21, 2023
0008570
chore: increase max connections
ppedziwiatr Nov 21, 2023
47fa4f5
chore: increase arweave network sync interval
ppedziwiatr Nov 21, 2023
edc8dc3
chore: commit...
ppedziwiatr Nov 21, 2023
910e4a9
chore: logging
ppedziwiatr Nov 21, 2023
b202c13
feat: input in interaction data field (#189)
asiaziola Nov 24, 2023
52161ea
fix: null data when cannot be parsed
asiaziola Nov 24, 2023
5188a8d
interactions sonar - input in data update
asiaziola Nov 27, 2023
03aa89a
fix: input tag fix
ppedziwiatr Nov 27, 2023
846d798
fix: add input tag to interaction tags list when input format is equa…
asiaziola Nov 29, 2023
f796ff2
fix: input in data - backwards compatibility
asiaziola Nov 29, 2023
347bd5b
chore: stop using javascript.
ppedziwiatr Nov 30, 2023
29721c2
contracts-by-source - add optional total interactions count (#192)
asiaziola Dec 4, 2023
579a662
sequencer node list
szynwelski Dec 8, 2023
b27a443
interactionsSortKeyRoute_v3 search starts from min sk
Tadeuchi Dec 21, 2023
018454d
block view
ppedziwiatr Dec 26, 2023
d92eb79
whitelisted wallet
ppedziwiatr Dec 26, 2023
606d79d
chore: remove 2nd redis publisher
ppedziwiatr Feb 29, 2024
6cc57f0
Revert "chore: remove 2nd redis publisher"
Tadeuchi Mar 22, 2024
98f41de
fix: set env in app's context
asiaziola May 20, 2024
55ae1c9
Warpy - registration date
asiaziola Jul 1, 2024
7e4359f
Warpy - registration date, null when not found
asiaziola Jul 1, 2024
6ace18a
Warpy - registration date, name result
asiaziola Jul 1, 2024
2486118
Warpy - joinSeason2 endpoint
asiaziola Jul 1, 2024
ddeeee8
Warpy - joinSeason2 with left join
asiaziola Jul 1, 2024
3733813
Warpy - joinSeason2 res fix
asiaziola Jul 1, 2024
c38cd79
add new wallet to the whitelist
asiaziola Aug 6, 2024
b595bb5
remove wallet from whitelist
asiaziola Aug 6, 2024
341b734
sql injection fix for v1 interactions
Tadeuchi Sep 27, 2024
1a2594e
Warpy - join-season-3
asiaziola Nov 25, 2024
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
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ node_modules
dist
.secrets/sw-gateway-ec2-key.cer
gateway.lock
dump*
network-cache.json
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ node_modules
.idea
db*.sqlite
.secrets
.secrets/.env
.secrets/local.env
gateway.lock
network-cache.json
.DS_Store
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM node:14.18.2-alpine
FROM node:18

RUN mkdir /app
WORKDIR /app

# Installing required npm packages
COPY package.json package.json
COPY yarn.lock yarn.lock
RUN yarn
RUN yarn && yarn global add pm2

# Copying all files
COPY . .
Expand All @@ -17,4 +17,4 @@ RUN yarn build
EXPOSE 5666

# Running the gateway
CMD yarn start:prod --env_path .secrets/.env
CMD [ "pm2-runtime", "start", "dist/gateway/init.js", "--name", "gateway", "-i", "max", "--", "--noSync" ]
2 changes: 1 addition & 1 deletion docker-build.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
docker build -t redstone-sw-gateway .
docker build -t warp-gateway .
2 changes: 1 addition & 1 deletion docker-run.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
docker run -t -i -p 8080:5666 redstone-sw-gateway
docker run -t -i -p 8080:5666 warp-gateway
24 changes: 24 additions & 0 deletions k8s/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: node
labels:
name: node
spec:
replicas: 1
selector:
matchLabels:
app: node
template:
metadata:
labels:
app: node
spec:
containers:
- name: node
image: gcr.io/warp-372209/docker-image:2
imagePullPolicy: Always
ports:
- containerPort: 5666
protocol: TCP
restartPolicy: Always
18 changes: 18 additions & 0 deletions k8s/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: gke-warp-gw-ingress
annotations:
kubernetes.io/ingress.global-static-ip-name: "gke-warp-gw-ip"
spec:
rules:
- host: "chart-example.local"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: gke-warp-gw-deployment
port:
number: 5666
21 changes: 21 additions & 0 deletions k8s/podscaler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: node
namespace: default
labels:
app: node
spec:
scaleTargetRef:
kind: Deployment
name: node
apiVersion: apps/v1
minReplicas: 2
maxReplicas: 5
metrics:
- type: Resource
resource:
name: cpu
target:
averageValue: 70
type: Utilization
12 changes: 12 additions & 0 deletions k8s/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: node
labels:
service: node
spec:
selector:
app: node
type: LoadBalancer
ports:
- port: 5666
30 changes: 19 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
"dev:network:watch": "ts-node-dev --watch -- src/gateway/init.ts",
"build": "tsc",
"start:prod": "node dist/gateway/init.js",
"start:prod:noSync": "node dist/gateway/init.js --noSync",
"start:prod:replica": "node dist/gateway/init.js --replica",
"start:local": "node dist/gateway/init.js --env_path .secrets/local.env --local",
"start:local:replica": "node dist/gateway/init.js --env_path .secrets/local.env --replica --local",
"start:local:testnet": "node dist/gateway/init.js --env_path .secrets/local-testnet.env --local",
"start:local:noSync": "node dist/gateway/init.js --env_path .secrets/local.env --local --noSync",
"start:prod:testnet": "node dist/gateway/init.js --env_path .secrets/prod-testnet.env",
"format": "prettier --write .",
"test": "jest",
Expand All @@ -19,31 +21,35 @@
"license": "MIT",
"author": "Redstone Team <[email protected]>",
"dependencies": {
"@bundlr-network/client": "0.9.6",
"@irys/sdk": "0.1.1",
"@idena/vrf-js": "^1.0.1",
"@koa/cors": "3.2.0",
"@koa/router": "10.1.1",
"@types/yargs": "17.0.7",
"JSONStream": "^1.3.5",
"arbundles": "^0.7.0",
"arweave": "1.11.8",
"arbundles": "^0.9.6",
"arweave": "1.13.7",
"axios": "^0.26.1",
"dotenv": "16.0.3",
"elliptic": "^6.5.4",
"ethers": "^5.7.2",
"exponential-backoff": "3.1.0",
"ioredis": "^5.2.4",
"knex": "0.95.14",
"koa": "2.13.4",
"koa-bodyparser": "4.3.0",
"knex": "2.4.2",
"koa": "2.14.1",
"koa-bodyparser": "4.4.0",
"koa-compress": "5.1.0",
"nodemailer": "^6.9.1",
"parse-json-stream": "^2.4.0",
"pg": "8.7.3",
"pg": "8.10.0",
"pg-query-stream": "^4.2.3",
"raw-body": "^2.5.1",
"undici": "5.14.0",
"warp-contracts": "1.2.48",
"undici": "5.21.0",
"uuid": "^9.0.0",
"warp-arbundles": "1.0.0",
"warp-contracts": "1.4.26-beta.0",
"warp-contracts-new": "npm:warp-contracts",
"warp-contracts-old": "npm:[email protected]",
"warp-contracts-plugin-signature": "^1.0.16",
"warp-contracts-pubsub": "^1.0.3",
"warp-contracts-subscription-plugin": "1.0.4",
"warp-signature": "1.0.4",
Expand All @@ -56,6 +62,8 @@
"@types/koa__router": "8.0.11",
"@types/nodemailer": "^6.4.7",
"@types/object-hash": "2.2.1",
"@types/uuid": "^9.0.1",
"@types/yargs": "17.0.7",
"@typescript-eslint/eslint-plugin": "4.33.0",
"@typescript-eslint/parser": "4.33.0",
"autocannon": "^7.6.0",
Expand All @@ -68,6 +76,6 @@
"ts-jest": "27.1.2",
"ts-node": "^10.2.1",
"tsconfig-paths": "^3.10.1",
"typescript": "4.5.2"
"typescript": "4.9.5"
}
}
39 changes: 22 additions & 17 deletions src/bundlr/connect.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,46 @@
import { WarpLogger } from 'warp-contracts';
import Bundlr from '@bundlr-network/client';
import fs from 'fs';
import { TaskRunner } from '../gateway/tasks/TaskRunner';
import { GatewayContext } from '../gateway/init';
import { JWKInterface } from 'arweave/node/lib/wallet';
import { BUNDLR_NODE1_URL } from '../constants';
import { WarpLogger } from "warp-contracts";
import fs from "fs";
import { TaskRunner } from "../gateway/tasks/TaskRunner";
import { GatewayContext } from "../gateway/init";
import { JWKInterface } from "arweave/node/lib/wallet";
import { BUNDLR_NODE1_URL } from "../constants";
import Irys from "@irys/sdk";

const BUNDLR_CHECK_INTERVAL = 3600000;

export async function runBundlrCheck(context: GatewayContext) {
await TaskRunner.from('[bundlr balance check]', checkBalance, context).runSyncEvery(BUNDLR_CHECK_INTERVAL, true);
await TaskRunner.from("[bundlr balance check]", checkBalance, context).runSyncEvery(BUNDLR_CHECK_INTERVAL, true);
}

export function initBundlr(logger: WarpLogger): { bundlr: Bundlr; jwk: JWKInterface } {
const jwk = JSON.parse(fs.readFileSync('.secrets/warp-wallet-jwk.json').toString());
const bundlr = new Bundlr(BUNDLR_NODE1_URL, 'arweave', jwk, {
timeout: 5000,
export function initBundlr(logger: WarpLogger): { bundlr: Irys; jwk: JWKInterface } {
const jwk = JSON.parse(fs.readFileSync(".secrets/warp-wallet-jwk.json").toString());
const bundlr = new Irys({
url: BUNDLR_NODE1_URL,
token: "arweave",
key: jwk,
config: {
timeout: 5000
}
});
logger.info('Running bundlr on', {
logger.info("Running bundlr on", {
address: bundlr.address,
currency: bundlr.currency,
currency: bundlr.token
});

return { bundlr, jwk };
}

async function checkBalance(context: GatewayContext) {
const { bundlr, logger } = context;
logger.debug('Checking Bundlr balance');
logger.debug("Checking Bundlr balance");

// Check your balance
const balance = await bundlr.getLoadedBalance();
logger.debug('Current Bundlr balance', balance);
logger.debug("Current Bundlr balance", balance);

// If balance is < 0.5 AR
if (balance.isLessThan(5e11)) {
logger.debug('Funding Bundlr');
logger.debug("Funding Bundlr");
// Fund your account with 0.5 AR
//const fundResult = await bundlr.fund(5e11);
//logger.debug("Fund result", fundResult);
Expand Down
16 changes: 14 additions & 2 deletions src/db/databaseSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ interface DbData {
export class DatabaseSource {
public db: Knex[] = [];
public primaryDb: Knex | null = null;
public healthCheckConnection: Knex | null = null;
private mailClient: Transporter<SMTPTransport.SentMessageInfo>;

constructor(dbData: DbData[]) {
constructor(dbData: DbData[], healthCheckConnection?: DbData) {
for (let i = 0; i < dbData.length; i++) {
this.db[i] = this.connectDb(dbData[i]);
if (dbData[i].primaryDb) {
Expand All @@ -39,6 +40,9 @@ export class DatabaseSource {
if (this.primaryDb == null) {
throw new Error('Exactly one db must be set as primary');
}
if (healthCheckConnection != null) {
this.healthCheckConnection = this.connectDb(healthCheckConnection);
}
this.mailClient = client();
}

Expand Down Expand Up @@ -251,6 +255,14 @@ export class DatabaseSource {
return db.raw(query, bindings);
}

public healthCheckEnabled(): boolean {
return this.healthCheckConnection != null;
}

public healthCheck(query: string, bindings?: any) {
return this.healthCheckConnection!!.raw(query, bindings);
}

public async loopThroughDb(callback: any, recordName: string): Promise<any> {
let result: any;
try {
Expand Down Expand Up @@ -278,7 +290,7 @@ export class DatabaseSource {
useNullAsDefault: true,
pool: {
min: 5,
max: 30,
max: 20,
createTimeoutMillis: 3000,
acquireTimeoutMillis: 30000,
idleTimeoutMillis: 30000,
Expand Down
4 changes: 2 additions & 2 deletions src/db/insertInterfaces.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GQLTagInterface, Tags } from 'warp-contracts';
import { WarpDeployment } from '../gateway/router/routes/deployContractRoute';
import { WarpDeployment } from '../gateway/router/routes/deploy/deployContractRoute';

export interface SequencerInsert {
original_sig: string;
Expand Down Expand Up @@ -49,7 +49,7 @@ export interface ContractInsert {
block_timestamp: number;
content_type: string | undefined;
contract_tx: {
tags: Tags;
tags: { name: string; value: string }[];
};
bundler_contract_tx_id: string;
bundler_contract_node: string;
Expand Down
49 changes: 0 additions & 49 deletions src/gateway/LastTxSyncer.ts

This file was deleted.

Loading