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

conway governance tasks #181

Merged
merged 18 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from 17 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
12 changes: 4 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@ members = [
"indexer/plan-visualizer",
"indexer/task-docgen"
]


[workspace.dependencies]
cml-chain = { git = "https://github.com/dcSpark/cardano-multiplatform-lib", branch = "new-conway-cddl-updates" }
cml-core = { git = "https://github.com/dcSpark/cardano-multiplatform-lib", branch = "new-conway-cddl-updates" }
cml-crypto = { git = "https://github.com/dcSpark/cardano-multiplatform-lib", branch = "new-conway-cddl-updates" }
cml-multi-era = { git = "https://github.com/dcSpark/cardano-multiplatform-lib", branch = "new-conway-cddl-updates" }
SebastienGllmt marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 4 additions & 4 deletions indexer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ tasks = { path = "tasks" }
# [indexer]
anyhow = { version = "1.0.69" }
async-trait = { version = "0.1.64" }
cml-chain = { version = "5.2.0" }
cml-core = { version = "5.2.0" }
cml-crypto = { version = "5.2.0" }
cml-multi-era = { version = "5.2.0" }
cml-chain = { workspace = true }
cml-core = { workspace = true }
cml-crypto = { workspace = true }
cml-multi-era = { workspace = true }
clap = { version = "3.1", features = ["derive"] }
ctrlc = { version = "3.2.4", features = ["termination"] }
dotenv = { version = "0.15.0" }
Expand Down
25 changes: 25 additions & 0 deletions indexer/entity/src/governance_votes.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Deserialize, Serialize)]
#[sea_orm(table_name = "GovernanceVote")]
pub struct Model {
#[sea_orm(primary_key, column_type = "BigInteger")]
pub id: i64,
pub tx_id: i64,
pub voter: Vec<u8>,
pub gov_action_id: Vec<u8>,
pub vote: Vec<u8>,
}

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

impl ActiveModelBehavior for ActiveModel {}
3 changes: 3 additions & 0 deletions indexer/entity/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ pub mod asset_mint;
pub mod asset_utxos;
pub mod cip25_entry;
pub mod dex_swap;
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;
5 changes: 5 additions & 0 deletions indexer/entity/src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ 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::governance_votes::{
ActiveModel as GovernanceVoteActiveModel, Column as GovernanceVoteColumn,
Entity as GovernanceVote, Model as GovernanceVoteModel, PrimaryKey as GovernanceVotePrimaryKey,
Relation as GovernanceVoteRelation,
};
pub use super::native_asset::{
ActiveModel as NativeAssetActiveModel, Column as NativeAssetColumn, Entity as NativeAsset,
Model as NativeAssetModel, PrimaryKey as NativeAssetPrimaryKey,
Expand Down
37 changes: 37 additions & 0 deletions indexer/entity/src/stake_delegation_drep.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Deserialize, Serialize)]
#[sea_orm(table_name = "StakeDelegationDrepCredentialRelation")]
pub struct Model {
#[sea_orm(primary_key, column_type = "BigInteger")]
pub id: i64,
pub stake_credential: i64,
pub drep_credential: Option<Vec<u8>>,
pub tx_id: i64,
pub previous_drep_credential: Option<Vec<u8>>,
}

#[derive(Copy, Clone, Debug, DeriveRelation, EnumIter)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::stake_credential::Entity",
from = "Column::StakeCredential",
to = "super::stake_credential::Column::Id"
)]
StakeCredential,
#[sea_orm(
belongs_to = "super::transaction::Entity",
from = "Column::TxId",
to = "super::transaction::Column::Id"
)]
Transaction,
}

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

impl ActiveModelBehavior for ActiveModel {}
62 changes: 62 additions & 0 deletions indexer/genesis/sanchonet-byron-genesis.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"avvmDistr": {},
"blockVersionData": {
"heavyDelThd": "300000000000",
"maxBlockSize": "2000000",
"maxHeaderSize": "2000000",
"maxProposalSize": "700",
"maxTxSize": "4096",
"mpcThd": "20000000000000",
"scriptVersion": 0,
"slotDuration": "20000",
"softforkRule": {
"initThd": "900000000000000",
"minThd": "600000000000000",
"thdDecrement": "50000000000000"
},
"txFeePolicy": {
"multiplier": "43946000000",
"summand": "155381000000000"
},
"unlockStakeEpoch": "18446744073709551615",
"updateImplicit": "10000",
"updateProposalThd": "100000000000000",
"updateVoteThd": "1000000000000"
},
"bootStakeholders": {
"318488dc356f6034104804b2cb6a2dcc055202491386fb0d5af7c3ba": 1,
"3a3c2ffaf066c8f211a1bdfd844f767ac453b1d94915e725c5867467": 1,
"3ae8eabb4e0626cea0ba38d8303d59514dae9c307d93bad3d259e4a9": 1
},
"heavyDelegation": {
"318488dc356f6034104804b2cb6a2dcc055202491386fb0d5af7c3ba": {
"cert": "b80e06679023284236df3464dc6aab3f56f23cb721d5943c59632ac77004f76ae415b6d291606c7194509e1fefa0c8341eed269bd0e0e1433302b00912a4230c",
"delegatePk": "9ELoyHN4GVtXrFzAJZApAVjrhwftqEFVoDXl9ebtTwpe/lG4b5ZkgH3DqwHE1hNJFRsnYs4zYzMmdbnoR7lfUA==",
"issuerPk": "MHFL9SqIV6KuXSAvp08jHBRtHwNsDJMsCxbmXLorSbfLAORg7waqVL8NEaKU3Lb0FBIX5sHVC21i1M/c0jrnlA==",
"omega": 0
},
"3a3c2ffaf066c8f211a1bdfd844f767ac453b1d94915e725c5867467": {
"cert": "ce91b8e35b67de2236fa79b353d1c4ebd97ad4b4cc89056a1acfc217ece8e91fbffc4bf44604a96a1064c9997f6cd39b81284aadfac752056eafc6b5996a6509",
"delegatePk": "Grpf6iTqd9aWc3QWvfthNv2l8Pp0X2tKpoIoPn0+Dy1+ow60UTu9i1j4KPjp1uzrnM4JoUcmkCGF507fPagO8w==",
"issuerPk": "1FPA7qSOPVDlNZoQAuoB2dnm+tKI5td6+BO5sJ2rswVxuS6S6sjBFVfVz/VXfKTcEt/AKyffgzWXAtPCnhC1jw==",
"omega": 0
},
"3ae8eabb4e0626cea0ba38d8303d59514dae9c307d93bad3d259e4a9": {
"cert": "908dd25262598050d60cb24928a7059fea3726a1dd7764645edab654d3b4e37ba69acd4841454f70f0f643305ede0ef66dc0ea9747a2387da05d2af77963f30a",
"delegatePk": "1zYduiReianx6HJHgQqtira7XY6M/Ol4tFj/O7TzTLcNfgazJm8pq5y6HAANwl91iL1pDZuIgFjzI+2i1Z6y2Q==",
"issuerPk": "Pgj3IyTJDyxr+t5fcMuM3aPtyNCxOo4T9sr78BNbgWBGwlTGo0P6UtzNLyqloLsH8V6Lv6kYMdWELAiEyfCpkw==",
"omega": 0
}
},
"nonAvvmBalances": {
"FHnt4NL7yPXqn7xha3WB99wYLxAc1FhceD3D1pQWaCthk9RYB46aGb6Tbq2KxV5": "0",
"FHnt4NL7yPXwj8m191s48v1RZtQqA2sVHpamzStuXTuAnzYUSR6hRPqhYmW3MY4": "0",
"FHnt4NL7yPXzVZ5xexcb7rWqCYWuFU7y6Pp4tLTiv6txhDcpQ2m7AFGMirsi1F1": "30000000000000000",
"FHnt4NL7yPY27r794z4UiYJ3RwezucDRLX94Pzy6mYPNUNWboB71S9xUm2WEDrv": "0"
},
"protocolConsts": {
"k": 432,
"protocolMagic": 4
},
"startTime": 1686789000
}
4 changes: 4 additions & 0 deletions indexer/migration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ mod m20230927_000016_create_stake_delegation_table;
mod m20231025_000017_projected_nft;
mod m20231220_000018_asset_utxo_table;
mod m20240229_000019_add_block_tx_count_column;
mod m20240326_000020_create_drep_delegation_table;
mod m20240326_000021_create_governance_voting_table;

pub struct Migrator;

Expand Down Expand Up @@ -49,6 +51,8 @@ impl MigratorTrait for Migrator {
Box::new(m20231025_000017_projected_nft::Migration),
Box::new(m20231220_000018_asset_utxo_table::Migration),
Box::new(m20240229_000019_add_block_tx_count_column::Migration),
Box::new(m20240326_000020_create_drep_delegation_table::Migration),
Box::new(m20240326_000021_create_governance_voting_table::Migration),
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
use entity::prelude::{StakeCredential, StakeCredentialColumn, Transaction, TransactionColumn};
use entity::stake_delegation_drep::*;
use sea_schema::migration::prelude::*;

pub struct Migration;

impl MigrationName for Migration {
fn name(&self) -> &str {
"m20240326_000020_create_drep_delegation_table"
}
}

#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_table(
Table::create()
.table(Entity)
.if_not_exists()
.col(
ColumnDef::new(Column::Id)
.big_integer()
.not_null()
.auto_increment(),
)
.col(
ColumnDef::new(Column::StakeCredential)
.big_integer()
.not_null(),
)
.col(ColumnDef::new(Column::TxId).big_integer().not_null())
.col(ColumnDef::new(Column::DrepCredential).binary())
.col(ColumnDef::new(Column::PreviousDrepCredential).binary())
.foreign_key(
ForeignKey::create()
.name("fk-stake_delegation_drep-credential_id")
.from(Entity, Column::StakeCredential)
.to(StakeCredential, StakeCredentialColumn::Id)
.on_delete(ForeignKeyAction::Cascade),
)
.foreign_key(
ForeignKey::create()
.name("fk-stake_delegation_drep-tx_id")
.from(Entity, Column::TxId)
.to(Transaction, TransactionColumn::Id)
.on_delete(ForeignKeyAction::Cascade),
)
.primary_key(
Index::create()
.table(Entity)
.name("stake_delegation_drep_credential-pk")
.col(Column::Id),
)
.to_owned(),
)
.await?;

manager
.create_index(
Index::create()
.table(Entity)
.name("index-stake_delegation_credential_drep-stake_credential")
.col(Column::StakeCredential)
.to_owned(),
)
.await
}

async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_table(Table::drop().table(Entity).to_owned())
.await
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
use entity::governance_votes::*;
use entity::prelude::{Transaction, TransactionColumn};
use sea_schema::migration::prelude::*;

pub struct Migration;

impl MigrationName for Migration {
fn name(&self) -> &str {
"m20240326_000021_create_governance_vote_table"
}
}

#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_table(
Table::create()
.table(Entity)
.if_not_exists()
.col(
ColumnDef::new(Column::Id)
.big_integer()
.not_null()
.auto_increment(),
)
.col(ColumnDef::new(Column::TxId).big_integer().not_null())
.col(ColumnDef::new(Column::Voter).binary())
.col(ColumnDef::new(Column::GovActionId).binary())
.col(ColumnDef::new(Column::Vote).binary())
.foreign_key(
ForeignKey::create()
.name("fk-governance_vote-tx_id")
.from(Entity, Column::TxId)
.to(Transaction, TransactionColumn::Id)
.on_delete(ForeignKeyAction::Cascade),
)
.primary_key(
Index::create()
.table(Entity)
.name("governance_vote-pk")
.col(Column::Id),
)
.to_owned(),
)
.await?;

manager
.create_index(
Index::create()
.table(Entity)
.name("index-governance_vote-voter")
.col(Column::Voter)
.to_owned(),
)
.await?;

Ok(())
}

async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_table(Table::drop().table(Entity).to_owned())
.await
}
}
8 changes: 4 additions & 4 deletions indexer/reparse/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ entity = { path = "../entity" }

# [reparse]
anyhow = { version = "1.0.69" }
cml-chain = { version = "5.2.0" }
cml-core = { version = "5.2.0" }
cml-crypto = { version = "5.2.0" }
cml-multi-era = { version = "5.2.0" }
cml-chain = { workspace = true }
cml-core = { workspace = true }
cml-crypto = { workspace = true }
cml-multi-era = { workspace = true }
dotenv = { version = "0.15.0" }
futures = { version = "0.3.21" }
hex = { version = "0.4.0" }
Expand Down
Loading
Loading