-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add carp funnel with stake delegation pool tracking (#246)
* add carp funnel with stake delegation pool tracking * handle presync in carp funnel * expose cde utils get cardano delegation function * use local (tmp) carp client lib in the funnel just to test until the up to date version is published on npm * add delegation check in batcher's address validator * add stopSlot setting to stop fetching * improve logging and make presync concurrent * address review comments * fix markCardanoCdeSlotProcessed query * presync checkpointing for cardano cde * drop cde_tracking_cardano in down.sql * address new review comments * replace carp local client with 2.3.0 from npm * cache the startingSlot and the previous range upper end just to reduce the number of rpc calls * remove old TODO the cast is probably clearer than the alternatives * replace map-filter with reduce for getEarlistSlot/Blockheight * add CARDANO_CONFIRMATION_DEPTH config * refactor getEarliestStart* functions * default case of min should be Infinity * document timestampToAbsoluteSlot and fix missing slot offset * reinitialize the cache entry in case of error
- Loading branch information
1 parent
27ea4b0
commit a578dca
Showing
38 changed files
with
1,038 additions
and
552 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import type { | ||
CdeCardanoPoolDatum, | ||
ChainDataExtensionCardanoDelegation, | ||
ChainDataExtensionDatum, | ||
} from '@paima/sm'; | ||
import { ChainDataExtensionDatumType, DEFAULT_FUNNEL_TIMEOUT, timeout } from '@paima/utils'; | ||
import { Routes, query } from '@dcspark/carp-client/client/src'; | ||
import type { DelegationForPoolResponse } from '@dcspark/carp-client/shared/models/DelegationForPool'; | ||
|
||
export default async function getCdeData( | ||
url: string, | ||
extension: ChainDataExtensionCardanoDelegation, | ||
fromAbsoluteSlot: number, | ||
toAbsoluteSlot: number, | ||
getBlockNumber: (slot: number) => number | ||
): Promise<ChainDataExtensionDatum[]> { | ||
const events = await timeout( | ||
query(url, Routes.delegationForPool, { | ||
pools: extension.pools, | ||
range: { minSlot: fromAbsoluteSlot, maxSlot: toAbsoluteSlot }, | ||
}), | ||
DEFAULT_FUNNEL_TIMEOUT | ||
); | ||
|
||
return events.map(e => eventToCdeDatum(e, extension, getBlockNumber(e.slot))); | ||
} | ||
|
||
function eventToCdeDatum( | ||
event: DelegationForPoolResponse[0], | ||
extension: ChainDataExtensionCardanoDelegation, | ||
blockNumber: number | ||
): CdeCardanoPoolDatum { | ||
return { | ||
cdeId: extension.cdeId, | ||
cdeDatumType: ChainDataExtensionDatumType.CardanoPool, | ||
blockNumber, | ||
payload: { | ||
address: event.credential, | ||
pool: event.pool || undefined, | ||
}, | ||
scheduledPrefix: extension.scheduledPrefix, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.