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

[DNM] test #3238 #3240

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
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
1 change: 1 addition & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"draftPR": true,
"cloneSubmodules": true,
"forkProcessing": "enabled",
"ignorePaths": ["packages/contracts-core/**"],
"packageRules": [
{
"matchUpdateTypes": [
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,10 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }} # Optional
filesizelimit: 15MB

- name: Add 'fe-release' label
if: github.event.pull_request.base.ref == 'fe-release'
uses: actions-ecosystem/action-add-labels@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
labels: 'fe-release'
8 changes: 8 additions & 0 deletions docs/bridge/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.3.8](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-10-07)

**Note:** Version bump only for package @synapsecns/bridge-docs





## [0.3.7](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-10-05)

**Note:** Version bump only for package @synapsecns/bridge-docs
Expand Down
7 changes: 7 additions & 0 deletions docs/bridge/docs/01-About/03-Routes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Routes from '@site/src/components/Routes'

# Chains & Tokens

This page contains a list of supported tokens, listed per-chain. For a given pair, use the [Synapse Bridge](https://synapseprotocol.com) to see if a route between them exists.

<Routes />
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
sidebar_label: Sample Code
sidebar_label: Examples
---

# Sample Code
# Example Code

Example SDK & API implementations

Expand Down
14 changes: 0 additions & 14 deletions docs/bridge/docs/02-Bridge/05-Supported-Routes.md

This file was deleted.

17 changes: 0 additions & 17 deletions docs/bridge/docs/02-Bridge/_05-Supported-Routes.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/bridge/docs/02-Bridge/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import SVGBridge from '@site/src/components/SVGBridge'

# Synapse Bridge

The [Synapse Bridge](https://synapseprotocol.com) and [Solana Bridge](https://solana.synapseprotocol.com/) seamlessly swap on-chain assets between [20+ EVM and non-EVM blockchains](./Supported-Routes) in a safe and secure manner.
The [Synapse Bridge](https://synapseprotocol.com) and [Solana Bridge](https://solana.synapseprotocol.com/) seamlessly swap on-chain assets between [20+ EVM and non-EVM blockchains](/docs/About/Routes) in a safe and secure manner.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Invalid link detected in documentation.

The link /docs/About/Routes in docs/bridge/docs/02-Bridge/index.md does not point to an existing documentation page. Please update the link to docs/bridge/docs/01-About/03-Routes.md to ensure it directs to the correct location.

🔗 Analysis chain

Approve link update with verification request.

The update to the documentation link appears to be an improvement in the overall structure. However, please ensure that the new link '/docs/About/Routes' is valid and leads to the correct page containing information about the supported blockchains.

To verify the existence of the new documentation page, please run the following script:

If the script doesn't find the file, please create it or update the link to the correct location.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the new Routes documentation file exists

# Test: Search for the Routes documentation file
fd -t f 'Routes.md' docs/About

Length of output: 128


Script:

#!/bin/bash
# Description: Search for Routes.md in the entire repository to verify its existence and correct path.

fd -t f 'Routes.md'

Length of output: 58


<br />

Expand Down
2 changes: 1 addition & 1 deletion docs/bridge/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@synapsecns/bridge-docs",
"version": "0.3.7",
"version": "0.3.8",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
Expand Down
26 changes: 7 additions & 19 deletions docs/bridge/src/components/Routes.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import { BRIDGABLE_TOKENS, CHAINS } from '@synapsecns/synapse-constants'

const CHAINS_BY_ID = {}

for (const { chainImg, id, name } of Object.values(CHAINS)) {
if (id && name) {
CHAINS_BY_ID[id] = { name, chainImg }
}
}

export default () =>
Object.entries(BRIDGABLE_TOKENS).map(([id, tokens]) => {
const chain = CHAINS_BY_ID[id]
const chainImg = chain.chainImg({ width: 28, height: 28 })
const chain = CHAINS.CHAINS_BY_ID[id]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

⚠️ Potential issue

Incorrect usage of CHAINS_BY_ID

The CHAINS object does not contain a CHAINS_BY_ID property. You should reference CHAINS_BY_ID directly instead of accessing it via CHAINS.

  • Suggested change in docs/bridge/src/components/Routes.tsx:

    - const chain = CHAINS.CHAINS_BY_ID[id]
    + const chain = CHAINS_BY_ID[id]
🔗 Analysis chain

Incorrect chain access method

The current implementation attempts to access CHAINS.CHAINS_BY_ID[id], which is likely incorrect. Based on the previous implementation and the typical structure of such constants, it's probable that CHAINS_BY_ID is a separate object, not a property of CHAINS.

Consider reverting to the previous access method or ensure that the CHAINS object has the correct structure. If CHAINS_BY_ID is a separate export from the constants file, you should use:

-const chain = CHAINS.CHAINS_BY_ID[id]
+const chain = CHAINS_BY_ID[id]

If CHAINS_BY_ID is no longer available, please provide more context on how chain information should be accessed.

To verify the correct structure, we can check the contents of the constants file:


Constants file not found

The shell script did not locate a constants file containing synapse-constants. To verify the structure of CHAINS, we need to identify where it is defined in the codebase.


Failed to locate CHAINS definitions

The previous shell script failed to recognize the tsx file type. To locate the definitions of CHAINS and CHAINS_BY_ID, we need to adjust the search parameters.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check the structure of CHAINS in the constants file

# Find the constants file
constants_file=$(fd -e ts -e js -e tsx -e jsx -t f synapse-constants)

if [ -n "$constants_file" ]; then
    echo "Contents of the constants file:"
    cat "$constants_file"
else
    echo "Constants file not found."
fi

Length of output: 149


Script:

#!/bin/bash
# Description: Find the definition of CHAINS and CHAINS_BY_ID in the codebase

# Search for CHAINS definition
echo "Searching for 'CHAINS' definition:"
rg 'CHAINS\s*=' --type ts --type tsx --type js --type jsx

# Search for 'CHAINS_BY_ID' definition
echo "Searching for 'CHAINS_BY_ID' definition:"
rg 'CHAINS_BY_ID\s*=' --type ts --type tsx --type js --type jsx

Length of output: 363


Script:

#!/bin/bash
# Description: Find the definition of CHAINS and CHAINS_BY_ID in the codebase without specifying file types

# Search for CHAINS definition
echo "Searching for 'CHAINS' definition:"
rg 'CHAINS\s*='

# Search for 'CHAINS_BY_ID' definition:
rg 'CHAINS_BY_ID\s*='

Length of output: 1524

const chainImg = chain.chainImg

return (
<section key={id}>
<h2
Expand All @@ -22,16 +15,10 @@ export default () =>
alignItems: 'center',
}}
>
{chainImg} {chain.name} <code>{id}</code>
<img width="28" height="28" src={chainImg} alt={chain.name} />
{chain.name} <code>{id}</code>
</h2>
{Object.values(tokens).map((token) => {
const tokenImg =
typeof token.icon === 'string' ? (
<img width="16" height="16" src={token.icon} />
) : (
token.icon({ width: 16, height: 16 })
)

return (
<span
key={token.addresses[id]}
Expand All @@ -42,7 +29,8 @@ export default () =>
padding: '.25rem .5rem',
}}
>
{tokenImg} {token.symbol}
<img width="16" height="16" src={token.icon} alt={token.symbol} />{' '}
{token.symbol}
</span>
)
})}
Expand Down
8 changes: 8 additions & 0 deletions packages/rfq-indexer/api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [1.0.6](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-10-07)

**Note:** Version bump only for package @synapsecns/rfq-indexer-api





## [1.0.5](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-10-03)

**Note:** Version bump only for package @synapsecns/rfq-indexer-api
Expand Down
26 changes: 16 additions & 10 deletions packages/rfq-indexer/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,40 @@ To make requests, use: https://triumphant-magic-production.up.railway.app , and

## API Calls

1. GET /api/hello
- Description: A simple hello world endpoint
- Example: `curl http://localhost:3001/api/hello`

2. GET /api/pending-transactions-missing-relay
All API calls can be viewed in Swagger:

[Swagger Documentation](http://localhost:3001/api-docs)

1. GET /api/pending-transactions-missing-relay
- Description: Retrieves pending transactions that are missing relay events
- Example:
```
curl http://localhost:3001/api/pending-transactions-missing-relay
curl http://localhost:3001/api/pending-transactions/missing-relay
```

3. GET /api/pending-transactions-missing-proof
2. GET /api/pending-transactions-missing-proof
- Description: Retrieves pending transactions that are missing proof events
- Example:
```
curl http://localhost:3001/api/pending-transactions-missing-proof
curl http://localhost:3001/api/pending-transactions/missing-proof
```

4. GET /api/pending-transactions-missing-claim
3. GET /api/pending-transactions-missing-claim
- Description: Retrieves pending transactions that are missing claim events
- Example:
```
curl http://localhost:3001/api/pending-transactions-missing-claim
curl http://localhost:3001/api/pending-transactions/missing-claim
```

5. GraphQL endpoint: /graphql
4. GraphQL endpoint: /graphql
- Description: Provides a GraphQL interface for querying indexed data, the user is surfaced an interface to query the data via GraphiQL

## Env Vars

- **NODE_ENV**: Set to `"development"` for localhost testing.
- **DATABASE_URL**: PostgreSQL connection URL for the ponder index.

## Important Scripts

- `yarn dev:local`: Runs the API in development mode using local environment variables
Expand Down
2 changes: 1 addition & 1 deletion packages/rfq-indexer/api/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@synapsecns/rfq-indexer-api",
"private": true,
"version": "1.0.5",
"version": "1.0.6",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const conflictingProofsController = async (
const query = db
.with('deposits', () => qDeposits())
.with('relays', () => qRelays())
.with('proofs', () => qProofs())
.with('proofs', () => qProofs({activeOnly: true}))
.with('combined', (qb) =>
qb
.selectFrom('deposits')
Expand Down Expand Up @@ -41,10 +41,10 @@ export const conflictingProofsController = async (
if (conflictingProofs && conflictingProofs.length > 0) {
res.json(conflictingProofs)
} else {
res.status(200).json({ message: 'No conflicting proofs found' })
res.status(200).json({ message: 'No active conflicting proofs found' })
}
} catch (error) {
console.error('Error fetching conflicting proofs:', error)
console.error('Error fetching active conflicting proofs:', error)
res.status(500).json({ message: 'Internal server error' })
}
}
27 changes: 27 additions & 0 deletions packages/rfq-indexer/api/src/controllers/disputesController.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Request, Response } from 'express'

import { db } from '../db'
import { qDisputes } from '../queries'
import { nest_results } from '../utils/nestResults'

export const disputesController = async (req: Request, res: Response) => {
try {
const query = db
.with('disputes', () => qDisputes({activeOnly: true}))
.selectFrom('disputes')
.selectAll()
.orderBy('blockTimestamp_dispute', 'desc')
Comment on lines +9 to +13
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider optimizing the query by selecting only necessary columns.

The query construction looks good overall, using a CTE and proper ordering. However, selecting all columns (selectAll()) might not be the most efficient approach, especially if the client doesn't need all the data.

Consider modifying the query to select only the columns that are actually needed by the client. This can improve query performance and reduce data transfer. For example:

.selectFrom('disputes')
.select(['id', 'status', 'blockTimestamp_dispute', /* other necessary columns */])

This change would require knowing which specific columns are needed for the disputes data in your application.


const results = await query.execute()
const disputes = nest_results(results)

if (disputes && disputes.length > 0) {
res.json(disputes)
} else {
res.status(200).json({ message: 'No active disputes found' })
}
Comment on lines +18 to +22
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider making the response structure consistent for both cases.

The response handling covers both cases (disputes found and not found) appropriately. However, the response structure is inconsistent between the two cases.

To improve API consistency, consider using the same structure for both cases. Here's a suggested modification:

if (disputes && disputes.length > 0) {
  res.json({ disputes })
} else {
  res.json({ disputes: [], message: 'No active disputes found' })
}

This change ensures that the client always receives an object with a disputes property (an array, which may be empty) and optionally a message property. This consistency can make it easier for clients to handle the response.

} catch (error) {
console.error('Error fetching active disputes:', error)
res.status(500).json({ message: 'Internal server error' })
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import { Request, Response } from 'express'

import { db } from '../db'
import { qDeposits, qRelays, qProofs, qClaims, qRefunds } from '../queries'
import {
qDeposits,
qRelays,
qProofs,
qClaims,
qRefunds,
qDisputes,
} from '../queries'
import { nest_results } from '../utils/nestResults'

const sevenDaysAgo = Math.floor(Date.now() / 1000) - 7 * 24 * 60 * 60

Comment on lines +14 to +15
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider defining constants for time calculations for better readability.

To enhance readability and maintainability, consider defining constants for time units used in time calculations.

Example:

const SECONDS_IN_A_DAY = 86400; // 24 * 60 * 60
const sevenDaysAgo = Math.floor(Date.now() / 1000) - 7 * SECONDS_IN_A_DAY;

export const pendingTransactionsMissingClaimController = async (
req: Request,
res: Response
Expand All @@ -12,7 +21,7 @@ export const pendingTransactionsMissingClaimController = async (
const query = db
.with('deposits', () => qDeposits())
.with('relays', () => qRelays())
.with('proofs', () => qProofs())
.with('proofs', () => qProofs({activeOnly: true}))
.with('claims', () => qClaims())
.with('combined', (qb) =>
qb
Expand Down Expand Up @@ -45,7 +54,6 @@ export const pendingTransactionsMissingClaimController = async (
}
}


export const pendingTransactionsMissingProofController = async (
req: Request,
res: Response
Expand All @@ -54,7 +62,7 @@ export const pendingTransactionsMissingProofController = async (
const query = db
.with('deposits', () => qDeposits())
.with('relays', () => qRelays())
.with('proofs', () => qProofs())
.with('proofs', () => qProofs({activeOnly: true}))
.with('combined', (qb) =>
qb
.selectFrom('deposits')
Expand Down Expand Up @@ -111,6 +119,52 @@ export const pendingTransactionsMissingRelayController = async (
.selectFrom('combined')
.selectAll()
.orderBy('blockTimestamp_deposit', 'desc')
.where('blockTimestamp_deposit', '>', sevenDaysAgo)

const results = await query.execute()
const nestedResults = nest_results(results)

if (nestedResults && nestedResults.length > 0) {
res.json(nestedResults)
} else {
res
.status(404)
.json({ message: 'No pending transactions missing relay found' })
}
} catch (error) {
console.error('Error fetching pending transactions missing relay:', error)
res.status(500).json({ message: 'Internal server error' })
}
Comment on lines +135 to +137
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Differentiate error messages for clearer debugging.

The error messages in the catch blocks are identical across controllers. To facilitate easier debugging, update the error messages to reflect the specific controller's context.

Suggested changes:

In pendingTransactionsMissingRelayExceedDeadlineController, update the error logging:

- console.error('Error fetching pending transactions missing relay:', error)
+ console.error('Error fetching pending transactions missing relay exceeding deadline:', error)

And update the response message in the else block:

- .json({ message: 'No pending transactions missing relay found' })
+ .json({ message: 'No pending transactions missing relay exceeding deadline found' })

Also applies to: 166-167

}

export const pendingTransactionsMissingRelayExceedDeadlineController = async (
req: Request,
res: Response
) => {
try {
const query = db
.with('deposits', () => qDeposits())
.with('relays', () => qRelays())
.with('refunds', () => qRefunds())
.with(
'combined',
(qb) =>
qb
.selectFrom('deposits')
.selectAll('deposits')
.leftJoin('relays', 'transactionId_deposit', 'transactionId_relay')
.leftJoin(
'refunds',
'transactionId_deposit',
'transactionId_refund'
)
.where('transactionId_relay', 'is', null) // is not relayed
.where('transactionId_refund', 'is', null) // is not refunded
)
.selectFrom('combined')
.selectAll()
.orderBy('blockTimestamp_deposit', 'desc')
.where('blockTimestamp_deposit', '<=', sevenDaysAgo)
Comment on lines +140 to +167
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider refactoring to reduce code duplication between controllers.

The pendingTransactionsMissingRelayController and pendingTransactionsMissingRelayExceedDeadlineController have similar structures with differences in the where clauses. Refactoring common logic into shared functions can improve maintainability and reduce redundancy.


const results = await query.execute()
const nestedResults = nest_results(results)
Expand Down
Loading