Skip to content

Commit 463d0b8

Browse files
committed
update readme, fix flag direction
1 parent 9aa6f51 commit 463d0b8

File tree

3 files changed

+97
-74
lines changed

3 files changed

+97
-74
lines changed

README.md

+95-73
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,31 @@ BLOCK_FROM=18421105 sqd process:oeth # Start processing at block 18421105
2828
BLOCK_TO=18421105 sqd process:oeth # Process up to block 18421105
2929
```
3030

31-
## Frequent Commands
31+
## Useful Commands
3232

3333
```shell
34-
yarn codegen # Generate Schema code
35-
sqd typegen # Generate ABI code
36-
sqd down # Bring down squid container
37-
sqd up # Bring up squid container
38-
sqd process:oeth # Run OETH processor
39-
sqd process:ousd # Run OUSD processor
40-
sqd process:mainnet # Run misc processor
41-
sqd migration:generate # Generate migration (sqd down && sqd up first)
34+
# Code Generation
35+
yarn generate # Generate new migration
36+
yarn typegen # Generate ABI code
37+
38+
yarn setup # Reset database - run prior to starting processing for a fresh start
39+
40+
# Processing Commands
41+
yarn process:arbitrum # Run Arbitrum processor
42+
yarn process:base # Run Base processor
43+
yarn process:sonic # Run Sonic processor
44+
yarn process:oeth # Run OETH processor
45+
yarn process:ousd # Run OUSD processor
46+
yarn process:ogv # Run OGV processor
47+
yarn process:mainnet # Run misc mainnet processor
48+
yarn process:test # Run test processor
49+
yarn process # Run combined processor
50+
51+
# Local GraphQL Server
52+
yarn serve # You'll have to rebuild and rerun to see updates here.
53+
54+
# Deployment Tools
55+
yarn postdeploy v81 # Run post-deployment tasks (processing times log and validations)
4256
```
4357

4458
## Quickstart
@@ -47,99 +61,107 @@ sqd migration:generate # Generate migration (sqd down && sqd up first)
4761
# 0. Install @subsquid/cli a.k.a. the sqd command globally
4862
npm i -g @subsquid/cli
4963

50-
# 1. Retrieve the template
51-
sqd init my_squid_name -t evm
52-
cd my_squid_name
53-
54-
# 2. Install dependencies
64+
# 1. Install dependencies
5565
npm ci
5666

57-
# 3. Start a Postgres database container and detach
58-
sqd up
67+
# 2. Start a Postgres database container and setup
68+
yarn setup
5969

60-
# 4. Build and start the processor
61-
sqd process:oeth
70+
# 3. Build and start the processor (choose one)
71+
yarn process:oeth
72+
yarn process:ousd
73+
yarn process:mainnet
74+
# ... or other available processors
6275

63-
# 5. The command above will block the terminal
64-
# being busy with fetching the chain data,
65-
# transforming and storing it in the target database.
66-
#
67-
# To start the graphql server open the separate terminal
68-
# and run
69-
sqd serve
76+
# 4. In a separate terminal, start the GraphQL server
77+
yarn serve
7078
```
7179

7280
A GraphiQL playground will be available at [localhost:4350/graphql](http://localhost:4350/graphql).
7381

74-
## Dev flow
75-
76-
### 1. Define database schema
82+
## Dev Flow
7783

78-
Start development by defining the schema of the target database via `schema.graphql`.
79-
Schema definition consists of regular graphql type declarations annotated with custom directives.
80-
Full description of `schema.graphql` dialect is available [here](https://docs.subsquid.io/basics/schema-file).
84+
### 1. Make Schema Changes
8185

82-
### 2. Generate TypeORM classes
86+
- Add or modify GraphQL schema files in `src/**/*.graphql`
87+
- Run `yarn generate` to:
88+
- Combine GraphQL files into schema.graphql
89+
- Generate TypeORM entities
90+
- Create new database migration
91+
- Add new files to git
8392

84-
Mapping developers use TypeORM [EntityManager](https://typeorm.io/#/working-with-entity-manager)
85-
to interact with target database during data processing. All necessary entity classes are
86-
generated by the squid framework from `schema.graphql`. This is done by running `yarn codegen`
87-
command.
93+
### 2. Add New Events/Contracts
8894

89-
NOTE: We don't directly use the `sqd codegen` command because we generate our schema.graphql file first in
90-
the `yarn codegen` script.
95+
- Add ABI JSON files to `./abi/`
96+
- Run `yarn typegen` to generate TypeScript interfaces
97+
- Create new processor in `src/processors/` or add to existing one
98+
- Update `squid.yaml` if adding new processor
9199

92-
### 3. Generate database migrations
93-
94-
All database changes are applied through migration files located at `db/migrations`.
95-
`squid-typeorm-migration(1)` tool provides several commands to drive the process.
100+
### 3. Local Development
96101

97102
```bash
98-
## drop create the database
99-
sqd down
100-
sqd up
103+
# Start fresh
104+
yarn setup
105+
106+
# Run processor (choose one)
107+
yarn process:oeth
108+
yarn process:ousd
109+
# ... etc
101110

102-
## replace any old schemas with a new one made from the entities
103-
sqd migration:generate
111+
# In another terminal
112+
yarn serve
104113
```
105114

106-
See [docs on database migrations](https://docs.subsquid.io/basics/db-migrations) for more details.
115+
### 4. Testing Changes
107116

108-
### 4. Import ABI contract and generate interfaces to decode events
117+
- Use GraphiQL playground at [localhost:4350/graphql](http://localhost:4350/graphql)
118+
- Check processing times with `yarn log:processing-times`
119+
- Validate data integrity with generated validation queries
109120

110-
It is necessary to import the respective ABI definition to decode EVM logs. One way to generate a type-safe facade class
111-
to decode EVM logs is by placing the relevant JSON ABIs to `./abi`, then using `squid-evm-typegen(1)` via an `sqd`
112-
script:
121+
### 5. Deployment
122+
123+
#### Development (v999)
113124

114125
```bash
115-
sqd typegen
126+
# Reset dev environment (v999)
127+
# Only use when you need to reset schema or reload data
128+
sqd deploy . --update --hard-reset
116129
```
117130

118-
See more details on the [`squid-evm-typegen` doc page](https://docs.subsquid.io/evm-indexing/squid-evm-typegen).
131+
#### Production Deployment
119132

120-
## Project conventions
133+
1. Create and push a new version branch
121134

122-
Squid tools assume a certain [project layout](https://docs.subsquid.io/basics/squid-structure):
135+
```bash
136+
git checkout -b v80 # Replace 80 with your version number
137+
# Make any final changes if needed
138+
git push origin v80
139+
```
140+
141+
2. Wait for the deployment to complete and validate the data
142+
143+
3. Tag for production
144+
145+
```bash
146+
# Once validated, tag the latest commit for production
147+
git tag prod-v80 # Replace 80 with your version number
148+
git push origin prod-v80
149+
```
123150

124-
- All compiled js files must reside in `lib` and all TypeScript sources in `src`.
125-
The layout of `lib` must reflect `src`.
126-
- All TypeORM classes must be exported by `src/model/index.ts` (`lib/model` module).
127-
- Database schema must be defined in `schema.graphql`.
128-
- Database migrations must reside in `db/migrations` and must be plain js files.
129-
- `sqd(1)` and `squid-*(1)` executables consult `.env` file for environment variables.
151+
4. Monitor deployment
130152

131-
## Deploy a new version
153+
- Check processing at https://app.subsquid.io/squids
154+
- Follow release checklist at the top of this README
155+
- Keep the version branch for reference, DO NOT DELETE
132156

133-
- Visit [Squid deploy dashboard](https://app.subsquid.io/squids/deploy)
134-
- Auth with `sqd auth -k sqd_XXX` (key is on squid deploy page)
135-
- Update `squid.yaml` to set the correct version
136-
- Run `sqd deploy .`
137-
- Make branch for new version (eg v9) and push to origin
138-
- Switch back to main branch
157+
Note: Local deployment via `sqd deploy .` is possible but not recommended for production releases.
139158

140-
## Reset cloud dev version (v999)
159+
## Project conventions
141160

142-
Useful if you made a schema change or need to reload data.
161+
Squid tools assume a certain [project layout](https://docs.subsquid.io/basics/squid-structure):
143162

144-
- Check `squid.yaml` to make sure you're on v999
145-
- `sqd deploy . --update --hard-reset`
163+
- All compiled js files must reside in `lib` and all TypeScript sources in `src`
164+
- The layout of `lib` must reflect `src`
165+
- All TypeORM classes must be exported by `src/model/index.ts`
166+
- Database schema is generated from GraphQL files in `src`
167+
- Database migrations must reside in `db/migrations` and must be plain js files

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"prettier-fix": "prettier --write src",
1111
"setup": "sqd down && sqd up && sleep 2 && sqd migration:apply",
1212
"serve": "sqd serve",
13+
"typegen": "sqd typegen",
1314
"process:arbitrum": "sqd process:arbitrum",
1415
"process:base": "sqd process:base",
1516
"process:sonic": "sqd process:sonic",

src/templates/otoken/otoken.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,7 @@ export const createOTokenProcessor = (params: {
12231223
])
12241224
time('save to database')
12251225

1226-
if (global.process.env.DEBUG_PERF !== 'true') {
1226+
if (global.process.env.DEBUG_PERF === 'true') {
12271227
// Log entity counts
12281228
ctx.log.info(`Saved ${ownersToUpdate.length} OTokenAddress entities`)
12291229
ctx.log.info(`Saved entities:

0 commit comments

Comments
 (0)