Skip to content

Commit

Permalink
Merge branch '404-event-synchronization' into 'dev'
Browse files Browse the repository at this point in the history
implement EventSynchronization

Closes #404

See merge request ergo/rosen-bridge/guard-service!412
  • Loading branch information
vorujack committed Nov 12, 2024
2 parents d569614 + 7383baa commit 3741134
Show file tree
Hide file tree
Showing 15 changed files with 2,844 additions and 142 deletions.
5 changes: 5 additions & 0 deletions .changeset/fuzzy-cows-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'guard-service': minor
---

Add Event Synchronization feature: Communicate with other guards to get the payment transaction of an event and move it to reward distribution
5 changes: 5 additions & 0 deletions config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ reward:
networkFeeRepoAddress: '' # guards address for receiving network fee of events
watchersSharePercent: 50 # watchers share for event fees (payed in tokens or native token)
watchersEmissionSharePercent: 0 # watchers share for event fees (payed in emission token)
eventSync:
parallelSyncLimit: 3
parallelRequestCount: 3
timeout: 3600
interval: 60
tss:
path: './bin/tss.exe' # path to tss executable file
configPath: './bin/conf/conf.env'
Expand Down
144 changes: 72 additions & 72 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,19 @@
"@rosen-bridge/tx-progress-check": "^1.0.2",
"@rosen-bridge/watcher-data-extractor": "^8.0.2",
"@rosen-bridge/winston-logger": "1.0.2",
"@rosen-chains/abstract-chain": "10.0.0",
"@rosen-chains/binance": "0.1.2",
"@rosen-chains/bitcoin": "6.0.0",
"@rosen-chains/bitcoin-esplora": "4.0.4",
"@rosen-chains/cardano": "10.0.0",
"@rosen-chains/cardano-blockfrost-network": "7.0.3",
"@rosen-chains/cardano-koios-network": "10.0.3",
"@rosen-chains/ergo": "10.0.0",
"@rosen-chains/ergo-explorer-network": "9.0.3",
"@rosen-chains/ergo-node-network": "9.0.3",
"@rosen-chains/ethereum": "0.1.10",
"@rosen-chains/evm": "5.0.0",
"@rosen-chains/evm-rpc": "2.1.7",
"@rosen-chains/abstract-chain": "11.0.0",
"@rosen-chains/binance": "0.2.0",
"@rosen-chains/bitcoin": "6.1.0",
"@rosen-chains/bitcoin-esplora": "4.0.5",
"@rosen-chains/cardano": "10.1.0",
"@rosen-chains/cardano-blockfrost-network": "7.0.4",
"@rosen-chains/cardano-koios-network": "10.0.4",
"@rosen-chains/ergo": "10.1.0",
"@rosen-chains/ergo-explorer-network": "9.0.4",
"@rosen-chains/ergo-node-network": "9.0.4",
"@rosen-chains/ethereum": "0.2.0",
"@rosen-chains/evm": "5.1.0",
"@rosen-chains/evm-rpc": "2.1.8",
"@sinclair/typebox": "^0.30.4",
"await-semaphore": "^0.1.3",
"axios": "^1.6.8",
Expand Down
13 changes: 13 additions & 0 deletions src/configs/Configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ class Configs {
>('tss.pubs'),
};

// event synchronization
static parallelSyncLimit = getConfigIntKeyOrDefault(
'eventSync.parallelSyncLimit',
3
);
static parallelRequestCount = getConfigIntKeyOrDefault(
'eventSync.parallelRequestCount',
3
);
static eventSyncTimeout = getConfigIntKeyOrDefault('eventSync.timeout', 3600);
static eventSyncInterval = getConfigIntKeyOrDefault('eventSync.interval', 60);

// guards configs
static guardMnemonic = config.get<string>('guard.mnemonic');
static guardSecret = Utils.convertMnemonicToSecretKey(this.guardMnemonic);
Expand Down Expand Up @@ -192,6 +204,7 @@ class Configs {
static multiSigCleanUpInterval = 120; // seconds
static tssInstanceRestartGap = 5; // seconds
static tssUpdateInterval = 10; // seconds
static detectionUpdateInterval = 10; // seconds
static timeoutProcessorInterval = getConfigIntKeyOrDefault(
'intervals.timeoutProcessorInterval',
3600
Expand Down
25 changes: 25 additions & 0 deletions src/db/DatabaseAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,31 @@ class DatabaseAction {
});
};

/**
* inserts a tx record into transactions table
*/
insertCompletedTx = async (
paymentTx: PaymentTransaction,
event: ConfirmedEventEntity | null,
requiredSign: number,
order: ArbitraryEntity | null
): Promise<void> => {
await this.TransactionRepository.insert({
txId: paymentTx.txId,
txJson: paymentTx.toJson(),
type: paymentTx.txType,
chain: paymentTx.network,
status: TransactionStatus.completed,
lastStatusUpdate: String(Math.round(Date.now() / 1000)),
lastCheck: 0,
event: event !== null ? event : undefined,
order: order !== null ? order : undefined,
failedInSign: false,
signFailedCount: 0,
requiredSign: requiredSign,
});
};

/**
* @param eventId the event trigger id
* @param eventBoxHeight the event trigger box mined height
Expand Down
Loading

0 comments on commit 3741134

Please sign in to comment.