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

feat: rgb++ ckb transaction queue #4

Merged
merged 77 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
e845ac1
Merge pull request #6 from ckb-cell/develop
ahonn Mar 20, 2024
4d6f600
Merge pull request #7 from ckb-cell/develop
Flouse Mar 21, 2024
5e26394
Merge pull request #9 from ckb-cell/develop
Flouse Mar 22, 2024
081ef46
feat: add rgb++ ckb transaction queue processing and queuing
ahonn Mar 6, 2024
061809a
feat: implement fastify cron job plugins
ahonn Mar 6, 2024
bfe6dfb
feat: update vercel maxDuration config
ahonn Mar 6, 2024
86e62e0
feat: add paymaster service
ahonn Mar 6, 2024
630120e
fix: update rgbpp routes schemas
ahonn Mar 7, 2024
066024b
feat: refactor transaction handling with new manager
ahonn Mar 7, 2024
25b0fde
fix: fix type issues
ahonn Mar 7, 2024
0092e70
feat: add ckb rpc service and impl partial transaction process
ahonn Mar 7, 2024
a7b4269
refactor: refactor rgb++ transaction query
ahonn Mar 7, 2024
8543717
ci: update test workflow
ahonn Mar 12, 2024
dca2197
feat: add verifyTransaction to check ckb virtual result
ahonn Mar 12, 2024
d448cd0
chroe: add annotations about job returnvalue
ahonn Mar 12, 2024
10c8f97
feat: update environment variables and paymaster service in codebase
ahonn Mar 12, 2024
1cf63fd
feat: add appendCellAndSignTx and refillCellQueue to Paymaster
ahonn Mar 13, 2024
bbc73ab
test: add paymaster unit tests
ahonn Mar 13, 2024
10f96ad
test: add paymaster refillCellQueue test cases
ahonn Mar 13, 2024
20cfd0a
feat: refactor paymaster class and add transaction processing logic
ahonn Mar 13, 2024
bc19179
chore: update pnpm-lock.yaml
ahonn Mar 13, 2024
dcb0a50
fix: fix type issues
ahonn Mar 13, 2024
e9b3343
feat: add unlock BTC_TIME_LOCK cells cron task
ahonn Mar 14, 2024
b198512
feat: add new features and improvements to RGBPP services and routes
ahonn Mar 14, 2024
647d025
fix: fix @rgbpp-sdk/ckb type issues
ahonn Mar 15, 2024
424d328
feat: update rgbpp routes
ahonn Mar 15, 2024
d5ac33b
feat: import calculateCommitment from @rgbpp-sdk/ckb utils path
ahonn Mar 15, 2024
5830dd4
feat: add /rgbpp/v1/address/:address/assets route
ahonn Mar 15, 2024
af0dfd3
fix: fix rgbpp cell type
ahonn Mar 15, 2024
b5413f1
feat: add type script query to rgbpp address assets route
ahonn Mar 15, 2024
7e7484d
feat: add unlock cells cron task to vercel cron, start jobs when app …
ahonn Mar 15, 2024
2cccd73
ci: update unit test workflow
ahonn Mar 15, 2024
8d42aa1
ci: update test workflow redis config
ahonn Mar 15, 2024
8588e6a
feat: add type script hex query param support
ahonn Mar 15, 2024
93146a3
feat: update rgbpp routes
ahonn Mar 15, 2024
0f6470b
feat: rename rgbpp get transaction response hash
ahonn Mar 18, 2024
f459397
test: add tests for rgb++ ckb transaction verfiy
ahonn Mar 18, 2024
a5f3327
chore: downgrade rgbpp-sdk version
ahonn Mar 18, 2024
1527dbc
feat: capture OpReturnNotFoundError and InvalidTransactionError
ahonn Mar 18, 2024
b5a3050
test: fix test case commitment
ahonn Mar 18, 2024
cc9d391
docs: add rgb++ routes description
ahonn Mar 21, 2024
b040beb
feat: upgrade rgbpp sdk
ahonn Mar 21, 2024
400e6aa
fix: upgrade unlocker buildBtcTimeCellsSpentTx
ahonn Mar 21, 2024
82d3e9d
feat: upgrade rgbpp sdk
ahonn Mar 21, 2024
7d3f8a7
build: add TRANSACTION_SPV_SERVICE_URL env var
ahonn Mar 22, 2024
9b20dbd
test: add unlock getNextBatchLockCell unit tests
ahonn Mar 22, 2024
ffed476
test: add unlocker unlockCells method test case
ahonn Mar 22, 2024
f4ed033
feat: add job retry options and complete the main process
ahonn Mar 25, 2024
e2a756c
feat: update cron task
ahonn Mar 25, 2024
ab499f7
feat: use electrs for get btc tx hex and blockindex, and using for sp…
ahonn Mar 25, 2024
ff93193
fix: fix unlocker type issue and update test cases
ahonn Mar 25, 2024
c22f493
fix: fix rgbpp routes
ahonn Mar 25, 2024
b67ed7b
feat: improve Paymaster implementation and add some annotations
ahonn Mar 25, 2024
025ec27
feat: complete paymaster cell signing & sending transaction
ahonn Mar 25, 2024
98d9211
feat: update cron task & paymaster
ahonn Mar 25, 2024
4167114
test: fix test case type issue
ahonn Mar 25, 2024
42d9a74
feat: add work onActive callback
ahonn Mar 25, 2024
e0cf0d0
feat: update cron task
ahonn Mar 25, 2024
6e3888b
feat: add bitcoin get block txids route and bitcoin spv route
ahonn Mar 25, 2024
a03dec6
feat: update cron task route schema
ahonn Mar 25, 2024
032daaa
ci: update test workflow env var
ahonn Mar 25, 2024
412740d
test: update test cases
ahonn Mar 26, 2024
f55f5f1
feat: mark paymaster cell as spent after tx confirmed
ahonn Mar 26, 2024
d0a2962
fix: fix markPaymasterCellAsSpent
ahonn Mar 26, 2024
678ffc7
feat: update transactions cron
ahonn Mar 26, 2024
7da77a7
feat: update rgbpp routes
ahonn Mar 26, 2024
d8023bb
feat: add more info logs and update app logger options
ahonn Mar 26, 2024
fe503a3
test: fix app test cases
ahonn Mar 26, 2024
63cdae2
feat: update rgbpp transaction route and unlocker
ahonn Mar 26, 2024
f80f56c
feat: completed unlock cron task
ahonn Mar 26, 2024
7de6328
feat: add unlocker collector private prop back
ahonn Mar 26, 2024
328709d
fix: fix /rgbpp/v1/transaction/{btc_tx_id}/job
ahonn Mar 26, 2024
cb20032
test: update unit tests
ahonn Mar 26, 2024
6d42adb
fix: fix rgbpp address assets route
ahonn Mar 26, 2024
def8ea6
fix: use ckb jsonrpc url for indexer service
ahonn Mar 26, 2024
78baf96
chore: delete useless hex utils
ahonn Mar 26, 2024
cd635ff
fix: paymaster cell queueSize pre-check & rgbpp transaction params re…
ahonn Mar 26, 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
13 changes: 13 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,16 @@ BITCOIN_JSON_RPC_USERNAME=
BITCOIN_JSON_RPC_PASSWORD=

BITCOIN_ELECTRS_API_URL=

BITCOIN_SPV_SERVICE_URL=

CKB_RPC_URL=https://testnet.ckb.dev/rpc
CKB_INDEXER_URL=https://testnet.ckb.dev/indexer

PAYMASTER_PRIVATE_KEY=
PAYMASTER_CELL_CAPACITY=31600000000
PAYMASTER_CELL_PRESET_COUNT=500

UNLOCKER_CELL_BATCH_SIZE=100

TRANSACTION_QUEUE_JOB_DELAY=12000
17 changes: 17 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ jobs:
test:
runs-on: ubuntu-latest

services:
redis:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379

steps:
- name: Checkout Code
uses: actions/checkout@v3
Expand All @@ -36,4 +47,10 @@ jobs:
BITCOIN_JSON_RPC_USERNAME: ${{ secrets.BITCOIN_JSON_RPC_USERNAME }}
BITCOIN_JSON_RPC_PASSWORD: ${{ secrets.BITCOIN_JSON_RPC_PASSWORD }}
BITCOIN_ELECTRS_API_URL: ${{ secrets.BITCOIN_ELECTRS_API_URL }}
BITCOIN_SPV_SERVICE_URL: ${{ secrets.BITCOIN_SPV_SERVICE_URL }}
CKB_RPC_URL: ${{ secrets.CKB_RPC_URL }}
CKB_INDEXER_URL: ${{ secrets.CKB_INDEXER_URL }}
PAYMASTER_PRIVATE_KEY: ${{ secrets.PAYMASTER_PRIVATE_KEY }}
REDIS_URL: redis://localhost:6379
CI_REDIS_URL: redis://localhost:6379
run: pnpm test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ yarn.lock
coverage
data
redis.conf
dump.rdb
.envrc
4 changes: 4 additions & 0 deletions api/serverless.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { buildFastify } from '../src/app';

export const config = {
maxDuration: 300,
};

const app = buildFastify();

export default async (req: Request, res: Response) => {
Expand Down
7 changes: 7 additions & 0 deletions devbox.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"packages": [
"nodejs@latest",
"nodePackages.pnpm@latest",
"redis@latest"
]
}
66 changes: 66 additions & 0 deletions devbox.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"lockfile_version": "1",
"packages": {
"nodePackages.pnpm@latest": {
"last_modified": "2024-03-08T13:51:52Z",
"resolved": "github:NixOS/nixpkgs/a343533bccc62400e8a9560423486a3b6c11a23b#nodePackages.pnpm",
"source": "devbox-search",
"version": "8.15.3",
"systems": {
"aarch64-darwin": {
"store_path": "/nix/store/m9p6q42njy1k33fdzf2axqyhy8vh4vn5-pnpm-8.15.3"
},
"aarch64-linux": {
"store_path": "/nix/store/war7jm6ka7afc2v8a78hlq8v9m4pg38m-pnpm-8.15.3"
},
"x86_64-darwin": {
"store_path": "/nix/store/3w3bs2cdqx7sivcldcf6drwrhilv511m-pnpm-8.15.3"
},
"x86_64-linux": {
"store_path": "/nix/store/hcq09j80njlfghy65qmwhn5nq20nk8kl-pnpm-8.15.3"
}
}
},
"nodejs@latest": {
"last_modified": "2024-03-09T07:11:56Z",
"resolved": "github:NixOS/nixpkgs/0e7f98a5f30166cbed344569426850b21e4091d4#nodejs_21",
"source": "devbox-search",
"version": "21.7.1",
"systems": {
"aarch64-darwin": {
"store_path": "/nix/store/mh1db6rni4mlcr473sh3fy6jg2m38jvg-nodejs-21.7.1"
},
"aarch64-linux": {
"store_path": "/nix/store/ziyb3ny5f9hcwp0lsb9gwdv1pqsn03x1-nodejs-21.7.1"
},
"x86_64-darwin": {
"store_path": "/nix/store/0zaa3aarbsj38g62ihv94gz2hgvgh6bc-nodejs-21.7.1"
},
"x86_64-linux": {
"store_path": "/nix/store/4arhczh30ychpx6h2wpj5nhx39wm0nla-nodejs-21.7.1"
}
}
},
"redis@latest": {
"last_modified": "2024-03-08T13:51:52Z",
"plugin_version": "0.0.2",
"resolved": "github:NixOS/nixpkgs/a343533bccc62400e8a9560423486a3b6c11a23b#redis",
"source": "devbox-search",
"version": "7.2.4",
"systems": {
"aarch64-darwin": {
"store_path": "/nix/store/700kyznxcmlkqqabhwa64vmyg4aj6igj-redis-7.2.4"
},
"aarch64-linux": {
"store_path": "/nix/store/xlc976dh4nb2aa0gzs0jfgld4cc3x8si-redis-7.2.4"
},
"x86_64-darwin": {
"store_path": "/nix/store/5v58fadclljqa2fmwq281bx5wma9cslb-redis-7.2.4"
},
"x86_64-linux": {
"store_path": "/nix/store/zp1lapdicjxnjhiz8l6j2j4nn6sa9fg5-redis-7.2.4"
}
}
}
}
}
17 changes: 15 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
]
},
"dependencies": {
"@ckb-lumos/base": "^0.21.1",
"@ckb-lumos/ckb-indexer": "^0.21.1",
"@ckb-lumos/codec": "^0.21.1",
"@ckb-lumos/lumos": "^0.21.1",
"@fastify/compress": "^7.0.0",
"@fastify/cors": "^9.0.1",
"@fastify/http-proxy": "^9.4.0",
Expand All @@ -32,36 +36,45 @@
"@fastify/sensible": "^5.5.0",
"@fastify/swagger": "^8.14.0",
"@fastify/swagger-ui": "^3.0.0",
"@nervosnetwork/ckb-sdk-utils": "^0.109.1",
"@rgbpp-sdk/btc": "0.0.0-snap-20240326062949",
"@rgbpp-sdk/ckb": "0.0.0-snap-20240326062949",
"@sentry/node": "^7.102.1",
"@sentry/profiling-node": "^7.102.1",
"awilix": "^10.0.1",
"axios": "^1.6.7",
"bullmq": "^5.4.2",
"dotenv": "^16.4.2",
"fastify": "^4.26.0",
"fastify-cron": "^1.3.1",
"fastify-plugin": "^4.5.1",
"fastify-type-provider-zod": "^1.1.9",
"ioredis": "^5.3.2",
"lodash": "^4.17.21",
"multicoin-address-validator": "^0.5.16",
"pino": "^8.19.0",
"std-env": "^3.7.0",
"uuid": "^9.0.1",
"zod": "^3.22.4"
},
"devDependencies": {
"@types/ioredis-mock": "^8.2.5",
"@types/lodash": "^4.17.0",
"@types/multicoin-address-validator": "^0.5.2",
"@types/node": "^20.11.17",
"@types/uuid": "^9.0.8",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"@vitest/coverage-istanbul": "^1.3.1",
"@vitest/ui": "^1.3.1",
"bitcoinjs-lib": "^6.1.5",
"cross-env": "^7.0.3",
"ecpair": "^2.1.0",
"eslint": "^8.56.0",
"ioredis-mock": "^8.9.0",
"lint-staged": "^15.2.2",
"pino-pretty": "^10.3.1",
"prettier": "^3.2.5",
"simple-git-hooks": "^2.10.0",
"tiny-secp256k1": "^2.2.3",
"tsx": "^4.7.1",
"typescript": "^5.3.3",
"vercel": "^33.5.1",
Expand Down
Loading
Loading