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

Support dynamically specified networks #187

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1,335 changes: 542 additions & 793 deletions Cargo.lock

Large diffs are not rendered by default.

13 changes: 9 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ members = [


[workspace.dependencies]
cml-chain = { version = "6.0.0" }
cml-core = { version = "6.0.0" }
cml-crypto = { version = "6.0.0" }
cml-multi-era = { version = "6.0.0" }
# cml-chain = { version = "6.0.0" }
# cml-core = { version = "6.0.0" }
# cml-crypto = { version = "6.0.0" }
# cml-multi-era = { version = "6.0.0" }

cml-chain = { git = "https://github.com/dcSpark/cardano-multiplatform-lib", rev = "8ea3d50ab9a01d82ca72ab6d8258b4b36aad2ce7" }
cml-core = { git = "https://github.com/dcSpark/cardano-multiplatform-lib", rev = "8ea3d50ab9a01d82ca72ab6d8258b4b36aad2ce7" }
cml-crypto = { git = "https://github.com/dcSpark/cardano-multiplatform-lib", rev = "8ea3d50ab9a01d82ca72ab6d8258b4b36aad2ce7" }
cml-multi-era = { git = "https://github.com/dcSpark/cardano-multiplatform-lib", rev = "8ea3d50ab9a01d82ca72ab6d8258b4b36aad2ce7" }
2 changes: 1 addition & 1 deletion deployment/config/indexer/cardano_node_docker.mainnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ sink:
db:
type: postgres
database_url: postgresql://carp:1234@postgres:5432/carp_mainnet
network: mainnet # preview / preprod / testnet
network: mainnet # preview / preprod / testnet / custom

start_block:
2 changes: 1 addition & 1 deletion deployment/config/indexer/oura_docker.mainnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ sink:
db:
type: postgres
database_url: postgresql://carp:1234@postgres:5432/carp_mainnet
network: mainnet # preview / preprod / testnet
network: mainnet # preview / preprod / testnet / custom

start_block:
2 changes: 1 addition & 1 deletion docs/docs/indexer/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ sink:
db:
type: postgres
database_url: postgresql://carp:1234@localhost:5432/carp_mainnet
network: mainnet # preview / preprod / testnet
network: mainnet # preview / preprod / testnet / custom

start_block:
```
Expand Down
7 changes: 3 additions & 4 deletions indexer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ strip = true

[dependencies]
# [core]
dcspark-core = { git = "https://github.com/dcSpark/dcspark-core.git", rev = "63105adc46478eea57340bcbfc5425ced0ba139f" }
dcspark-blockchain-source = { git = "https://github.com/dcSpark/dcspark-core.git", rev = "63105adc46478eea57340bcbfc5425ced0ba139f" }
multiverse = { git = "https://github.com/dcSpark/dcspark-core.git", rev = "63105adc46478eea57340bcbfc5425ced0ba139f" }
dcspark-core = { git = "https://github.com/dcSpark/dcspark-core.git", rev = "986ad8495c3894782774e2db0fc3fe65f44ca89d" }
dcspark-blockchain-source = { git = "https://github.com/dcSpark/dcspark-core.git", rev = "986ad8495c3894782774e2db0fc3fe65f44ca89d" }
multiverse = { git = "https://github.com/dcSpark/dcspark-core.git", rev = "986ad8495c3894782774e2db0fc3fe65f44ca89d" }

# [local]
entity = { path = "entity" }
Expand All @@ -29,7 +29,6 @@ clap = { version = "3.1", features = ["derive"] }
ctrlc = { version = "3.2.4", features = ["termination"] }
dotenv = { version = "0.15.0" }
hex = { version = "0.4.3" }
oura = { git = "https://github.com/txpipe/oura.git", rev = "e1b971394a394bde13fb601ad3f6d4ad343b02f0" }
serde = { version = "1.0.152", features = ["derive", "rc"] }
serde_json = { version = "1.0.92" }
serde_yaml = { version = "0.9.17" }
Expand Down
2 changes: 1 addition & 1 deletion indexer/configs/cardano_node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ sink:
db:
type: postgres
database_url: postgresql://carp:1234@localhost:5432/carp_mainnet
network: mainnet # preview / preprod / testnet
network: mainnet # preview / preprod / testnet / custom

start_block:
23 changes: 23 additions & 0 deletions indexer/configs/custom.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
source:
type: cardano_net
relay:
- localhost
- 3001

sink:
type: cardano
db:
type: postgres
database_url: postgresql://carp:1234@localhost:5432/carp_custom5
network: custom # preview / preprod / testnet / custom
genesis_folder: /home/user/Cardano/carp/indexer/genesis/
custom_config:
chain_info:
network_id: 1
protocol_magic: 42
relay:
- "localhost"
- 3001

start_block:

2 changes: 1 addition & 1 deletion indexer/configs/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ sink:
db:
type: postgres
database_url: postgresql://carp:1234@localhost:5432/carp_mainnet
network: mainnet # preview / preprod / testnet
network: mainnet # preview / preprod / testnet / custom

start_block:
2 changes: 1 addition & 1 deletion indexer/configs/oura.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ sink:
db:
type: postgres
database_url: postgresql://carp:1234@localhost:5432/carp_mainnet
network: mainnet # preview / preprod / testnet
network: mainnet # preview / preprod / testnet / custom

start_block:
14 changes: 14 additions & 0 deletions indexer/entity/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,17 @@ impl TryFrom<i32> for EraValue {
}
}
}

impl EraValue {
pub fn to_str(&self) -> &'static str {
match self {
EraValue::Byron => "byron",
EraValue::Shelley => "shelley",
EraValue::Allegra => "allegra",
EraValue::Mary => "mary",
EraValue::Alonzo => "alonzo",
EraValue::Babbage => "babbage",
EraValue::Conway => "conway",
}
}
}
32 changes: 32 additions & 0 deletions indexer/entity/src/genesis.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Deserialize, Serialize)]
#[sea_orm(table_name = "Era")]
pub struct Model {
#[sea_orm(primary_key)]
pub era: i32,
pub block_id: i32,
pub block_height: i32,
pub first_slot: i64,
pub start_epoch: i64,
pub epoch_length_seconds: i64,
}

#[derive(Copy, Clone, Debug, DeriveRelation, EnumIter)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::block::Entity",
from = "Column::BlockId",
to = "super::block::Column::Id"
)]
Block,
}

impl Related<super::block::Entity> for Entity {
fn to() -> RelationDef {
Relation::Block.def()
}
}

impl ActiveModelBehavior for ActiveModel {}
2 changes: 1 addition & 1 deletion indexer/entity/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ pub mod asset_mint;
pub mod asset_utxos;
pub mod cip25_entry;
pub mod dex_swap;
pub mod genesis;
pub mod governance_votes;
pub mod native_asset;
pub mod plutus_data;
pub mod plutus_data_hash;
pub mod projected_nft;
// todo: rename to pool?
pub mod stake_delegation;
pub mod stake_delegation_drep;
pub mod transaction_metadata;
4 changes: 4 additions & 0 deletions indexer/entity/src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ pub use super::dex_swap::{
ActiveModel as DexSwapActiveModel, Column as DexSwapColumn, Entity as DexSwap,
Model as DexSwapModel, PrimaryKey as DexSwapPrimaryKey, Relation as DexSwapRelation,
};
pub use super::genesis::{
ActiveModel as GenesisActiveModel, Column as GenesisColumn, Entity as Genesis,
Model as GenesisModel, PrimaryKey as GenesisPrimaryKey, Relation as GenesisRelation,
};
pub use super::governance_votes::{
ActiveModel as GovernanceVoteActiveModel, Column as GovernanceVoteColumn,
Entity as GovernanceVote, Model as GovernanceVoteModel, PrimaryKey as GovernanceVotePrimaryKey,
Expand Down
2 changes: 2 additions & 0 deletions indexer/execution_plans/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ include_payload=false
[GenesisTransactionTask]
include_payload=true

[ShelleyGenesisBlockTask]

[ByronBlockTask]
readonly=false
include_payload=false
Expand Down
68 changes: 68 additions & 0 deletions indexer/genesis/mainnet-shelley-genesis.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"activeSlotsCoeff": 0.05,
"protocolParams": {
"protocolVersion": {
"minor": 0,
"major": 2
},
"decentralisationParam": 1,
"eMax": 18,
"extraEntropy": {
"tag": "NeutralNonce"
},
"maxTxSize": 16384,
"maxBlockBodySize": 65536,
"maxBlockHeaderSize": 1100,
"minFeeA": 44,
"minFeeB": 155381,
"minUTxOValue": 1000000,
"poolDeposit": 500000000,
"minPoolCost": 340000000,
"keyDeposit": 2000000,
"nOpt": 150,
"rho": 0.003,
"tau": 0.20,
"a0": 0.3
},
"genDelegs": {
"ad5463153dc3d24b9ff133e46136028bdc1edbb897f5a7cf1b37950c": {
"delegate": "d9e5c76ad5ee778960804094a389f0b546b5c2b140a62f8ec43ea54d",
"vrf": "64fa87e8b29a5b7bfbd6795677e3e878c505bc4a3649485d366b50abadec92d7"
},
"b9547b8a57656539a8d9bc42c008e38d9c8bd9c8adbb1e73ad529497": {
"delegate": "855d6fc1e54274e331e34478eeac8d060b0b90c1f9e8a2b01167c048",
"vrf": "66d5167a1f426bd1adcc8bbf4b88c280d38c148d135cb41e3f5a39f948ad7fcc"
},
"60baee25cbc90047e83fd01e1e57dc0b06d3d0cb150d0ab40bbfead1": {
"delegate": "7f72a1826ae3b279782ab2bc582d0d2958de65bd86b2c4f82d8ba956",
"vrf": "c0546d9aa5740afd569d3c2d9c412595cd60822bb6d9a4e8ce6c43d12bd0f674"
},
"f7b341c14cd58fca4195a9b278cce1ef402dc0e06deb77e543cd1757": {
"delegate": "69ae12f9e45c0c9122356c8e624b1fbbed6c22a2e3b4358cf0cb5011",
"vrf": "6394a632af51a32768a6f12dac3485d9c0712d0b54e3f389f355385762a478f2"
},
"162f94554ac8c225383a2248c245659eda870eaa82d0ef25fc7dcd82": {
"delegate": "4485708022839a7b9b8b639a939c85ec0ed6999b5b6dc651b03c43f6",
"vrf": "aba81e764b71006c515986bf7b37a72fbb5554f78e6775f08e384dbd572a4b32"
},
"2075a095b3c844a29c24317a94a643ab8e22d54a3a3a72a420260af6": {
"delegate": "6535db26347283990a252313a7903a45e3526ec25ddba381c071b25b",
"vrf": "fcaca997b8105bd860876348fc2c6e68b13607f9bbd23515cd2193b555d267af"
},
"268cfc0b89e910ead22e0ade91493d8212f53f3e2164b2e4bef0819b": {
"delegate": "1d4f2e1fda43070d71bb22a5522f86943c7c18aeb4fa47a362c27e23",
"vrf": "63ef48bc5355f3e7973100c371d6a095251c80ceb40559f4750aa7014a6fb6db"
}
},
"updateQuorum": 5,
"networkId": "Mainnet",
"initialFunds": {},
"maxLovelaceSupply": 45000000000000000,
"networkMagic": 764824073,
"epochLength": 432000,
"systemStart": "2017-09-23T21:44:51Z",
"slotsPerKESPeriod": 129600,
"slotLength": 1,
"maxKESEvolutions": 62,
"securityParam": 2160
}
72 changes: 72 additions & 0 deletions indexer/genesis/preprod-shelley-genesis.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"activeSlotsCoeff": 0.05,
"epochLength": 432000,
"genDelegs": {
"637f2e950b0fd8f8e3e811c5fbeb19e411e7a2bf37272b84b29c1a0b": {
"delegate": "aae9293510344ddd636364c2673e34e03e79e3eefa8dbaa70e326f7d",
"vrf": "227116365af2ed943f1a8b5e6557bfaa34996f1578eec667a5e2b361c51e4ce7"
},
"8a4b77c4f534f8b8cc6f269e5ebb7ba77fa63a476e50e05e66d7051c": {
"delegate": "d15422b2e8b60e500a82a8f4ceaa98b04e55a0171d1125f6c58f8758",
"vrf": "0ada6c25d62db5e1e35d3df727635afa943b9e8a123ab83785e2281605b09ce2"
},
"b00470cd193d67aac47c373602fccd4195aad3002c169b5570de1126": {
"delegate": "b3b539e9e7ed1b32fbf778bf2ebf0a6b9f980eac90ac86623d11881a",
"vrf": "0ff0ce9b820376e51c03b27877cd08f8ba40318f1a9f85a3db0b60dd03f71a7a"
},
"b260ffdb6eba541fcf18601923457307647dce807851b9d19da133ab": {
"delegate": "7c64eb868b4ef566391a321c85323f41d2b95480d7ce56ad2abcb022",
"vrf": "7fb22abd39d550c9a022ec8104648a26240a9ff9c88b8b89a6e20d393c03098e"
},
"ced1599fd821a39593e00592e5292bdc1437ae0f7af388ef5257344a": {
"delegate": "de7ca985023cf892f4de7f5f1d0a7181668884752d9ebb9e96c95059",
"vrf": "c301b7fc4d1b57fb60841bcec5e3d2db89602e5285801e522fce3790987b1124"
},
"dd2a7d71a05bed11db61555ba4c658cb1ce06c8024193d064f2a66ae": {
"delegate": "1e113c218899ee7807f4028071d0e108fc790dade9fd1a0d0b0701ee",
"vrf": "faf2702aa4893c877c622ab22dfeaf1d0c8aab98b837fe2bf667314f0d043822"
},
"f3b9e74f7d0f24d2314ea5dfbca94b65b2059d1ff94d97436b82d5b4": {
"delegate": "fd637b08cc379ef7b99c83b416458fcda8a01a606041779331008fb9",
"vrf": "37f2ea7c843a688159ddc2c38a2f997ab465150164a9136dca69564714b73268"
}
},
"initialFunds": {},
"maxKESEvolutions": 62,
"maxLovelaceSupply": 45000000000000000,
"networkId": "Testnet",
"networkMagic": 1,
"protocolParams": {
"protocolVersion": {
"minor": 0,
"major": 2
},
"decentralisationParam": 1,
"eMax": 18,
"extraEntropy": {
"tag": "NeutralNonce"
},
"maxTxSize": 16384,
"maxBlockBodySize": 65536,
"maxBlockHeaderSize": 1100,
"minFeeA": 44,
"minFeeB": 155381,
"minUTxOValue": 1000000,
"poolDeposit": 500000000,
"minPoolCost": 340000000,
"keyDeposit": 2000000,
"nOpt": 150,
"rho": 0.003,
"tau": 0.20,
"a0": 0.3
},
"securityParam": 2160,
"slotLength": 1,
"slotsPerKESPeriod": 129600,
"staking": {
"pools": {},
"stake": {}
},
"systemStart": "2022-06-01T00:00:00Z",
"updateQuorum": 5
}
Loading
Loading