Skip to content

Commit

Permalink
ignore commit - ci test
Browse files Browse the repository at this point in the history
  • Loading branch information
cong-or committed Sep 25, 2022
1 parent 25fad50 commit 0782197
Show file tree
Hide file tree
Showing 15 changed files with 214 additions and 59 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions explorer/Cargo.toml
Expand Up @@ -43,6 +43,8 @@ jormungandr-lib = {path = "../jormungandr-lib"}
jormungandr-automation = { path = "../testing/jormungandr-automation" }
jormungandr-integration-tests = { path = "../testing/jormungandr-integration-tests" }
thor = { path = "../testing/thor" }
jortestkit = { git = "https://github.com/input-output-hk/jortestkit.git", branch = "master" }


cardano-legacy-address = {git = "https://github.com/input-output-hk/chain-libs.git", branch = "master"}
chain-addr = {git = "https://github.com/input-output-hk/chain-libs.git", branch = "master"}
Expand Down
2 changes: 1 addition & 1 deletion explorer/src/api/graphql/config_param.rs
Expand Up @@ -502,7 +502,7 @@ pub enum ConfigParam {

#[derive(SimpleObject)]
pub struct ConfigParams {
config_params: Vec<ConfigParam>,
pub config_params: Vec<ConfigParam>,
}

impl From<&ConfigParamLib> for ConfigParam {
Expand Down
24 changes: 24 additions & 0 deletions explorer/src/api/graphql/mod.rs
Expand Up @@ -541,6 +541,30 @@ impl Block {
format!("{}", self.hash)
}

/// Initial bootstrap config params (initial fragments), only present in Block0
pub async fn configuration_params(
&self,
context: &Context<'_>,
) -> FieldResult<Option<config_param::ConfigParams>> {
let explorer_block = self
.fetch_explorer_block(&extract_context(context).db)
.await?;

let transactions: Vec<&ExplorerTransaction> =
explorer_block.transactions.values().collect();

for tx in transactions.iter() {
if tx.config_params.is_some() {
let tx = match &tx.config_params {
Some(tx) => tx,
None => return Ok(None),
};
return Ok(Some(config_param::ConfigParams::from(tx)));
}
}
Ok(None)
}

/// Date the Block was included in the blockchain
pub async fn date(&self, context: &Context<'_>) -> FieldResult<BlockDate> {
self.fetch_explorer_block(&extract_context(context).db)
Expand Down
13 changes: 12 additions & 1 deletion explorer/src/db/indexing.rs
Expand Up @@ -8,7 +8,7 @@ use chain_impl_mockchain::{
certificate::{
Certificate, ExternalProposalId, PoolId, PoolRegistration, PoolRetirement, VotePlanId,
},
fragment::{Fragment, FragmentId},
fragment::{ConfigParams, Fragment, FragmentId},
header::{BlockDate, ChainLength, Epoch, HeaderId as HeaderHash},
key::BftLeaderId,
transaction::{InputEnum, TransactionSlice, Witness},
Expand Down Expand Up @@ -70,6 +70,7 @@ pub struct ExplorerTransaction {
pub outputs: Vec<ExplorerOutput>,
pub certificate: Option<Certificate>,
pub offset_in_block: u32,
pub config_params: Option<ConfigParams>,
}

/// Unified Input representation for utxo and account inputs as used in the graphql API
Expand Down Expand Up @@ -161,6 +162,14 @@ impl ExplorerBlock {
let fragment_id = fragment.id();
let offset: u32 = offset.try_into().unwrap();
let metx = match fragment {
Fragment::Initial(config) => Some(ExplorerTransaction {
id: fragment_id,
inputs: vec![],
outputs: vec![],
certificate: None,
offset_in_block: offset,
config_params: Some(config.clone()),
}),
Fragment::Transaction(tx) => {
let tx = tx.as_slice();
Some(ExplorerTransaction::from(
Expand Down Expand Up @@ -277,6 +286,7 @@ impl ExplorerBlock {
outputs,
certificate: None,
offset_in_block: offset,
config_params: None,
})
}
_ => None,
Expand Down Expand Up @@ -429,6 +439,7 @@ impl ExplorerTransaction {
outputs: new_outputs,
certificate,
offset_in_block,
config_params: None,
}
}

Expand Down
1 change: 1 addition & 0 deletions explorer/src/main.rs
Expand Up @@ -63,6 +63,7 @@ async fn main() -> Result<(), Error> {
let mut settings = Settings::load()?;
let (guards, log_init_messages) = settings.log_settings.take().unwrap().init_log()?;

//tracing_subscriber::fmt::init();
let init_span = span!(Level::TRACE, "task", kind = "init");
let _enter = init_span.enter();
tracing::info!("Starting explorer");
Expand Down
9 changes: 9 additions & 0 deletions explorer/src/tests.rs
Expand Up @@ -65,6 +65,15 @@ pub fn get_valid_block(explorer: &Explorer, genesis_block: Hash) {
.block
.id;
assert_eq!(block_id, genesis_block.to_string());

let config_params = explorer
.block(genesis_block)
.unwrap()
.data
.unwrap()
.block
.configuration_params
.unwrap();
}

#[test]
Expand Down
@@ -1,5 +1,94 @@
query Block($id: String!) {
block(id:$id){
id
id
__typename
configurationParams { configParams {...configParam}}
}
}

fragment configParam on ConfigParam
{
__typename
... on Block0Date { block0Date }
... on Discrimination { discrimination }
... on ConsensusType { consensusType }
... on SlotsPerEpoch { slotsPerEpoch }
... on SlotDuration { slotDuration}
... on EpochStabilityDepth { epochStabilityDepth }
... on Milli { milli}
... on BlockContentMaxSize { blockContentMaxSize}
... on AddBftLeader { addBftLeader{ id }}
... on RemoveBftLeader { removeBftLeader { id }}
... on LinearFee {
constant
coefficient
certificate
perCertificateFees {
certificatePoolRegistration
certificateStakeDelegation
certificateOwnerStakeDelegation
}
perVoteCertificateFees {
certificateVotePlan
certificateVoteCast
}}
... on ProposalExpiration{ proposalExpiration }
... on KesUpdateSpeed { kesUpdateSpeed}
... on TreasuryAdd { treasuryAdd }
... on TreasuryParams { treasuryParams {
fixed
ratio {
numerator
denominator
}
maxLimit
}}
... on RewardPot { rewardPot }
... on RewardParams { rewardParams {
__typename
... on LinearRewardParams{
constant
ratio {
numerator
denominator
}
epochStart
epochRate
}
... on HalvingRewardParams {
constant
ratio {
numerator
denominator
}
epochStart
epochRate
}
}}
... on PerCertificateFee{
certificatePoolRegistration
certificateStakeDelegation
certificateOwnerStakeDelegation
}
... on FeesInTreasury { feesInTreasury}
... on RewardLimitNone { rewardLimitNone }
... on RewardLimitByAbsoluteStake { rewardLimitByAbsoluteStake {
numerator
denominator
}}
... on PoolRewardParticipationCapping { min max }
... on AddCommitteeId { addCommitteeId}
... on RemoveCommitteeId { removeCommitteeId }
... on PerVoteCertificateFee {
certificateVotePlan
certificateVoteCast
}
... on TransactionMaxExpiryEpochs { transactionMaxExpiryEpochs }
}







Empty file.
Expand Up @@ -21,6 +21,9 @@ type Block {
"""The Block unique identifier"""
id: String!

"""Initial bootstrap fragments, only present in Block0"""
configurationParams: ConfigParams

"""Date the Block was included in the blockchain"""
date: BlockDate!

Expand All @@ -44,7 +47,10 @@ type BlockConnection {
pageInfo: PageInfo!

"""A list of edges."""
edges: [BlockEdge]
edges: [BlockEdge!]!

"""A list of nodes."""
nodes: [Block!]!
totalCount: Int!
}

Expand All @@ -60,11 +66,11 @@ type BlockDate {

"""An edge in a connection."""
type BlockEdge {
"""The item at the end of the edge"""
node: Block!

"""A cursor for use in pagination"""
cursor: String!

"""The item at the end of the edge"""
node: Block!
}

type Branch {
Expand Down Expand Up @@ -222,17 +228,20 @@ type PoolConnection {
pageInfo: PageInfo!

"""A list of edges."""
edges: [PoolEdge]
edges: [PoolEdge!]!

"""A list of nodes."""
nodes: [Pool!]!
totalCount: Int!
}

"""An edge in a connection."""
type PoolEdge {
"""The item at the end of the edge"""
node: Pool!

"""A cursor for use in pagination"""
cursor: String!

"""The item at the end of the edge"""
node: Pool!
}

scalar PoolId
Expand Down Expand Up @@ -283,7 +292,7 @@ type Proposal {

"""
get the vote options range
this is the available range of choices to make for the given
proposal. all casted votes for this proposals ought to be in
within the given range
Expand Down Expand Up @@ -419,17 +428,20 @@ type TransactionConnection {
pageInfo: PageInfo!

"""A list of edges."""
edges: [TransactionEdge]
edges: [TransactionEdge!]!

"""A list of nodes."""
nodes: [Transaction!]!
totalCount: Int!
}

"""An edge in a connection."""
type TransactionEdge {
"""The item at the end of the edge"""
node: Transaction!

"""A cursor for use in pagination"""
cursor: String!

"""The item at the end of the edge"""
node: Transaction!
}

type TransactionInput {
Expand Down Expand Up @@ -534,17 +546,20 @@ type VotePlanStatusConnection {
pageInfo: PageInfo!

"""A list of edges."""
edges: [VotePlanStatusEdge]
edges: [VotePlanStatusEdge!]!

"""A list of nodes."""
nodes: [VotePlanStatus!]!
totalCount: Int!
}

"""An edge in a connection."""
type VotePlanStatusEdge {
"""The item at the end of the edge"""
node: VotePlanStatus!

"""A cursor for use in pagination"""
cursor: String!

"""The item at the end of the edge"""
node: VotePlanStatus!
}

type VoteProposalStatus {
Expand All @@ -564,21 +579,25 @@ type VoteStatusConnection {
pageInfo: PageInfo!

"""A list of edges."""
edges: [VoteStatusEdge]
edges: [VoteStatusEdge!]!

"""A list of nodes."""
nodes: [VoteStatus!]!
totalCount: Int!
}

"""An edge in a connection."""
type VoteStatusEdge {
"""The item at the end of the edge"""
node: VoteStatus!

"""A cursor for use in pagination"""
cursor: String!

"""The item at the end of the edge"""
node: VoteStatus!
}

type VoteTally {
votePlan: VotePlanId!
}

scalar Weight

@@ -1,6 +1,7 @@
query TransactionById($id: String!){
transaction(id: $id) {
id

blocks{id date{...blockDate}}
inputs{amount address{id}}
outputs{amount address{id}}}}
Expand Down
Expand Up @@ -152,7 +152,7 @@ impl Drop for ExplorerProcess {
);

std::fs::write(logs_dir.join("explorer.log"), output.stdout)
.unwrap_or_else(|e| eprint!("Could not write explorer logs to disk: {}", e));
.unwrap_or_else(|e| eprint!("Could not write explorer logs to disk: {} ", e));
}
}
}
Expand Down

0 comments on commit 0782197

Please sign in to comment.