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

chore: improved stats-cards with long content #198

Open
wants to merge 78 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
5708979
init
FilipHarald Oct 28, 2024
d5d0206
k8s
FilipHarald Oct 28, 2024
2f79e79
now receiving aztec-connection event
FilipHarald Oct 28, 2024
4ef7bcf
it's connecting but not showing anything fun
FilipHarald Oct 29, 2024
bbc6f63
done
FilipHarald Oct 29, 2024
d365760
done
FilipHarald Oct 30, 2024
eaac3ca
Merge branch 'main' of github.com:aztlan-labs/chicmoz into service/az…
FilipHarald Oct 30, 2024
9a97826
more like main
FilipHarald Oct 30, 2024
e0f8680
More like main
FilipHarald Oct 30, 2024
b64bb0e
Merge branch 'main' of github.com:aztlan-labs/chicmoz into service/az…
FilipHarald Oct 30, 2024
7773f7a
fixed it
FilipHarald Oct 31, 2024
696bca1
done
FilipHarald Oct 31, 2024
87f8afb
small refactor and it runs without errors
FilipHarald Oct 31, 2024
59cd57f
added code for broadcasting, but tx is being dropped
FilipHarald Oct 31, 2024
236bf8d
still not working
FilipHarald Oct 31, 2024
f7fa1b2
still not working
FilipHarald Oct 31, 2024
53e5274
throw comment
FilipHarald Oct 31, 2024
d4a9104
changed comment
FilipHarald Oct 31, 2024
3025524
now it works
FilipHarald Oct 31, 2024
9e72205
done
FilipHarald Oct 31, 2024
a2c8327
broadcasting unconstrained events as well
FilipHarald Oct 31, 2024
8f4191e
Merge branch 'main' of github.com:aztlan-labs/chicmoz into feat/store…
FilipHarald Oct 31, 2024
a781d42
success
FilipHarald Oct 31, 2024
8350cbd
no comment
FilipHarald Oct 31, 2024
f59d2f2
added disable button
Mautjee Oct 31, 2024
fd3c8e7
mobile friendly
Mautjee Oct 31, 2024
9832749
Merge branch 'main' into ui/tx-effects-disable-buttons
Mautjee Oct 31, 2024
14a19d5
update loops
Mautjee Oct 31, 2024
345db09
hotfix: add sub title to Chicmoz
FilipHarald Nov 1, 2024
3a7699b
Merge branch 'main' of github.com:aztlan-labs/chicmoz into feat/store…
FilipHarald Nov 1, 2024
1250d47
Merge branch 'ui/tx-effects-disable-buttons' of github.com:aztlan-lab…
FilipHarald Nov 1, 2024
fe0dd72
Merge branch 'main' of github.com:aztlan-labs/chicmoz into feat/store…
FilipHarald Nov 1, 2024
c11650f
local sandbox
FilipHarald Nov 1, 2024
0cdc490
WIP
FilipHarald Nov 1, 2024
a447c4e
Merge branch 'main' of github.com:aztlan-labs/chicmoz into feat/store…
FilipHarald Nov 1, 2024
31a1329
yarn
FilipHarald Nov 1, 2024
c3ae358
Merge branch 'main' of github.com:aztlan-labs/chicmoz into feat/store…
FilipHarald Nov 1, 2024
87c6fc7
Merge branch 'main' of github.com:aztlan-labs/chicmoz into feat/store…
FilipHarald Nov 1, 2024
7f24910
hotfix: websocket hook now properly appends instead of prepend
FilipHarald Nov 1, 2024
1386b17
done
FilipHarald Nov 1, 2024
77e4a30
less space
FilipHarald Nov 1, 2024
7045171
less diff
FilipHarald Nov 1, 2024
76426b9
Merge branch 'main' of github.com:aztlan-labs/chicmoz into feat/store…
FilipHarald Nov 1, 2024
e53d291
done
FilipHarald Nov 1, 2024
72047c7
done
FilipHarald Nov 1, 2024
eb0fecb
Merge branch 'main' of github.com:aztlan-labs/chicmoz into feat/serve…
FilipHarald Nov 4, 2024
ce49a35
Merge branch 'feat/serve_and_display_contract_broadcast_data' of gith…
FilipHarald Nov 4, 2024
f8c3086
images
FilipHarald Nov 4, 2024
13530f5
link
FilipHarald Nov 4, 2024
9cf7bca
pt 2
FilipHarald Nov 4, 2024
a618e63
more skaffolds
FilipHarald Nov 4, 2024
ae6cd7c
not working
FilipHarald Nov 4, 2024
ac64e6a
done
FilipHarald Nov 4, 2024
0d9c083
done
FilipHarald Nov 4, 2024
b90ff67
getting there
FilipHarald Nov 4, 2024
90a9e63
finito
FilipHarald Nov 4, 2024
7b08085
store done
FilipHarald Nov 4, 2024
a7fd9b0
pt1
FilipHarald Nov 5, 2024
25a5286
does not crash
FilipHarald Nov 5, 2024
8350b91
Merge branch 'main' into feat/pending_l2_txs
FilipHarald Nov 5, 2024
96e5c96
done
FilipHarald Nov 5, 2024
546483b
Merge branch 'main' of github.com:aztlan-labs/chicmoz into feat/pendi…
FilipHarald Nov 5, 2024
1428b56
Merge branch 'feat/pending_l2_txs' of github.com:aztlan-labs/chicmoz …
FilipHarald Nov 5, 2024
061f536
fixed it
FilipHarald Nov 5, 2024
ff47aef
Merge branch 'main' of github.com:aztlan-labs/chicmoz into chore/skaf…
FilipHarald Nov 5, 2024
182e513
Merge branch 'chore/skaffold-files' of github.com:aztlan-labs/chicmoz…
FilipHarald Nov 5, 2024
5e333c8
working
FilipHarald Nov 5, 2024
bfa24a4
Merge branch 'main' of github.com:aztlan-labs/chicmoz into feat/pendi…
FilipHarald Nov 5, 2024
f7dab33
format
FilipHarald Nov 5, 2024
e73a813
fixes
FilipHarald Nov 5, 2024
47cbb93
shit works
FilipHarald Nov 5, 2024
cb69960
done
FilipHarald Nov 5, 2024
fa414f2
working
FilipHarald Nov 5, 2024
ef16f9e
done
FilipHarald Nov 5, 2024
b759297
format
FilipHarald Nov 5, 2024
cb4b3e3
Merge branch 'main' of github.com:aztlan-labs/chicmoz into feat/pendi…
FilipHarald Nov 5, 2024
762330d
fixed it
FilipHarald Nov 5, 2024
c993950
fixed stats-cards
FilipHarald Nov 5, 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
33 changes: 19 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Requirements:
**terminal 1:**

```sh
minikube start --kubernetes-version=v1.25.3 --cpus max --memory max && skaffold run
minikube start --kubernetes-version=v1.25.3 --cpus max --memory max && skaffold run -f k8s/local/skaffold.default.yaml
```

**terminal 2:**
Expand All @@ -25,35 +25,40 @@ minikube start --kubernetes-version=v1.25.3 --cpus max --memory max && skaffold
./scripts/miscallaneous.sh
```

### with Sandbox
Now you can access the explorer at http://explorer-ui.localhost and also...

Default settings is to run against the Devnet, if you want to run against the Sandbox you need to do one of the following:
- API: http://explorer-api.localhost
- index of API: http://explorer-api.localhost/v1/d1e2083a-660c-4314-a6f2-1d42f4b944f4/l2/index

### Different Aztec-setups

#### Option 1 - your own existing sandbox running on your machine
#### Option 1 - default

Update the `CHICMOZ_AZTEC_RPC` in the `.chicmoz-local.env` to your sandbox rpc url.
Default settings is to set up a sandbox in the local cluster.

#### Option 2 - run the sandbox in the local cluster
#### Option 0 - connect to your already running sandbox or to public devnet

Update to the commented out config in both...
Update the `CHICMOZ_AZTEC_RPC` in the `.chicmoz-local.env` to desired endpoint and then run

- `k8s/local/skaffold.local.yaml`
- `k8s/local/aztec-listener/deployment.yaml`
```sh
skaffold run -f k8s/local/skaffold.remote_aztec.yaml
```

## Pro tip

### 1

after the first time you have deployed the app you can run the following command to have faster deployments:

```sh
skaffold run -f k8s/local/skaffold.local.light.yaml
skaffold run -f k8s/local/skaffold.default_dev.yaml
```

when developing locally you can command out the creation of the `explorer-ui` and run it locally
### 2

if you run the explorer with `skaffold run -f k8s/local/skaffold.no_ui.yaml` you can run the explorer-ui locally for even faster development:

```
cd services/exporer-ui/
yarn dev
```

- API: http://explorer-api.localhost
- index of API: http://explorer-api.localhost/v1/d1e2083a-660c-4314-a6f2-1d42f4b944f4/l2/index
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ manifests:
- k8s/local/auth/deployment.yaml
- k8s/local/auth/service.yaml
- k8s/local/aztec-event-cannon/deployment.yaml
- k8s/local/aztec-listener/remote_devnet_deployment.yaml
- k8s/local/aztec-listener/remote_aztec_deployment.yaml
helm:
releases:
- name: ingress-nginx
Expand Down
9 changes: 8 additions & 1 deletion packages/types/src/aztec/l2TxEffect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const unencryptedLogEntrySchema = z.object({

export const chicmozL2PendingTxSchema = z.object({
hash: hexStringSchema,
birthTimestamp: z.number().optional(),
data: z.string(),
noteEncryptedLogs: z.string(),
encryptedLogs: z.string(),
Expand All @@ -27,6 +28,9 @@ export const chicmozL2PendingTxSchema = z.object({
publicTeardownFunctionCall: z.string(),
});

/**
* Represents effects of a transaction on the L2 state.
*/
export const chicmozL2TxEffectSchema = z.object({
revertCode: z.preprocess(
(val) => {
Expand All @@ -35,8 +39,11 @@ export const chicmozL2TxEffectSchema = z.object({
},
z.object({ code: z.number() }),
),
/** The hash of the transaction that caused these effects. */
hash: hexStringSchema,
txHash: hexStringSchema.optional(), // TODO: remove optional
/** The hash of the transaction and its effects. */
txHash: hexStringSchema,
txBirthTimestamp: z.number().optional(),
transactionFee: frNumberSchema,
noteHashes: z.array(frSchema),
nullifiers: z.array(frSchema),
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/aztec/special.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type ChicmozL2ContractInstanceDeluxe = z.infer<
export const chicmozL2TxEffectDeluxeSchema = z.object({
...chicmozL2TxEffectSchema.shape,
blockHeight: z.lazy(() => chicmozL2BlockSchema.shape.height),
txBirthTimestamp: z.number(),
timestamp: z.lazy(
() =>
chicmozL2BlockSchema.shape.header.shape.globalVariables.shape.timestamp
Expand Down
4 changes: 2 additions & 2 deletions services/aztec-listener/src/aztec/txs_poller.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Tx } from "@aztec/aztec.js";
import { BLOCK_POLL_INTERVAL_MS } from "../constants.js";
import { TX_POLL_INTERVAL_MS } from "../constants.js";
import { getPendingTxs } from "./network-client.js";
import { onPendingTxs } from "../event-handler/index.js";

Expand All @@ -8,7 +8,7 @@ let pollInterval: NodeJS.Timeout;
export const startPolling = () => {
pollInterval = setInterval(() => {
void fetchAndPublishPendingTxs();
}, BLOCK_POLL_INTERVAL_MS);
}, TX_POLL_INTERVAL_MS);
};

export const stopPolling = () => {
Expand Down
3 changes: 2 additions & 1 deletion services/aztec-listener/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const BLOCK_POLL_INTERVAL_MS = Number(process.env.BLOCK_INTERVAL_MS) || 2000;
export const BLOCK_POLL_INTERVAL_MS = Number(process.env.BLOCK_INTERVAL_MS) || 3000;
export const TX_POLL_INTERVAL_MS = Number(process.env.TX_POLL_INTERVAL_MS) || 500;
export const MAX_BATCH_SIZE_FETCH_MISSED_BLOCKS = Number(process.env.MAX_BATCH_SIZE_FETCH_MISSED_BLOCKS) || 50;
export const AZTEC_LISTEN_FOR_BLOCKS = process.env.AZTEC_LISTEN_FOR_BLOCKS === "true";
export const AZTEC_LISTEN_FOR_PENDING_TXS = process.env.AZTEC_LISTEN_FOR_PENDING_TXS === "true";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ CREATE TABLE IF NOT EXISTS "public_data_write" (
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "tx_effect" (
"hash" varchar PRIMARY KEY NOT NULL,
"txHash" varchar NOT NULL,
"tx_time_of_birth" timestamp DEFAULT now() NOT NULL,
"index" integer NOT NULL,
"revert_code" smallint NOT NULL,
"transaction_fee" bigint NOT NULL,
Expand Down Expand Up @@ -160,6 +162,18 @@ CREATE TABLE IF NOT EXISTS "state" (
"partial_id" uuid NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "tx" (
"hash" varchar PRIMARY KEY NOT NULL,
"birth_timestamp" timestamp DEFAULT now() NOT NULL,
"data" text NOT NULL,
"note_encrypted_logs" text NOT NULL,
"encrypted_logs" text NOT NULL,
"unencrypted_logs" text NOT NULL,
"client_ivc_proof" text NOT NULL,
"enqueued_public_functions" jsonb NOT NULL,
"public_teardown_function_call" text NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "l2_contract_class_registered" (
"block_hash" varchar NOT NULL,
"contract_class_id" varchar(66) NOT NULL,
Expand Down Expand Up @@ -364,3 +378,5 @@ DO $$ BEGIN
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "tx_hash_index" ON "tx_effect" USING btree ("txHash");
98 changes: 96 additions & 2 deletions services/explorer-api/migrations/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6ea46951-3aa8-4e0c-813c-5831c4d6e2f9",
"id": "cfc8941b-919b-4bbe-9e32-fa2c7eb733bb",
"prevId": "00000000-0000-0000-0000-000000000000",
"version": "7",
"dialect": "postgresql",
Expand Down Expand Up @@ -359,6 +359,19 @@
"primaryKey": true,
"notNull": true
},
"txHash": {
"name": "txHash",
"type": "varchar",
"primaryKey": false,
"notNull": true
},
"tx_time_of_birth": {
"name": "tx_time_of_birth",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"index": {
"name": "index",
"type": "integer",
Expand Down Expand Up @@ -414,7 +427,23 @@
"notNull": true
}
},
"indexes": {},
"indexes": {
"tx_hash_index": {
"name": "tx_hash_index",
"columns": [
{
"expression": "txHash",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
Expand Down Expand Up @@ -1007,6 +1036,71 @@
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"public.tx": {
"name": "tx",
"schema": "",
"columns": {
"hash": {
"name": "hash",
"type": "varchar",
"primaryKey": true,
"notNull": true
},
"birth_timestamp": {
"name": "birth_timestamp",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"data": {
"name": "data",
"type": "text",
"primaryKey": false,
"notNull": true
},
"note_encrypted_logs": {
"name": "note_encrypted_logs",
"type": "text",
"primaryKey": false,
"notNull": true
},
"encrypted_logs": {
"name": "encrypted_logs",
"type": "text",
"primaryKey": false,
"notNull": true
},
"unencrypted_logs": {
"name": "unencrypted_logs",
"type": "text",
"primaryKey": false,
"notNull": true
},
"client_ivc_proof": {
"name": "client_ivc_proof",
"type": "text",
"primaryKey": false,
"notNull": true
},
"enqueued_public_functions": {
"name": "enqueued_public_functions",
"type": "jsonb",
"primaryKey": false,
"notNull": true
},
"public_teardown_function_call": {
"name": "public_teardown_function_call",
"type": "text",
"primaryKey": false,
"notNull": true
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"public.l2_contract_class_registered": {
"name": "l2_contract_class_registered",
"schema": "",
Expand Down
4 changes: 2 additions & 2 deletions services/explorer-api/migrations/meta/_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
{
"idx": 0,
"version": "7",
"when": 1730468944923,
"tag": "0000_absurd_carlie_cooper",
"when": 1730817509967,
"tag": "0000_clean_post",
"breakpoints": true
}
]
Expand Down
1 change: 1 addition & 0 deletions services/explorer-api/src/database/controllers/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * as l2Block from "./l2block/index.js";
export * as l2Contract from "./l2contract/index.js";
export * as l2TxEffect from "./l2TxEffect/index.js";
export * as l2Tx from "./l2Tx/index.js";
export * as l2 from "./l2/index.js";
export * as signOfLife from "./sign-of-life.js";
export * as aztecChainConnection from "./aztec-chain-connection.js";
24 changes: 24 additions & 0 deletions services/explorer-api/src/database/controllers/l2Tx/get-tx.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {
chicmozL2PendingTxSchema,
type ChicmozL2PendingTx,
} from "@chicmoz-pkg/types";
import { asc, getTableColumns } from "drizzle-orm";
import { z } from "zod";
import { getDb as db } from "../../../database/index.js";
import { l2Tx } from "../../../database/schema/l2tx/index.js";

export const getTxs = async (): Promise<ChicmozL2PendingTx[]> => {
const res = await db()
.select({
...getTableColumns(l2Tx),
})
.from(l2Tx)
.orderBy(asc(l2Tx.birthTimestamp));
if (!res) return [];
return z.array(chicmozL2PendingTxSchema).parse(
res.map((tx) => ({
...tx,
birthTimestamp: tx.birthTimestamp.getTime(),
}))
);
};
3 changes: 3 additions & 0 deletions services/explorer-api/src/database/controllers/l2Tx/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./get-tx.js";
export * from "./replace-txs-with-tx-effects.js";
export * from "./store.js";
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { type ChicmozL2TxEffect } from "@chicmoz-pkg/types";
import { eq } from "drizzle-orm";
import { getDb as db } from "../../../database/index.js";
import { l2Tx } from "../../../database/schema/l2tx/index.js";
import { logger } from "../../../logger.js";

export const replaceTxsWithTxEffects = async (
txEffects: ChicmozL2TxEffect[]
): Promise<void> => {
return await db().transaction(async (dbTx) => {
for (const txEffect of Object.values(txEffects)) {
const tx = await dbTx
.delete(l2Tx)
.where(eq(l2Tx.hash, txEffect.txHash))
.returning();
if (!tx) continue;
logger.info(`🕐🔥 Replacing tx with txEffect: ${txEffect.txHash}`);
if (tx[0]?.birthTimestamp) {
await dbTx
.update(l2Tx)
.set({
birthTimestamp: tx[0].birthTimestamp,
})
.where(eq(l2Tx.hash, txEffect.txHash));
}
}
});
};
13 changes: 13 additions & 0 deletions services/explorer-api/src/database/controllers/l2Tx/store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { type ChicmozL2PendingTx } from "@chicmoz-pkg/types";
import { getDb as db } from "../../../database/index.js";
import { l2Tx } from "../../schema/l2tx/index.js";

export const storeL2Tx = async (tx: ChicmozL2PendingTx): Promise<void> => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { birthTimestamp, ...rest } = tx;
await db()
.insert(l2Tx)
.values({
...rest,
});
};
Loading