Skip to content

Commit

Permalink
Merge pull request #2 from push-protocol/basic-rpc
Browse files Browse the repository at this point in the history
Basic rpc features
  • Loading branch information
Igx22 authored Sep 17, 2024
2 parents 75e8f7d + 059e07f commit 50b45ad
Show file tree
Hide file tree
Showing 52 changed files with 14,752 additions and 317 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,4 @@ src/devtools/devtools.secrets.json
yarn.lock
yarn.lock
package-lock.json
/docker/mysql-init
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
FROM node:20.6.1
WORKDIR /app
COPY . .
RUN yarn install --non-interactive --frozen-lockfile
RUN yarn install
# size reduction: "--production" removes dev deps; "cache clean" reduces cache
#RUN yarn install --production && yarn cache clean
EXPOSE 4001
EXPOSE 4002
EXPOSE 4003
Expand Down
149 changes: 109 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,30 @@ Please ensure your code adheres to our coding standards and includes appropriate
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
## Protobuf modifications
For every edit to /proto/push/block.proto.ts
Please do the following
- check that protobuf is installed
```shell
protoc --version
### libprotoc 3.20.3
## if missing (for mac)
brew install protobuf@3
```
- regenerate files
```shell
yarn build:proto
```
- commit new files
## generate protobuf
yarn add ts-protoc-gen
yarn build:proto
## Docker (local testing)
Expand Down Expand Up @@ -292,49 +316,72 @@ Setup docker images for smart-contracts & vnodes
```bash
## create docker network
docker network create push-shared-network
## prepare image for hardhat
cd /Users/w/chain/push-node-smart-contracts
docker build . -t hardhat-main
## prepare image for V
## prepare image for V (if needed)
cd /Users/w/chain/push-vnode
docker build . -t vnode-main
## prepare image for S (if needed)
cd /Users/w/chain/push-snode
docker build . -t snode-main
## prepare image for A (if needed)
cd /Users/w/chain/push-anode
docker build -t anode-main -f Dockerfile.light .
```
Run (2 shell tabs recommended)
Run
```bash
## run mysql + redis + phpmyadmin (shell1)
## add up -d for background
export DB_PASS=s1mpl3
export DB_NAME=vnode1
export DB_USER=2roor
cd /Users/w/chain/push-vnode
docker-compose up
## run hardhat + vnode1 + vnode2 + vnode3 (shell2)
## add up -d for background
export DB_PASS=s1mpl3
export DB_USER=2roor
cd /Users/w/push-vnode
docker-compose -f net.yml up
cd /Users/w/chain/push-vnode/docker
## run mysql + postgres + redis + phpmyadmin + hardhat
export POSTGRES_USER=postgres101
export POSTGRES_PASSWORD=lmnkdwhplk2
export DB_USER=sql101
export DB_PASS=lmnkdwhplk2
docker-compose -f db.yml up -d
## hints:
## read logs: db.yml logs -f
## re-create container (non-existing) db.yml up -d
## start (existing) db.yml start
## stop (existing) db.yml stop
## delete container: db.yml down
## delete everything: ./cleanup.sh
## run vnode1 + vnode2 + vnode3
export DB_USER=sql101
export DB_PASS=lmnkdwhplk2
docker-compose -f v.yml up -d
## run snode1 + snode2
export POSTGRES_USER=postgres101
export POSTGRES_PASSWORD=lmnkdwhplk2
docker-compose -f s.yml up -d
## run anode1
docker-compose -f a.yml up -d
```
Check that all docker DNS is online (OPTIONAL)
```bash
docker exec redis-main bash -c " getent hosts redis.local "
docker exec redis-main bash -c " getent hosts mysql.local "
docker exec redis-main bash -c " getent hosts phpmyadmin.local "
docker exec redis-main bash -c " getent hosts hardhat.local "
docker exec redis-main bash -c " getent hosts vnode1.local "
docker exec redis-main bash -c " getent hosts vnode2.local "
docker exec redis-main bash -c " getent hosts vnode3.local "
docker exec redis bash -c " getent hosts redis.local "
docker exec redis bash -c " getent hosts mysql.local "
docker exec redis bash -c " getent hosts phpmyadmin.local "
docker exec redis bash -c " getent hosts hardhat.local "
docker exec redis bash -c " getent hosts vnode1.local "
docker exec redis bash -c " getent hosts vnode2.local "
docker exec redis bash -c " getent hosts vnode3.local "
```
Test
Test vnodes: vnode1, vnode2, vnode3 are online and visible from the host machine
```shell
## vnode1, vnode2, vnode3 are online and visible from the host machine
##
curl --location 'http://localhost:4001/api/v1/rpc/' \
--header 'Content-Type: application/json' \
--data '{
Expand Down Expand Up @@ -363,46 +410,68 @@ curl --location 'http://localhost:4003/api/v1/rpc/' \
}'
echo ------------
```
Smoke-test validator api
Test vnodes: Smoke-test validator api
```shell
### get api token
### 1 send a test transaction (DUMMY DATA) (INCLUDES API TOKEN)
curl --location 'http://localhost:4001/api/v1/rpc/' \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"method": "push_getApiToken",
"params": [],
"method": "push_sendTransaction",
"params": ["1208494e49545f4449441a336569703135353a313a30783335423834643638343844313634313531373763363444363435303436363362393938413661623422336569703135353a313a30783335423834643638343844313634313531373763363444363435303436363362393938413661623422346569703135353a39373a3078443836333443333942424664343033336330643332383943343531353237353130323432333638312a670a0f6469643a6578616d706c653a313233120e6d61737465725f7075625f6b6579220f646572697665645f7075625f6b657932330a177075736831303232326e333233326d7764656963656a331218737472696e6769666965645f656e637279707465645f706b321071d60eecc00f4cc8ac898784a7eeb98f3ab40b7b226e6f646573223a5b7b226e6f64654964223a22307838653132644531324333356541426633356235366230344535334334453436386534363732374538222c2274734d696c6c6973223a313732363134383637303032342c2272616e646f6d486578223a2262323637636131656661626366386264323063623763616336356330633534323865656664663338222c2270696e67526573756c7473223a5b7b226e6f64654964223a22307866444145616637616643466262346534643136444336366244323033396664363030344346636538222c2274734d696c6c6973223a313732363134383637303032302c22737461747573223a317d2c7b226e6f64654964223a22307839384639443931304165663942334239413435313337616631434137363735654439306135333535222c2274734d696c6c6973223a313732363134383637303031362c22737461747573223a317d5d2c227369676e6174757265223a22307834366331643237316663383637343435393138356132616265636637373736323961303133373066343366303766343965623431363235616565656631643033356431396664326164326437323232373162343166336536636231653735303338343730366162383336363437363837653539346362636462636632316165663162227d2c7b226e6f64654964223a22307839384639443931304165663942334239413435313337616631434137363735654439306135333535222c2274734d696c6c6973223a313732363134383637303032392c2272616e646f6d486578223a2263316662333961383232623964383261643264373437333230626165383634303634386632356137222c2270696e67526573756c7473223a5b7b226e6f64654964223a22307838653132644531324333356541426633356235366230344535334334453436386534363732374538222c2274734d696c6c6973223a313732363134383637303031372c22737461747573223a317d2c7b226e6f64654964223a22307866444145616637616643466262346534643136444336366244323033396664363030344346636538222c2274734d696c6c6973223a313732363134383637303032342c22737461747573223a317d5d2c227369676e6174757265223a22307866663737366563393736306235646134373238323130333862646631646363656162333130666531323030376262336634336636346236343535303264663466333733323234333066653333366535313661356336613734363038353465343033306235363334343633646338613064613135386131623063373861323630653162227d2c7b226e6f64654964223a22307866444145616637616643466262346534643136444336366244323033396664363030344346636538222c2274734d696c6c6973223a313732363134383637303033352c2272616e646f6d486578223a2262393331656334316233393763623164656234396536353764396437623739383764316361373530222c2270696e67526573756c7473223a5b7b226e6f64654964223a22307838653132644531324333356541426633356235366230344535334334453436386534363732374538222c2274734d696c6c6973223a313732363134383637303031352c22737461747573223a317d2c7b226e6f64654964223a22307839384639443931304165663942334239413435313337616631434137363735654439306135333535222c2274734d696c6c6973223a313732363134383637303032352c22737461747573223a317d5d2c227369676e6174757265223a22307837633964343832396336616161363535396465643833323433623665386438623665623333366439303932613261306466323533316463336364396532623335353735626462386261313134323263326663346262363737653064396365356266343464353466653538373266396530373661633339643530316237343934333163227d5d7d42412592af30c62ac73025e37826d60a250e7c4f44c3697d2868307255bcff52a4b61e9a3fa015761ebd89b3d9d1ce3e4a7ad4691c5259e56f8be2e79a486a1eb01b1b4a0130"],
"id": 1
}'
echo ------------
### send a test transaction (DUMMY DATA)
### 2 read transaction queue size
curl --location 'http://localhost:4001/api/v1/rpc/' \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"method": "push_sendTransaction",
"params": ["1208494e49545f4449441a0d6569703135353a313a30784141220d6569703135353a313a30784242220d6569703135353a313a307843432a1a0a043078414112043078424218012204307843432a04307844443210d8555d2a5c474fa0a5f588563d50b2873ab40b7b226e6f646573223a5b7b226e6f64654964223a22307838653132644531324333356541426633356235366230344535334334453436386534363732374538222c2274734d696c6c6973223a313732343637333234303033302c2272616e646f6d486578223a2266376266376266303366656130613732353135363965303564653635363832646235353935353765222c2270696e67526573756c7473223a5b7b226e6f64654964223a22307866444145616637616643466262346534643136444336366244323033396664363030344346636538222c2274734d696c6c6973223a313732343637333234303032302c22737461747573223a317d2c7b226e6f64654964223a22307839384639443931304165663942334239413435313337616631434137363735654439306135333535222c2274734d696c6c6973223a313732343637333234303031392c22737461747573223a317d5d2c227369676e6174757265223a22307862333333636331623731633434633430386439366237626662363338353439336366313637636232626432353532376437383664333866376239383065616433303132663736636137386533616231613337653661316363666432306236393364656664303039633837313163666338396630353262333933363866316365383162227d2c7b226e6f64654964223a22307866444145616637616643466262346534643136444336366244323033396664363030344346636538222c2274734d696c6c6973223a313732343637333234303032352c2272616e646f6d486578223a2239323136383734646630653134383539376639643434643064666661656465393538343464643137222c2270696e67526573756c7473223a5b7b226e6f64654964223a22307838653132644531324333356541426633356235366230344535334334453436386534363732374538222c2274734d696c6c6973223a313732343637333232343635302c22737461747573223a317d2c7b226e6f64654964223a22307839384639443931304165663942334239413435313337616631434137363735654439306135333535222c2274734d696c6c6973223a313732343637333232343635352c22737461747573223a317d5d2c227369676e6174757265223a22307837626663343432343464633431376132383463313038353064613335313663353035613036326662323262623538353438383661613239393739653032663139376565633263393664356439343864306131643635306563323334646130356330663933626535653230393136316563326363626331653963396537343238623162227d2c7b226e6f64654964223a22307839384639443931304165663942334239413435313337616631434137363735654439306135333535222c2274734d696c6c6973223a313732343637333234303032342c2272616e646f6d486578223a2230643961313661383939636164306566633838336633343564306638306237666131356136353666222c2270696e67526573756c7473223a5b7b226e6f64654964223a22307838653132644531324333356541426633356235366230344535334334453436386534363732374538222c2274734d696c6c6973223a313732343637333232363934332c22737461747573223a317d2c7b226e6f64654964223a22307866444145616637616643466262346534643136444336366244323033396664363030344346636538222c2274734d696c6c6973223a313732343637333232363934372c22737461747573223a317d5d2c227369676e6174757265223a22307862613632393639366565653830343864313639303730336166656361663866626333663834333139643439316164623363663364663333313131396530303239303531373732303237393137313335333332653430666233323639333963626137663634373636663262363933343065366534663066623336333639386663393162227d5d7d4201ee4a0131"],
"method": "push_readBlockQueueSize",
"params": [],
"id": 1
}'
echo ------------
### read transaction queue size
### 3 read transaction queue
curl --location 'http://localhost:4001/api/v1/rpc/' \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"method": "push_readBlockQueueSize",
"params": [],
"method": "push_readBlockQueue",
"params": ["0"],
"id": 1
}'
```
### read transaction queue
Test vnodes: Smoke test api token
```sh
### 1 get api token
curl --location 'http://localhost:4001/api/v1/rpc/' \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"method": "push_getApiToken",
"params": [],
"id": 1
}'
echo ------------
```
Test anodes: Get blocks
```shell
curl --location 'http://localhost:5001/rpc' \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"method": "push_readBlockQueue",
"params": ["0"],
"method": "RpcService.getBlocks",
"params": {
"startTime": 1724771470,
"direction": "DESC",
"showDetails": true,
"pageSize": 10,
"page": 1
},
"id": 1
}'
```
72 changes: 0 additions & 72 deletions docker-compose-v02.yml

This file was deleted.

72 changes: 0 additions & 72 deletions docker-compose-v03.yml

This file was deleted.

Loading

0 comments on commit 50b45ad

Please sign in to comment.