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

add carp funnel with stake delegation pool tracking #246

Merged
merged 21 commits into from
Dec 12, 2023

Conversation

ecioppettini
Copy link
Contributor

@ecioppettini ecioppettini commented Oct 24, 2023

TODO

  • remove tmp_carp_client and use the version from npm once published
  • make the presync work
  • parametrize the known shelley time or something (potentially the carp service could provide this instead)

Example settings

Currently I'm setting things up like this:

extensions.yml

extensions:
   - name: "Cardano Stake Delegation"
     type: cardano-stake-delegation 
     pools: ["367d927a91eb9ecf15648779beeec8c710171566edcce18feb048265"]
     startSlot: 32032590  
     scheduledPrefix: cd

.env (example)

CARP_URL=http://localhost:3000
CARDANO_NETWORK=preview
CARDANO_CONFIRMATION_DEPTH=10 
BATCHER_CARDANO_ENABLED_POOLS="095dd39da2d8534f9ddb93759a1931288e5dd79ae04fa5914e157bd6,093de39da2d8534f9ddb93759a1931288e5dd79a404fa5914e157b99"
BATCHER_CARP_URL=http://host.docker.internal:3000

Ideally the carp setting should be a single one, but I needed this to make it work with the batcher running in docker.

Parsing

I had to setup a parsing rule like this:

cardanoDelegation  = cd|address|pool

(the lenghts are not tight bounds, just as an example for testing)

const cardanoDelegation: ParserRecord<CardanoStakeDelegation> = {
  address: PaimaParser.NCharsParser(0, 100),
  pool: PaimaParser.OptionalParser(null, PaimaParser.NCharsParser(0, 100)),
};

@ecioppettini ecioppettini self-assigned this Oct 24, 2023
@ecioppettini ecioppettini force-pushed the carp-funnel-stake-delegation-cde branch from 081aeba to a1831ef Compare October 31, 2023 00:32
@ecioppettini ecioppettini marked this pull request as ready for review November 3, 2023 00:53
@ecioppettini ecioppettini force-pushed the carp-funnel-stake-delegation-cde branch from 9b76490 to 2a9f066 Compare November 7, 2023 02:30
);
return allData;
}

async function getSpecificCdeData(
extension: ChainDataExtension,
extension: ChainDataExtension & { startBlockHeight: number },
Copy link
Contributor

Choose a reason for hiding this comment

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

What was the need to add this? It's not used anywhere in the function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't understand this question, it's used in the first line of the function actually

packages/engine/paima-funnel/src/funnels/BaseFunnel.ts Outdated Show resolved Hide resolved
packages/engine/paima-funnel/src/funnels/block/funnel.ts Outdated Show resolved Hide resolved
import { query, getErrorResponse } from '@dcspark/carp-client/client/src/index';
import { Routes } from '@dcspark/carp-client/shared/routes';

const confirmationDepth = '10';
Copy link
Contributor

@SebastienGllmt SebastienGllmt Nov 16, 2023

Choose a reason for hiding this comment

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

Should have a comment rationale for why 10 was picked. If this isn't an ENV, it should be mentioned in the docs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made it an env... Since I think it should be configurable, although it's a bit problematic since it shouldn't really be changed without resyncing.

packages/engine/paima-funnel/src/funnels/carp/funnel.ts Outdated Show resolved Hide resolved
packages/engine/paima-sm/src/index.ts Outdated Show resolved Hide resolved
packages/engine/paima-sm/src/index.ts Outdated Show resolved Hide resolved
packages/engine/paima-sm/src/index.ts Outdated Show resolved Hide resolved
packages/engine/paima-sm/src/index.ts Outdated Show resolved Hide resolved
packages/paima-sdk/paima-db/migrations/up.sql Outdated Show resolved Hide resolved
@ecioppettini ecioppettini force-pushed the carp-funnel-stake-delegation-cde branch from 079776d to 5ead855 Compare November 22, 2023 03:50
@ecioppettini ecioppettini force-pushed the carp-funnel-stake-delegation-cde branch from 6080ca7 to 879218d Compare November 30, 2023 02:39
@@ -1,16 +1,7 @@
/* tslint:disable */
Copy link
Contributor

Choose a reason for hiding this comment

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

This file is automatically generated and shouldn't be checked in. The reason this file changed is because sometimes it gets modified by automatic code formatting and I can't figure out why sometimes the rule to ignore this file for formatting works and sometimes it doesn't 😕

Copy link
Contributor Author

Choose a reason for hiding this comment

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

deleted

Comment on lines 65 to 67
if (!ENV.CARP_URL) {
delete presyncBlockHeight[Network.CARDANO];
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this not cause a subtle issue where if you specify a Cardano CDE but the CARP_URL is missing that it just silently doesn't track anything? I feel if you're using task that requires Carp and you didn't specify the CARP_URL it should be an error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, makes sense, changed it for an error

);

let grouped = groupCdeData(
Network.EVM,
Copy link
Contributor

Choose a reason for hiding this comment

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

why not cardano?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well... It doesn't actually matter, I think.

The discriminant was introduced so that during the presync we can update the cardano cde tracking table instead of the other one, but during the normal sync just knowing the EVM block gives you the slot, so the field is not used.

But I guess we should put cardano here anyway to be consistent.

@gostkin
Copy link
Contributor

gostkin commented Dec 5, 2023

how do I get pool id to put in the config in BATCHER_CARDANO_ENABLED_POOLS? what is the format? e.g. I have pool id 3867a09729a1f954762eea035a82e2d9d3a14f1fa791a022ef0da242, how to put it there? 8200581ceeef9389ba6f3971425a59af99c56d1c9c227b3a2c2c8f52a10dd8ag looks like a different format and i can't query it in the explorer

@ecioppettini
Copy link
Contributor Author

ecioppettini commented Dec 5, 2023

how do I get pool id to put in the config in BATCHER_CARDANO_ENABLED_POOLS? what is the format? e.g. I have pool id 3867a09729a1f954762eea035a82e2d9d3a14f1fa791a022ef0da242, how to put it there? 8200581ceeef9389ba6f3971425a59af99c56d1c9c227b3a2c2c8f52a10dd8ag looks like a different format and i can't query it in the explorer

The 8200581ceeef9389ba6f3971425a59af99c56d1c9c227b3a2c2c8f52a10dd8ag format was a mistake actually, it should be a string of 56 chars. I corrected it in the docs, but I forgot to do it here. It should be what shows as pool id in cardanoscan.

@gostkin

Comment on lines 8 to 18
const startBlockheights = config.map(cde => cde.startBlockHeight).filter(sbh => !!sbh);
const startBlockheights = config
.map(cde => {
if (cde.cdeType != ChainDataExtensionType.CardanoPool) {
return cde.startBlockHeight;
} else {
return null;
}
})
.filter(sbh => !!sbh) as number[];
const minStartBlockheight = Math.min(...startBlockheights);
return isFinite(minStartBlockheight) ? minStartBlockheight : -1;
Copy link
Contributor

Choose a reason for hiding this comment

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

All of this should probably be a single .reduce call instead (same with the function below)

@SebastienGllmt SebastienGllmt merged commit a578dca into master Dec 12, 2023
@SebastienGllmt SebastienGllmt deleted the carp-funnel-stake-delegation-cde branch December 12, 2023 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants