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

Deployment to crates.io #610

Merged
merged 10 commits into from
Nov 24, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ runs:
with:
name: mithril-distribution-${{ runner.os }}-${{ runner.arch }}
path: |
target/release/libmithril.*
target/release/libmithril_stm.*
target/release/libmithril_common.*
target/release/mithril-aggregator
target/release/mithril-aggregator.exe
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: doc
args: --no-deps -p mithril -p mithril-common -p mithril-aggregator -p mithril-signer -p mithril-client
args: --no-deps -p mithril-stm -p mithril-common -p mithril-aggregator -p mithril-signer -p mithril-client

- name: Publish Mithril-rust-doc
uses: actions/upload-artifact@v3
Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,63 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}

check-deploy-crates-io:
runs-on: ubuntu-22.04
outputs:
should-deploy: ${{ steps.check_version.outputs.should_deploy }}
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Check crate latest version
id: check_version
run: |
LATEST_REMOTE_VERSION=$(wget -q -O - https://crates.io/api/v1/crates/mithril-stm | jq -r '.crate.newest_version')
LOCAL_VERSION=$(cargo metadata --quiet --no-deps | jq -r '.packages[] | select(.name=="mithril-stm") | .version')
echo "Latest crate.io version: $LATEST_REMOTE_VERSION"
echo "Local version: $LOCAL_VERSION"

if [ "$LOCAL_VERSION" != "$LATEST_REMOTE_VERSION" ]; then
echo "Local version is newer than remote version: we will publish to crates.io"
echo "should_deploy=true" >> $GITHUB_OUTPUT
else
echo "Local version and remote version are the same: no need to publish to crates.io"
echo "should_deploy=false" >> $GITHUB_OUTPUT
fi

deploy-crates-io:
runs-on: ubuntu-22.04
needs: check-deploy-crates-io
if: needs.check-deploy-crates-io.outputs.should-deploy == 'true'
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable

- name: Cargo publish dry run
uses: actions-rs/cargo@v1
with:
command: publish
args: -p mithril-stm --dry-run
Comment on lines +101 to +105
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we running two times with --dry-run? With and without the token?

Copy link
Member Author

Choose a reason for hiding this comment

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

We will remove the second --dry-run once we have a working CRATES_IO_API_TOKEN (we keep the dry-run to prevent the workflow from failing at this last step) 👍


- name: Cargo package list
uses: actions-rs/cargo@v1
with:
command: package
args: -p mithril-stm --list

# We use the '--dry-run' arg until we have a valid CRATES_IO_API_TOKEN to avoid the workflow to crash
- name: Cargo publish
uses: actions-rs/cargo@v1
with:
command: publish
args: -p mithril-stm --token ${{ secrets.CRATES_IO_API_TOKEN }} --dry-run

deploy-release:
strategy:
fail-fast: false
Expand Down
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
mithril.cabal
.stack-work/
.direnv/
mithril-core/c-tests/tests
mithril-core/c-tests/tests.dSYM/
mithril-stm/c-tests/tests
mithril-stm/c-tests/tests.dSYM/
*~
mithril-core/proptest-regressions/
mithril-stm/proptest-regressions/
*.dump
.tmp/
.s.PGSQL*
Expand Down
46 changes: 23 additions & 23 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ members = [
"mithril-aggregator",
"mithril-client",
"mithril-common",
"mithril-core",
"mithril-signer",
"mithril-stm",
"mithril-test-lab/mithril-end-to-end"
]

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
COMPONENTS = mithril-common mithril-core mithril-aggregator mithril-client mithril-signer demo/protocol-demo mithril-test-lab
COMPONENTS = mithril-common mithril-stm mithril-aggregator mithril-client mithril-signer demo/protocol-demo mithril-test-lab
GOALS := $(or $(MAKECMDGOALS),all)

.PHONY: $(GOALS) $(COMPONENTS)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ This repository is sliced in the following parts:

* [**Mithril Common**](./mithril-common): this is the **common** library that is used by the **Mithril Network** nodes.

* [**Mithril Core**](./mithril-core): the **core** library that implements **Mithril** protocol cryptographic engine.
* [**Mithril STM**](./mithril-stm): the **core** library that implements **Mithril** protocol cryptographic engine.

* [**Mithril Explorer**](./mithril-explorer): the **explorer** website that connects to a **Mithril Aggregator** and displays its **Certificate Chain**.

Expand Down
2 changes: 1 addition & 1 deletion docs/root/manual/developer-docs/references.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ For more information about the **Mithril Protocol**, please refer to the [About
| Dependency | Description | Source Repository | Rust Documentation | REST API
|------------|-------------|:-----------------:|:------------------:|:------------:|
| **Mithril Common** | This is the **common** library that is used by the **Mithril Network** nodes. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/tree/main/mithril-common) | [:arrow_upper_right:](https://mithril.network/rust-doc/mithril_common/index.html) | -
| **Mithril Core** | The **core** library that implements **Mithril** protocol cryptographic engine. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/tree/main/mithril-core) | [:arrow_upper_right:](https://mithril.network/rust-doc/mithril/index.html) | -
| **Mithril STM** | The **core** library that implements **Mithril** protocol cryptographic engine. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/tree/main/mithril-stm) | [:arrow_upper_right:](https://mithril.network/rust-doc/mithril_stm/index.html) | -
| **Mithril Aggregator** | The node of the **Mithril Network** responsible for collecting individual signatures from the **Mithril Signers** and aggregate them into a multisignature. The **Mithril Aggregator** uses this ability to provide certified snapshots of the **Cardano** blockchain. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/tree/main/mithril-aggregator) | [:arrow_upper_right:](https://mithril.network/rust-doc/mithril_aggregator/index.html) | [:arrow_upper_right:](/aggregator-api)
| **Mithril Client** | The node of the **Mithril Network** responsible for restoring the **Cardano** blockchain on an empty node from a certified snapshot. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/tree/main/mithril-client) | [:arrow_upper_right:](https://mithril.network/rust-doc/mithril_client/index.html) | -
| **Mithril Signer** | The node of the **Mithril Network** responsible for producing individual signatures that are collected and aggregated by the **Mithril Aggregator**. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/tree/main/mithril-signer) | [:arrow_upper_right:](https://mithril.network/rust-doc/mithril_signer/index.html) | -
Expand Down
4 changes: 2 additions & 2 deletions mithril-aggregator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ RUN adduser --no-create-home --disabled-password appuser
WORKDIR /app

# Copy local dependencies
COPY mithril-core/ /mithril-core/
COPY Cargo.lock /mithril-core/
COPY mithril-stm/ /mithril-stm/
COPY Cargo.lock /mithril-stm/
COPY mithril-common/ /mithril-common/
COPY Cargo.lock /mithril-common/

Expand Down
2 changes: 1 addition & 1 deletion mithril-aggregator/src/multi_signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub enum ProtocolError {
#[error("codec error: '{0}'")]
Codec(String),

/// Mithril Core library returned an error.
/// Mithril STM library returned an error.
#[error("core error: '{0}'")]
Core(String),

Expand Down
4 changes: 2 additions & 2 deletions mithril-client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ RUN adduser --no-create-home --disabled-password appuser
WORKDIR /app

# Copy local dependencies
COPY mithril-core/ /mithril-core/
COPY Cargo.lock /mithril-core/
COPY mithril-stm/ /mithril-stm/
COPY Cargo.lock /mithril-stm/
COPY mithril-common/ /mithril-common/
COPY Cargo.lock /mithril-common/

Expand Down
6 changes: 3 additions & 3 deletions mithril-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ warp = "0.3"

[target.'cfg(not(windows))'.dependencies]
# non-windows: use default rug backend
mithril = { path = "../mithril-core" }
mithril-stm = { path = "../mithril-stm" }

[target.'cfg(windows)'.dependencies]
# Windows doesn't support rug backend, fallback to num-integer
mithril = { path = "../mithril-core", default-features = false, features = ["num-integer-backend"] }
mithril-stm = { path = "../mithril-stm", default-features = false, features = ["num-integer-backend"] }

[dev-dependencies]
slog-scope = "4.4.0"

[features]
portable = ["mithril/portable"]
portable = ["mithril-stm/portable"]
test_only = []
allow_skip_signer_certification = []
14 changes: 7 additions & 7 deletions mithril-common/src/crypto_helper/cardano/key_certification.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
//! API for mithril key certification.
//! Includes the wrappers for StmInitializer and KeyReg, and ProtocolRegistrationErrorWrapper.
//! These wrappers allows keeping mithril-core agnostic to Cardano, while providing some
//! guarantees that mithril-core will not be misused in the context of Cardano.
//! These wrappers allows keeping mithril-stm agnostic to Cardano, while providing some
//! guarantees that mithril-stm will not be misused in the context of Cardano.

use crate::crypto_helper::cardano::{OpCert, ParseError, SerDeShelleyFileFormat};
use crate::crypto_helper::types::{
ProtocolPartyId, ProtocolSignerVerificationKey, ProtocolSignerVerificationKeySignature,
ProtocolStakeDistribution,
};

use mithril::key_reg::{ClosedKeyReg, KeyReg};
use mithril::stm::{Stake, StmInitializer, StmParameters, StmSigner, StmVerificationKeyPoP};
use mithril::RegisterError;
use mithril_stm::key_reg::{ClosedKeyReg, KeyReg};
use mithril_stm::stm::{Stake, StmInitializer, StmParameters, StmSigner, StmVerificationKeyPoP};
use mithril_stm::RegisterError;

use blake2::{
digest::{consts::U32, FixedOutput},
Expand Down Expand Up @@ -79,7 +79,7 @@ pub enum ProtocolInitializerErrorWrapper {
#[error("KES key cannot be updated for period {0}")]
KesUpdate(KESPeriod),
}
/// Wrapper structure for [MithrilCore:StmInitializer](mithril::stm::StmInitializer).
/// Wrapper structure for [MithrilStm:StmInitializer](mithril_stm::stm::StmInitializer).
/// It now obtains a KES signature over the Mithril key. This allows the signers prove
/// their correct identity with respect to a Cardano PoolID.
#[derive(Debug, Clone, Serialize, Deserialize)]
Expand All @@ -88,7 +88,7 @@ pub struct StmInitializerWrapper {
kes_signature: Option<ProtocolSignerVerificationKeySignature>, // todo: The option is ONLY for a smooth transition. We have to remove this.
}

/// Wrapper structure for [MithrilCore:KeyReg](mithril::key_reg::KeyReg).
/// Wrapper structure for [MithrilStm:KeyReg](mithril_stm::key_reg::KeyReg).
/// The wrapper not only contains a map between `Mithril vkey <-> Stake`, but also
/// a map `PoolID <-> Stake`. This information is recovered from the node state, and
/// is used to verify the identity of a Mithril signer. Furthermore, the `register` function
Expand Down
2 changes: 1 addition & 1 deletion mithril-common/src/crypto_helper/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Tools and types to abstract the use of the [Mithril Core library](https://mithril.network/rust-doc/mithril/index.html)
//! Tools and types to abstract the use of the [Mithril STM library](https://mithril.network/rust-doc/mithril_stm/index.html)

mod cardano;
mod codec;
Expand Down
2 changes: 1 addition & 1 deletion mithril-common/src/crypto_helper/tests_setup.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Test data builders for Mithril Core types, for testing purpose.
//! Test data builders for Mithril STM types, for testing purpose.
use super::cardano::ColdKeyGenerator;
use super::{genesis::*, key_encode_hex, types::*, OpCert, SerDeShelleyFileFormat};
use crate::certificate_chain::CertificateGenesisProducer;
Expand Down
36 changes: 18 additions & 18 deletions mithril-common/src/crypto_helper/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ use crate::crypto_helper::cardano::{
KeyRegWrapper, ProtocolRegistrationErrorWrapper, StmInitializerWrapper,
};

use mithril::stm::{
use mithril_stm::stm::{
Index, Stake, StmAggrSig, StmAggrVerificationKey, StmClerk, StmParameters, StmSig, StmSigner,
StmVerificationKeyPoP,
};
use mithril::AggregationError;
use mithril_stm::AggregationError;

#[cfg(any(test, feature = "allow_skip_signer_certification"))]
use mithril::{key_reg::KeyReg, stm::StmInitializer};
use mithril_stm::{key_reg::KeyReg, stm::StmInitializer};

use blake2::{digest::consts::U32, Blake2b};
use ed25519_dalek;
Expand All @@ -24,43 +24,43 @@ type D = Blake2b<U32>;
/// The id of a mithril party.
pub type ProtocolPartyId = String;

/// Alias of [MithrilCore:Stake](type@mithril::stm::Stake).
/// Alias of [MithrilStm:Stake](type@mithril_stm::stm::Stake).
pub type ProtocolStake = Stake;

/// A list of [Party Id][ProtocolPartyId] associated with its [Stake][ProtocolStake].
pub type ProtocolStakeDistribution = Vec<(ProtocolPartyId, ProtocolStake)>;

/// Alias of [MithrilCore::StmParameters](struct@mithril::stm::StmParameters).
/// Alias of [MithrilStm::StmParameters](struct@mithril_stm::stm::StmParameters).
pub type ProtocolParameters = StmParameters;

/// Alias of [MithrilCore::Index](type@mithril::stm::Index).
/// Alias of [MithrilStm::Index](type@mithril_stm::stm::Index).
pub type ProtocolLotteryIndex = Index;

/// Alias of [MithrilCore:StmSigner](struct@mithril::stm::StmSigner).
/// Alias of [MithrilStm:StmSigner](struct@mithril_stm::stm::StmSigner).
pub type ProtocolSigner = StmSigner<D>;

/// Alias of a wrapper of [MithrilCore:StmInitializer](struct@mithril::stm::StmInitializer).
/// Alias of a wrapper of [MithrilStm:StmInitializer](struct@mithril_stm::stm::StmInitializer).
pub type ProtocolInitializer = StmInitializerWrapper;

/// Alias of [MithrilCore:StmClerk](struct@mithril::stm::StmClerk).
/// Alias of [MithrilStm:StmClerk](struct@mithril_stm::stm::StmClerk).
pub type ProtocolClerk = StmClerk<D>;

/// Alias of a wrapper of [MithrilCore:KeyReg](struct@mithril::key_reg::KeyReg).
/// Alias of a wrapper of [MithrilStm:KeyReg](struct@mithril_stm::key_reg::KeyReg).
pub type ProtocolKeyRegistration = KeyRegWrapper;

/// Alias of [MithrilCore:StmSig](struct@mithril::stm::StmSig).
/// Alias of [MithrilStm:StmSig](struct@mithril_stm::stm::StmSig).
pub type ProtocolSingleSignature = StmSig;

/// Alias of [MithrilCore:StmAggrSig](struct@mithril::stm::StmAggrSig).
/// Alias of [MithrilStm:StmAggrSig](struct@mithril_stm::stm::StmAggrSig).
pub type ProtocolMultiSignature = StmAggrSig<D>;

/// Alias of [MithrilCore:StmVerificationKeyPoP](type@mithril::stm::StmVerificationKeyPoP).
/// Alias of [MithrilStm:StmVerificationKeyPoP](type@mithril_stm::stm::StmVerificationKeyPoP).
pub type ProtocolSignerVerificationKey = StmVerificationKeyPoP;

/// Alias of [KES:Sum6KesSig](https://github.com/input-output-hk/kes/blob/master/src/kes.rs).
pub type ProtocolSignerVerificationKeySignature = Sum6KesSig;

/// Alias of [MithrilCore:StmAggrVerificationKey](struct@mithril::stm::StmAggrVerificationKey).
/// Alias of [MithrilStm:StmAggrVerificationKey](struct@mithril_stm::stm::StmAggrVerificationKey).
pub type ProtocolAggregateVerificationKey = StmAggrVerificationKey<D>;

/// Alias of [Ed25519:PublicKey](https://docs.rs/ed25519-dalek/latest/ed25519_dalek/struct.PublicKey.html).
Expand All @@ -73,17 +73,17 @@ pub type ProtocolGenesisSecretKey = ed25519_dalek::SecretKey;
pub type ProtocolGenesisSignature = ed25519_dalek::Signature;

// Error alias
/// Alias of a wrapper of [MithrilCore:RegisterError](enum@mithril::RegisterError).
/// Alias of a wrapper of [MithrilStm:RegisterError](enum@mithril_stm::RegisterError).
pub type ProtocolRegistrationError = ProtocolRegistrationErrorWrapper;

/// Alias of [MithrilCore:AggregationError](enum@mithril::AggregationError).
/// Alias of [MithrilStm:AggregationError](enum@mithril_stm::AggregationError).
pub type ProtocolAggregationError = AggregationError;

// Test only
/// (Test only) Alias of [MithrilCore:StmInitializer](struct@mithril::stm::StmInitializer).
/// (Test only) Alias of [MithrilStm:StmInitializer](struct@mithril_stm::stm::StmInitializer).
#[cfg(any(test, feature = "allow_skip_signer_certification"))]
pub type ProtocolInitializerNotCertified = StmInitializer;

/// (Test only) Alias of [MithrilCore:KeyReg](struct@mithril::key_reg::KeyReg). (Test only)
/// (Test only) Alias of [MithrilStm:KeyReg](struct@mithril_stm::key_reg::KeyReg). (Test only)
#[cfg(any(test, feature = "allow_skip_signer_certification"))]
pub type ProtocolKeyRegistrationNotCertified = KeyReg;
Loading