Skip to content

Commit

Permalink
Merge branch '421-bitcoin-rpc-scanner' into 'dev'
Browse files Browse the repository at this point in the history
Resolve "Use bitcoin rpc scanner in rosen service"

Closes #421

See merge request ergo/rosen-bridge/ui!348
  • Loading branch information
zargarzadehm committed Nov 15, 2024
2 parents 9f3182d + 66d28b1 commit 724ece0
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 78 deletions.
5 changes: 5 additions & 0 deletions .changeset/late-ants-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rosen-bridge/rosen-app': patch
---

Update scanner packages
5 changes: 5 additions & 0 deletions .changeset/pretty-mice-sparkle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rosen-bridge/rosen-service': minor
---

Update bitcoin scanner to use rpc endpoint instead of esplora.
4 changes: 4 additions & 0 deletions apps/rosen-service/config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ bitcoin:
rwt:
initialHeight:
esploraUrl: https://blockstream.info
rpc:
url:
username:
password:
ethereum:
addresses:
lock:
Expand Down
15 changes: 8 additions & 7 deletions apps/rosen-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
"get-config": "npx @rosen-bridge/cli download-assets --chain-type mainnet --out config --include-prereleases"
},
"dependencies": {
"@rosen-bridge/bitcoin-esplora-scanner": "^0.1.14",
"@rosen-bridge/bitcoin-observation-extractor": "^4.0.7",
"@rosen-bridge/evm-observation-extractor": "^3.0.5",
"@rosen-bridge/evm-rpc-scanner": "^1.0.4",
"@rosen-bridge/abstract-extractor": "^0.3.1",
"@rosen-bridge/bitcoin-observation-extractor": "^4.0.8",
"@rosen-bridge/bitcoin-rpc-scanner": "^1.0.0",
"@rosen-bridge/evm-observation-extractor": "^3.1.0",
"@rosen-bridge/evm-rpc-scanner": "^2.0.0",
"@rosen-bridge/extended-typeorm": "^0.0.3",
"@rosen-bridge/observation-extractor": "^5.0.7",
"@rosen-bridge/scanner": "^4.1.3",
"@rosen-bridge/watcher-data-extractor": "^8.0.2",
"@rosen-bridge/observation-extractor": "^5.0.8",
"@rosen-bridge/scanner": "^5.0.0",
"@rosen-bridge/watcher-data-extractor": "^9.0.0",
"@rosen-bridge/winston-logger": "^0.2.1",
"@rosen-ui/asset-calculator": "^2.0.0",
"config": "^3.3.7"
Expand Down
3 changes: 3 additions & 0 deletions apps/rosen-service/src/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ const getConfig = () => {
rwt: nodeConfig.get<string>('bitcoin.tokens.rwt'),
},
esploraUrl: nodeConfig.get<string>('bitcoin.esploraUrl'),
rpcUrl: nodeConfig.get<string>('bitcoin.rpc.url'),
rpcUsername: getOptionalString('bitcoin.rpc.username'),
rpcPassword: getOptionalString('bitcoin.rpc.password'),
},
ethereum: {
addresses: {
Expand Down
9 changes: 9 additions & 0 deletions apps/rosen-service/src/event-trigger/event-trigger-service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ErgoScanner } from '@rosen-bridge/scanner';
import { EventTriggerExtractor } from '@rosen-bridge/watcher-data-extractor';
import WinstonLogger from '@rosen-bridge/winston-logger';
import { ErgoNetworkType } from '@rosen-bridge/abstract-extractor';

import configs from '../configs';

Expand Down Expand Up @@ -28,6 +29,8 @@ export const registerExtractors = (scanner: ErgoScanner) => {
const ergoEventTriggerExtractor = new EventTriggerExtractor(
'ergo-extractor',
dataSource,
ErgoNetworkType.Explorer,
configs.ergo.explorerUrl,
configs.ergo.addresses.eventTrigger,
configs.ergo.tokens.rwt,
configs.ergo.addresses.permit,
Expand All @@ -37,6 +40,8 @@ export const registerExtractors = (scanner: ErgoScanner) => {
const cardanoEventTriggerExtractor = new EventTriggerExtractor(
'cardano-extractor',
dataSource,
ErgoNetworkType.Explorer,
configs.ergo.explorerUrl,
configs.cardano.addresses.eventTrigger,
configs.cardano.tokens.rwt,
configs.cardano.addresses.permit,
Expand All @@ -46,6 +51,8 @@ export const registerExtractors = (scanner: ErgoScanner) => {
const bitcoinEventTriggerExtractor = new EventTriggerExtractor(
'bitcoin-extractor',
dataSource,
ErgoNetworkType.Explorer,
configs.ergo.explorerUrl,
configs.bitcoin.addresses.eventTrigger,
configs.bitcoin.tokens.rwt,
configs.bitcoin.addresses.permit,
Expand All @@ -55,6 +62,8 @@ export const registerExtractors = (scanner: ErgoScanner) => {
const ethereumEventTriggerExtractor = new EventTriggerExtractor(
'ethereum-extractor',
dataSource,
ErgoNetworkType.Explorer,
configs.ergo.explorerUrl,
configs.ethereum.addresses.eventTrigger,
configs.ethereum.tokens.rwt,
configs.ethereum.addresses.permit,
Expand Down
8 changes: 4 additions & 4 deletions apps/rosen-service/src/observation/chains/bitcoin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BitcoinEsploraObservationExtractor } from '@rosen-bridge/bitcoin-observation-extractor';
import { BitcoinRpcObservationExtractor } from '@rosen-bridge/bitcoin-observation-extractor';
import WinstonLogger from '@rosen-bridge/winston-logger';

import { getRosenTokens } from '../../utils';
Expand All @@ -8,17 +8,17 @@ import config from '../../configs';
import dataSource from '../../data-source';

import AppError from '../../errors/AppError';
import { BitcoinEsploraScanner } from '@rosen-bridge/bitcoin-esplora-scanner';
import { BitcoinRpcScanner } from '@rosen-bridge/bitcoin-rpc-scanner';

const logger = WinstonLogger.getInstance().getLogger(import.meta.url);

/**
* register an observation extractor for the provided scanner
* @param scanner
*/
export const registerBitcoinExtractor = (scanner: BitcoinEsploraScanner) => {
export const registerBitcoinExtractor = (scanner: BitcoinRpcScanner) => {
try {
const observationExtractor = new BitcoinEsploraObservationExtractor(
const observationExtractor = new BitcoinRpcObservationExtractor(
config.bitcoin.addresses.lock,
dataSource,
getRosenTokens(),
Expand Down
8 changes: 5 additions & 3 deletions apps/rosen-service/src/scanner/chains/bitcoin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BitcoinEsploraScanner } from '@rosen-bridge/bitcoin-esplora-scanner';
import { BitcoinRpcScanner } from '@rosen-bridge/bitcoin-rpc-scanner';
import WinstonLogger from '@rosen-bridge/winston-logger';

import dataSource from '../../data-source';
Expand Down Expand Up @@ -28,12 +28,14 @@ const scannerLogger = WinstonLogger.getInstance().getLogger(
*/
export const startBitcoinScanner = async () => {
try {
const scanner = new BitcoinEsploraScanner(
const scanner = new BitcoinRpcScanner(
{
esploraUrl: config.bitcoin.esploraUrl,
rpcUrl: config.bitcoin.rpcUrl,
dataSource,
initialHeight: config.bitcoin.initialHeight,
timeout: SCANNER_API_TIMEOUT,
username: config.bitcoin.rpcUsername,
password: config.bitcoin.rpcPassword,
},
scannerLogger
);
Expand Down
6 changes: 3 additions & 3 deletions apps/rosen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
"@rosen-bridge/ergo-box-selection": "^0.1.0",
"@rosen-bridge/extended-typeorm": "^0.0.3",
"@rosen-bridge/minimum-fee": "^2.0.1",
"@rosen-bridge/observation-extractor": "^5.0.7",
"@rosen-bridge/scanner": "^4.1.3",
"@rosen-bridge/observation-extractor": "^5.0.8",
"@rosen-bridge/scanner": "^5.0.0",
"@rosen-bridge/tokens": "^1.2.1",
"@rosen-bridge/watcher-data-extractor": "^8.0.2",
"@rosen-bridge/watcher-data-extractor": "^9.0.0",
"@rosen-clients/cardano-koios": "^2.0.1",
"@rosen-clients/ergo-explorer": "^1.0.2",
"@rosen-network/bitcoin": "^1.0.0",
Expand Down
Loading

0 comments on commit 724ece0

Please sign in to comment.