-
Notifications
You must be signed in to change notification settings - Fork 2
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
WIP: copy indexer deposits data to scraper db #506
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
version: "3.7" | ||
|
||
networks: | ||
test-network: | ||
external: true | ||
|
||
services: | ||
backend: | ||
container_name: scraper-api-backend | ||
|
@@ -18,6 +22,8 @@ services: | |
depends_on: | ||
- postgres | ||
- redis | ||
networks: | ||
- test-network | ||
postgres: | ||
container_name: scraper-api-postgres | ||
image: postgres:12.2 | ||
|
@@ -27,21 +33,26 @@ services: | |
POSTGRES_PASSWORD: ${DB_PASSWORD} | ||
POSTGRES_DB: ${DB_DATABASE_NAME} | ||
PG_DATA: /var/lib/postgresql/data | ||
command: ["postgres", "-c", "log_statement=all"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just to debug the auth issue I am having. Can be deleted after |
||
ports: | ||
- 5432:5432 | ||
- 5433:5432 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is needed to avoid port collisions between indexer and scraper |
||
volumes: | ||
- scraper-api-pgdata:/var/lib/postgresql/data | ||
networks: | ||
- test-network | ||
redis: | ||
container_name: scraper-api-redis | ||
image: redis:6.2-alpine | ||
restart: always | ||
ports: | ||
- 6379:6379 | ||
- 6378:6379 | ||
command: ["redis-server", "--appendonly", "yes"] | ||
environment: | ||
REDIS_PASSWORD: ${REDIS_PASSWORD} | ||
volumes: | ||
- scraper-api-redis-volume:/data | ||
networks: | ||
- test-network | ||
volumes: | ||
backend-node-modules: | ||
scraper-api-pgdata: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
|
||
export class RewardedDeposit1735003840563 implements MigrationInterface { | ||
name = 'RewardedDeposit1735003840563'; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
CREATE TABLE "rewarded_deposit" ( | ||
"id" SERIAL NOT NULL, | ||
"relayHash" character varying NOT NULL, | ||
"depositTxHash" character varying NOT NULL, | ||
"depositId" integer NOT NULL, | ||
"originChainId" integer NOT NULL, | ||
"destinationChainId" integer NOT NULL, | ||
"depositor" character varying NOT NULL, | ||
"recipient" character varying NOT NULL, | ||
"inputToken" character varying NOT NULL, | ||
"inputAmount" character varying NOT NULL, | ||
"outputToken" character varying NOT NULL, | ||
"outputAmount" character varying NOT NULL, | ||
"exclusiveRelayer" character varying NOT NULL, | ||
"depositDate" TIMESTAMP NOT NULL, | ||
"fillTxHash" character varying NOT NULL, | ||
"relayer" character varying NOT NULL, | ||
"totalBridgeFeeUsd" character varying NOT NULL, | ||
"createdAt" TIMESTAMP NOT NULL DEFAULT now(), | ||
CONSTRAINT "UK_rewardedDeposit_depositId_originChainId" UNIQUE ("depositId", "originChainId"), | ||
CONSTRAINT "PK_891e96cd023b61f620566c0898a" PRIMARY KEY ("id"))`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`DROP TABLE "rewarded_deposit"`); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
|
||
export class OpRewardV21735659642491 implements MigrationInterface { | ||
name = 'OpRewardV21735659642491'; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`CREATE TABLE "op_reward_v2" ( | ||
"id" SERIAL NOT NULL, | ||
"depositId" integer NOT NULL, | ||
"originChainId" integer NOT NULL, | ||
"depositDate" TIMESTAMP NOT NULL, | ||
"recipient" character varying NOT NULL, | ||
"rate" numeric NOT NULL, | ||
"amount" character varying NOT NULL, | ||
"amountUsd" character varying NOT NULL, | ||
"rewardTokenId" integer NOT NULL, | ||
"windowIndex" integer, | ||
"isClaimed" boolean NOT NULL DEFAULT false, | ||
"createdAt" TIMESTAMP NOT NULL DEFAULT now(), | ||
"updatedAt" TIMESTAMP NOT NULL DEFAULT now(), | ||
CONSTRAINT "UK_opRewardV2_recipient_depId_chainId" UNIQUE ("recipient", "depositId", "originChainId"), | ||
CONSTRAINT "REL_f057b9c78adeb22f4f4fb69ea8" UNIQUE ("depositId", "originChainId"), | ||
CONSTRAINT "PK_fc4c022f3de3d4170ae8200c76b" PRIMARY KEY ("id")) | ||
`, | ||
); | ||
await queryRunner.query(`CREATE INDEX "IX_op_reward_v2_recipient" ON "op_reward_v2" ("recipient") `); | ||
await queryRunner.query(`ALTER TABLE "op_reward_v2" ADD CONSTRAINT "FK_op_reward_deposit" FOREIGN KEY ("depositId", "originChainId") REFERENCES "rewarded_deposit"("depositId","originChainId") ON DELETE NO ACTION ON UPDATE NO ACTION`); | ||
await queryRunner.query(`ALTER TABLE "op_reward_v2" ADD CONSTRAINT "FK_op_reward_token" FOREIGN KEY ("rewardTokenId") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "op_reward_v2" DROP CONSTRAINT "FK_op_reward_token"`); | ||
await queryRunner.query(`ALTER TABLE "op_reward_v2" DROP CONSTRAINT "FK_op_reward_deposit"`); | ||
await queryRunner.query(`DROP INDEX "public"."IX_op_reward_v2_recipient"`); | ||
await queryRunner.query(`DROP TABLE "op_reward_v2"`); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { Token } from "../../web3/model/token.entity"; | ||
import { | ||
Column, | ||
CreateDateColumn, | ||
Entity, | ||
Index, | ||
JoinColumn, | ||
ManyToOne, | ||
OneToOne, | ||
PrimaryGeneratedColumn, | ||
Unique, | ||
UpdateDateColumn, | ||
} from "typeorm"; | ||
import { RewardedDeposit } from "./RewardedDeposit.entity"; | ||
|
||
@Entity() | ||
@Unique("UK_opRewardV2_recipient_depId_chainId", ["recipient", "depositId", "originChainId"]) | ||
@Index("IX_op_reward_v2_recipient", ["recipient"]) | ||
export class OpRewardV2 { | ||
@PrimaryGeneratedColumn() | ||
id: number; | ||
|
||
@Column() | ||
depositId: number; | ||
|
||
@Column() | ||
originChainId: number; | ||
|
||
@OneToOne(() => RewardedDeposit) | ||
@JoinColumn([ | ||
{ name: "depositId", referencedColumnName: "depositId", foreignKeyConstraintName: "FK_op_reward_deposit" }, | ||
{ name: "originChainId", referencedColumnName: "originChainId", foreignKeyConstraintName: "FK_op_reward_deposit" }, | ||
]) | ||
deposit: RewardedDeposit; | ||
Comment on lines
+29
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This relation used to be ManyToOne, but I think it's ok to set it to OneToOne. |
||
|
||
@Column() | ||
depositDate: Date; | ||
|
||
@Column() | ||
recipient: string; | ||
|
||
@Column({ type: "decimal" }) | ||
rate: string; | ||
|
||
@Column() | ||
amount: string; | ||
|
||
@Column() | ||
amountUsd: string; | ||
|
||
@Column() | ||
rewardTokenId: number; | ||
|
||
@ManyToOne(() => Token) | ||
@JoinColumn([{ name: "rewardTokenId", referencedColumnName: "id", foreignKeyConstraintName: "FK_op_reward_token" }]) | ||
rewardToken: Token; | ||
|
||
// The window index set in the MerkleDistributor contract | ||
@Column({ nullable: true }) | ||
windowIndex: number; | ||
|
||
@Column({ default: false }) | ||
isClaimed: boolean; | ||
|
||
@CreateDateColumn() | ||
createdAt: Date; | ||
|
||
@UpdateDateColumn() | ||
updatedAt: Date; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { | ||
Column, | ||
CreateDateColumn, | ||
Entity, | ||
PrimaryGeneratedColumn, | ||
Unique, | ||
} from "typeorm"; | ||
|
||
@Entity() | ||
@Unique("UK_rewardedDeposit_depositId_originChainId", [ | ||
"depositId", | ||
"originChainId", | ||
]) | ||
export class RewardedDeposit { | ||
@PrimaryGeneratedColumn() | ||
id: number; | ||
|
||
@Column() | ||
relayHash: string; | ||
|
||
@Column() | ||
depositTxHash: string; | ||
|
||
@Column() | ||
depositId: number; | ||
|
||
@Column() | ||
originChainId: number; | ||
|
||
@Column() | ||
destinationChainId: number; | ||
|
||
@Column() | ||
depositor: string; | ||
|
||
@Column() | ||
recipient: string; | ||
|
||
@Column() | ||
inputToken: string; | ||
|
||
@Column() | ||
inputAmount: string; | ||
|
||
@Column() | ||
outputToken: string; | ||
|
||
@Column() | ||
outputAmount: string; | ||
|
||
@Column() | ||
exclusiveRelayer: string; | ||
|
||
@Column() | ||
depositDate: Date; | ||
|
||
@Column() | ||
fillTxHash: string; | ||
|
||
@Column() | ||
relayer: string; | ||
|
||
@Column() | ||
totalBridgeFeeUsd: string; | ||
|
||
@CreateDateColumn() | ||
createdAt: Date; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This network can be renamed.
I still have to check that both the indexer and scraper work fine using this network.
Indexer draft PR configuring the network: across-protocol/indexer#142