Skip to content

fetch network info from the validation #329

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all 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
16 changes: 2 additions & 14 deletions src/connection-manager/wsHandling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,13 @@ import {
import { AMENDMENTS_ID } from 'xrpl/dist/npm/models/ledger'
import { LedgerResponseExpanded } from 'xrpl/dist/npm/models/methods/ledger'

import {
query,
saveAmendmentStatus,
saveAmendmentsStatus,
} from '../shared/database'
import { saveAmendmentStatus, saveAmendmentsStatus } from '../shared/database'
import {
NETWORKS_HOSTS,
deleteAmendmentStatus,
} from '../shared/database/amendments'
import {
AmendmentStatus,
DatabaseValidator,
FeeVote,
StreamLedger,
StreamManifest,
Expand Down Expand Up @@ -123,14 +118,7 @@ export async function handleWsMessageSubscribeTypes(
}

// Get network of the validation if ledger_hash is not in cache.
const validationNetworkDb: DatabaseValidator | undefined = await query(
'validators',
)
.select('*')
.where('signing_key', validationData.validation_public_key)
.first()
const validationNetwork =
validationNetworkDb?.networks ?? validationData.networks
const validationNetwork = validationData.networks ?? networks
Copy link
Contributor

Choose a reason for hiding this comment

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

As per #328 (comment)

I think we should fallback to the in-memory cache -> database to get the network as you suggested here #328 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that is also an acceptable solution. However, I'm wary of the larger untested code changes in that PR. I will also note one other (albeit rare) possibility:

The in-memory cache does not have any "invalidation scheme". The network corresponding to a validator's public_key could be changed after its admission into the in-memory cache. However, this change will not be registered until at least CM_INTERVAL. This would be a very rare occurence, but it is something we need to consider for the future.


// Get the fee for the network to be used in case the validator does not vote for a new fee.
if (validationNetwork) {
Expand Down