Skip to content

Commit

Permalink
Merge master next into master
Browse files Browse the repository at this point in the history
introducint breaking changes since 0.6.x family
  • Loading branch information
NicolasDP committed Oct 22, 2019
2 parents 236698a + e6610fc commit 6cf8884
Show file tree
Hide file tree
Showing 31 changed files with 623 additions and 397 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ branches:
# release tags
- /^v\d+\.\d+\.\d+.*$/
- master
- master-next

notifications:
email:
Expand Down
262 changes: 113 additions & 149 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ branches:
# Release tags
- /^v\d+\.\d+\.\d+.*$/
- master
- master-next

notifications:
- provider: Email
Expand Down
2 changes: 1 addition & 1 deletion chain-deps
Submodule chain-deps updated 37 files
+14 −0 chain-impl-mockchain/src/accounting/account/account_state.rs
+12 −251 chain-impl-mockchain/src/block/builder.rs
+0 −44 chain-impl-mockchain/src/block/cstruct.rs
+8 −412 chain-impl-mockchain/src/block/header.rs
+89 −31 chain-impl-mockchain/src/block/mod.rs
+0 −129 chain-impl-mockchain/src/block/version.rs
+8 −4 chain-impl-mockchain/src/fragment/content.rs
+3 −0 chain-impl-mockchain/src/fragment/mod.rs
+210 −0 chain-impl-mockchain/src/header/builder.rs
+100 −0 chain-impl-mockchain/src/header/components.rs
+419 −0 chain-impl-mockchain/src/header/cstruct.rs
+38 −0 chain-impl-mockchain/src/header/deconstruct.rs
+27 −0 chain-impl-mockchain/src/header/eval.rs
+382 −0 chain-impl-mockchain/src/header/header.rs
+20 −0 chain-impl-mockchain/src/header/mod.rs
+94 −0 chain-impl-mockchain/src/header/version.rs
+7 −1 chain-impl-mockchain/src/leadership/bft.rs
+37 −20 chain-impl-mockchain/src/leadership/genesis/mod.rs
+9 −4 chain-impl-mockchain/src/leadership/mod.rs
+10 −9 chain-impl-mockchain/src/ledger/ledger.rs
+2 −0 chain-impl-mockchain/src/ledger/tests/mod.rs
+427 −0 chain-impl-mockchain/src/ledger/tests/transaction_tests.rs
+95 −0 chain-impl-mockchain/src/ledger/tests/update_tests.rs
+1 −0 chain-impl-mockchain/src/lib.rs
+30 −12 chain-impl-mockchain/src/multiverse.rs
+13 −21 chain-impl-mockchain/src/testing/arbitrary/update_proposal.rs
+20 −12 chain-impl-mockchain/src/testing/builders/block_builder.rs
+2 −0 chain-impl-mockchain/src/testing/builders/mod.rs
+3 −3 chain-impl-mockchain/src/testing/builders/tx_builder.rs
+2 −2 chain-impl-mockchain/src/testing/builders/tx_cert_builder.rs
+105 −0 chain-impl-mockchain/src/testing/builders/update_builder.rs
+4 −4 chain-impl-mockchain/src/testing/builders/witness_builder.rs
+13 −1 chain-impl-mockchain/src/testing/data/address.rs
+2 −2 chain-impl-mockchain/src/testing/data/leader.rs
+4 −4 chain-impl-mockchain/src/testing/ledger.rs
+8 −8 chain-impl-mockchain/src/transaction/witness.rs
+388 −70 chain-impl-mockchain/src/update.rs
25 changes: 22 additions & 3 deletions doc/jcli/rest.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,28 @@ YAML printed on success

```yaml
---
blockRecvCnt: 7 # Blocks received by node
txRecvCnt: 90 # Transactions received by node
uptime: 2101 # Node uptitme in seconds
# Number of blocks received by node
blockRecvCnt: 1102
# The Epoch and slot Number of the block (optional)
lastBlockDate: "20.29"
# Sum of all fee values in all transactions in last block
lastBlockFees: 534
# The block hash, it's unique identifier in the blockchain (optional)
lastBlockHash: b9597b45a402451540e6aabb58f2ee4d65c67953b338e04c52c00aa0886bd1f0
# The block number, in order, since the block0 (optional)
lastBlockHeight: 202901
# Sum of all input values in all transactions in last block
lastBlockSum: 51604
# When last block was created, not set if none was created yet (optional)
lastBlockTime: 2019-08-12T11:20:52.316544007+00:00
# Number of transactions in last block
lastBlockTx: 2
# State of the node
state: Running
# Number of transactions received by node
txRecvCnt: 5440
# Node uptime in seconds
uptime: 20032
```
## Whole UTXO
Expand Down
32 changes: 18 additions & 14 deletions doc/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -422,16 +422,25 @@ paths:
application/json:
schema:
type: object
required: [blockRecvCnt, lastBlockFees, lastBlockSum, lastBlockTx, txRecvCnt, uptime]
required: [blockRecvCnt, lastBlockFees, lastBlockSum, lastBlockTx, state, txRecvCnt, uptime]
properties:
blockRecvCnt:
description: Number of blocks received by node
type: integer
minimum: 0
lastBlockDate:
description: The Epoch and slot Number of the block
type: string
lastBlockFees:
description: Sum of all fee values in all transactions in last block
type: integer
minimum: 0
lastBlockHash:
description: The block hash, it's unique identifier in the blockchain
type: string
lastBlockHeight:
description: The block number, in order, since the block0
type: number
lastBlockSum:
description: Sum of all input values in all transactions in last block
type: integer
Expand All @@ -444,6 +453,10 @@ paths:
description: Number of transactions in last block
type: integer
minimum: 0
state:
description: State of the node
type: string
enum: [StartingRestServer, PreparingStorage, PreparingBlock0, Bootstrapping, StartingWorkers, Running]
txRecvCnt:
description: Number of transactions received by node
type: integer
Expand All @@ -452,26 +465,17 @@ paths:
description: Node uptime in seconds
type: integer
minimum: 0
lastBlockDate:
description: The Epoch and slot Number of the block.
type: string
lastBlockHeight:
description: The block number, in order, since the block0
type: number
minimum: 0
lastBlockHash:
description: The block hash, it's unique identifier in the blockchain.
type: string
example: |
{
"blockRecvCnt": 1102,
"lastBlockDate": "20.29",
"lastBlockFees": 534,
"lastBlockHash": "b9597b45a402451540e6aabb58f2ee4d65c67953b338e04c52c00aa0886bd1f0",
"lastBlockHeight": 202901,
"lastBlockSum": 51604,
"lastBlockTime": "2019-08-12T11:20:52.316544007+00:00",
"lastBlockDate": "20.29",
"lastBlockHeight": 202901,
"lastBlockHash": "b9597b45a402451540e6aabb58f2ee4d65c67953b338e04c52c00aa0886bd1f0",
"lastBlockTx": 2,
"state": "Running",
"txRecvCnt": 5440,
"uptime": 20032
}
Expand Down
2 changes: 1 addition & 1 deletion jcli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "jcli"
version = "0.6.5"
version = "0.6.999-dev"
authors = [ "[email protected]" ]
license = "MIT OR Apache-2.0"
repository = "https://github.com/input-output-hk/jormungandr"
Expand Down
4 changes: 2 additions & 2 deletions jcli/src/jcli_app/transaction/mk_witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use chain_core::property::Serialize as _;
use chain_crypto::{AsymmetricKey, Ed25519Bip32, SecretKey};
use chain_impl_mockchain::{
account::SpendingCounter,
block::HeaderHash,
header::HeaderId,
transaction::{TransactionSignDataHash, Witness},
};
use jcli_app::transaction::Error;
Expand Down Expand Up @@ -32,7 +32,7 @@ pub struct MkWitness {

/// the hash of the block0, the first block of the blockchain
#[structopt(long = "genesis-block-hash", parse(try_from_str))]
pub genesis_block_hash: HeaderHash,
pub genesis_block_hash: HeaderId,

/// value is mandatory is `--type=account' It is the counter for
/// every time the account is being utilized.
Expand Down
2 changes: 1 addition & 1 deletion jormungandr-integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "jormungandr-integration-tests"
version = "0.6.5"
version = "0.6.999-dev"
authors = [ "[email protected]" ]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion jormungandr-lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "jormungandr-lib"
version = "0.6.5"
version = "0.6.999-dev"
authors = ["[email protected]"]
edition = "2018"

Expand Down
20 changes: 15 additions & 5 deletions jormungandr-lib/src/interfaces/block0_configuration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ pub use self::leader_id::ConsensusLeaderId;
pub use self::number_of_slots_per_epoch::NumberOfSlotsPerEpoch;
pub use self::slots_duration::SlotDuration;
use chain_impl_mockchain::{
block::{Block, BlockBuilder, ContentsBuilder},
fragment::Fragment,
block::{self, Block},
fragment::{ContentsBuilder, Fragment},
header::{BlockDate, BlockVersion, Header},
};
use serde::{Deserialize, Serialize};
use std::convert::TryFrom as _;
use std::convert::{Infallible, TryFrom as _};

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
Expand Down Expand Up @@ -72,8 +73,17 @@ impl Block0Configuration {
self.blockchain_configuration.clone().into(),
));
content_builder.push_many(self.initial.iter().map(Fragment::from));
let builder = BlockBuilder::new(content_builder.into());
builder.make_genesis_block()
let content = content_builder.into();
block::builder(BlockVersion::Genesis, content, |hdr| {
let r: Result<Header, Infallible> = Ok(hdr
.set_genesis()
.set_date(BlockDate::first())
.to_unsigned_header()
.expect("internal error cannot build unsigned block")
.generalize());
r
})
.expect("internal error: block builder cannot return error")
}
}

Expand Down
2 changes: 1 addition & 1 deletion jormungandr-scenario-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "jormungandr-scenario-tests"
version = "0.6.5"
version = "0.6.999-dev"
authors = [ "[email protected]" ]
edition = "2018"

Expand Down
9 changes: 5 additions & 4 deletions jormungandr-scenario-tests/src/node.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::{scenario::settings::NodeSetting, style, Context, NodeAlias};
use bawawa::{Control, Process};
use chain_impl_mockchain::{
block::{Block, HeaderHash},
block::Block,
fragment::{Fragment, FragmentId},
header::HeaderId,
};
use indicatif::ProgressBar;
use jormungandr_lib::interfaces::{FragmentLog, FragmentStatus};
Expand Down Expand Up @@ -59,7 +60,7 @@ pub struct MemPoolCheck {
}

pub enum NodeBlock0 {
Hash(HeaderHash),
Hash(HeaderId),
File(PathBuf),
}

Expand Down Expand Up @@ -179,7 +180,7 @@ impl NodeController {
})
}

pub fn get_tip(&self) -> Result<HeaderHash> {
pub fn get_tip(&self) -> Result<HeaderId> {
let hash = self.get("tip")?.text()?;

let hash = hash.parse().chain_err(|| ErrorKind::InvalidHeaderHash)?;
Expand All @@ -189,7 +190,7 @@ impl NodeController {
Ok(hash)
}

pub fn get_block(&self, header_hash: &HeaderHash) -> Result<Block> {
pub fn get_block(&self, header_hash: &HeaderId) -> Result<Block> {
use chain_core::mempack::{ReadBuf, Readable as _};

let mut resp = self.get(&format!("block/{}", header_hash))?;
Expand Down
4 changes: 2 additions & 2 deletions jormungandr-scenario-tests/src/scenario/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
scenario::{settings::Settings, Blockchain, ContextChaCha, ErrorKind, Result, Topology},
style, MemPoolCheck, Node, NodeBlock0, NodeController, Wallet,
};
use chain_impl_mockchain::block::HeaderHash;
use chain_impl_mockchain::header::HeaderId;
use indicatif::{MultiProgress, ProgressBar};
use jormungandr_lib::interfaces::Value;
use std::{
Expand All @@ -29,7 +29,7 @@ pub struct Controller {
working_directory: PathBuf,

block0_file: PathBuf,
block0_hash: HeaderHash,
block0_hash: HeaderId,

progress_bar: Arc<MultiProgress>,
progress_bar_thread: Option<std::thread::JoinHandle<()>>,
Expand Down
3 changes: 2 additions & 1 deletion jormungandr-scenario-tests/src/scenario/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ pub use self::{
wallet::{Wallet, WalletAlias, WalletType},
};
pub use chain_impl_mockchain::{
block::{Block, ConsensusVersion, HeaderHash},
block::{Block, ConsensusVersion},
header::HeaderId,
value::Value,
};
pub use jormungandr_lib::interfaces::{NumberOfSlotsPerEpoch, SlotDuration};
Expand Down
2 changes: 1 addition & 1 deletion jormungandr/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "jormungandr"
version = "0.6.5"
version = "0.6.999-dev"
authors = [ "[email protected]" ]
license = "MIT OR Apache-2.0"
repository = "https://github.com/input-output-hk/jormungandr"
Expand Down
14 changes: 9 additions & 5 deletions jormungandr/src/blockcfg/mod.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
pub use network_core::gossip::Gossip;

pub use chain_impl_mockchain::{
block::{
Block, BlockBuilder, BlockDate, ChainLength, ConsensusVersion, Contents, ContentsBuilder,
Epoch, Header, HeaderContentEvalContext, HeaderHash, SlotId,
},
block::{Block, ConsensusVersion},
config::{self, Block0Date, ConfigParam},
fragment::{ConfigParams, Fragment, FragmentId},
fragment::{ConfigParams, Contents, ContentsBuilder, Fragment, FragmentId},
header::{
BlockDate, BlockVersion, ChainLength, Epoch, Header, HeaderBft, HeaderBftBuilder,
HeaderBuilder, HeaderBuilderNew, HeaderContentEvalContext, HeaderGenesisPraos,
HeaderGenesisPraosBuilder, HeaderId, HeaderSetConsensusSignature, SlotId,
},
leadership::{BftLeader, GenesisLeader, Leader, LeaderOutput, Leadership},
ledger::{Ledger, LedgerParameters, LedgerStaticParameters},
multiverse::Multiverse,
value::{Value, ValueError},
};
use std::time::{Duration, SystemTime};

pub type HeaderHash = HeaderId;

custom_error! {pub Block0Error
CannotParseEntity{source: config::Error} = "Block0 Initial settings: {source}",
Malformed{source: Block0Malformed} = "Block0 is invalid or malformed: {source}"
Expand Down
2 changes: 1 addition & 1 deletion jormungandr/src/blockchain/branch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl BranchData {
}

fn continue_with(&mut self, candidate: Arc<Ref>) -> bool {
if &self.reference.hash() == candidate.block_parent_hash() {
if self.reference.hash() == candidate.block_parent_hash() {
let _parent = self.update(candidate);
true
} else {
Expand Down
2 changes: 1 addition & 1 deletion jormungandr/src/blockchain/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ pub fn process_new_ref(
tip.clone()
.get_ref()
.and_then(move |tip_ref| {
if &tip_ref.hash() == candidate.block_parent_hash() {
if tip_ref.hash() == candidate.block_parent_hash() {
info!(logger, "update current branch tip");
A(A(tip.update_ref(candidate).map(|_| true)))
} else {
Expand Down
4 changes: 2 additions & 2 deletions jormungandr/src/blockchain/reference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ impl Ref {
}

/// access the reference's parent hash
pub fn block_parent_hash(&self) -> &HeaderHash {
pub fn block_parent_hash(&self) -> HeaderHash {
self.header().block_parent_hash()
}

/// retrieve the block date of the `Ref`
pub fn block_date(&self) -> &BlockDate {
pub fn block_date(&self) -> BlockDate {
self.header().block_date()
}

Expand Down
2 changes: 1 addition & 1 deletion jormungandr/src/explorer/indexing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl ExplorerBlock {
id,
transactions,
chain_length,
date: *block.header.block_date(),
date: block.header.block_date(),
parent_hash: block.parent_id(),
producer,
}
Expand Down
2 changes: 1 addition & 1 deletion jormungandr/src/explorer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ impl ExplorerDB {
let discrimination = self.blockchain_config.discrimination.clone();

multiverse
.get(*previous_block)
.get(previous_block)
.map_err(|_: Infallible| unreachable!())
.and_then(move |maybe_previous_state| match maybe_previous_state {
Some(state) => {
Expand Down
1 change: 0 additions & 1 deletion jormungandr/src/fragment/selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ impl FragmentSelectionAlgorithm for OldestFirst {
match ledger_simulation.apply_fragment(ledger_params, &fragment, metadata) {
Ok(ledger_new) => {
self.builder.push(fragment);

total += 1;
ledger_simulation = ledger_new;
}
Expand Down
Loading

0 comments on commit 6cf8884

Please sign in to comment.