Skip to content
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
3 changes: 3 additions & 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ sp-consensus = { default-features = false, git = "https://github.com/paritytech/
sp-std = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2603" }
substrate-test-runtime-client = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2603" }

whisky = { git = "https://github.com/midnightntwrk/whisky", branch = "wasm-bindgen-update" }

[profile.release]
panic = "unwind"

Expand Down
8 changes: 8 additions & 0 deletions changes/changed/bridge-toolkit-commands.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#toolkit

# Add commands for initiating bridge transfers.

Adds `bridge-transfer` command that submits transaction to Cardano. Transaction is from user wallet to ICS address and has metadata that encodes either: transfer to specified Midnight UserAddress, to reserve or invalid one (will end up in Treasury).

PR: https://github.com/midnightntwrk/midnight-node/pull/1340
Required for https://github.com/midnightntwrk/midnight-node/issues/1086
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ use cardano_serialization_lib::{Address, Language, PlutusData};
use hex_literal::hex;
use ogmios_client::{
query_ledger_state::{
PlutusCostModels, ProtocolParametersResponse, ReferenceScriptsCosts, ScriptExecutionPrices,
PlutusCostModels, ProtocolParametersResponse, ReferenceScriptsCosts,
ScriptExecutionPriceLimits, ScriptExecutionPrices,
},
types::{NativeScript, OgmiosBytesSize, OgmiosScript, OgmiosTx, OgmiosUtxo, OgmiosValue},
};
Expand Down Expand Up @@ -92,6 +93,16 @@ pub(crate) fn protocol_parameters() -> ProtocolParametersResponse {
stake_credential_deposit: OgmiosValue::new_lovelace(2000000),
max_value_size: OgmiosBytesSize { bytes: 5000 },
max_transaction_size: OgmiosBytesSize { bytes: 16384 },
max_block_body_size: OgmiosBytesSize { bytes: 65500 },
max_block_header_size: OgmiosBytesSize { bytes: 1200 },
max_execution_units_per_block: ScriptExecutionPriceLimits {
memory: 62000000,
cpu: 40000000000,
},
max_execution_units_per_transaction: ScriptExecutionPriceLimits {
memory: 14000000,
cpu: 10000000000,
},
min_utxo_deposit_coefficient: 4310,
script_execution_prices: ScriptExecutionPrices {
memory: fraction::Ratio::new_raw(577, 10000),
Expand All @@ -105,6 +116,7 @@ pub(crate) fn protocol_parameters() -> ProtocolParametersResponse {
max_collateral_inputs: 3,
collateral_percentage: 150,
min_fee_reference_scripts: ReferenceScriptsCosts { base: 15.0 },
min_stake_pool_cost: OgmiosValue::new_lovelace(0),
}
}

Expand Down
2 changes: 1 addition & 1 deletion partner-chains/toolkit/utils/ogmios-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub trait OgmiosClient {
) -> Result<T, OgmiosClientError>;
}

#[derive(Clone)]
#[derive(Clone, Debug)]
/// Enum representing the parameters for a JSON-RPC request to the Ogmios server.
pub enum OgmiosParams {
/// Represents positional parameters.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,16 @@ pub struct ProtocolParametersResponse {
pub stake_pool_deposit: OgmiosValue,
/// Amount of lovelace required to register a stake credential.
pub stake_credential_deposit: OgmiosValue,
/// Maximum block body size
pub max_block_body_size: OgmiosBytesSize,
/// Maximum block header size
pub max_block_header_size: OgmiosBytesSize,
/// Maximum size limit for the value field in transaction outputs.
pub max_value_size: OgmiosBytesSize,
/// Maximum size limit for the transaction body.
pub max_transaction_size: OgmiosBytesSize,
/// Minimal stake pool cost
pub min_stake_pool_cost: OgmiosValue,
/// Additional transaction fee per byte of output data (in lovelace). Also called coinsPerUTxOWord or coinsPerUTxOByte
pub min_utxo_deposit_coefficient: u64,
/// Pricing for Plutus script execution resources.
Expand All @@ -154,6 +160,10 @@ pub struct ProtocolParametersResponse {
pub collateral_percentage: u32,
/// Cost of reference scripts.
pub min_fee_reference_scripts: ReferenceScriptsCosts,
/// Per transaction limits
pub max_execution_units_per_transaction: ScriptExecutionPriceLimits,
/// Per block limits
pub max_execution_units_per_block: ScriptExecutionPriceLimits,
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Default)]
Expand All @@ -167,6 +177,15 @@ pub struct ScriptExecutionPrices {
pub cpu: fraction::Ratio<u64>,
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Default)]
/// Represents the pricing for Plutus script execution limits.
pub struct ScriptExecutionPriceLimits {
/// Limit of memory unit.s
pub memory: u64,
/// Limit of CPU units.
pub cpu: u64,
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Default)]
/// Represents the cost models for different Plutus language versions.
pub struct PlutusCostModels {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use ogmios_client::{
jsonrpsee::client_for_url,
query_ledger_state::{
EpochBoundary, EpochParameters, EraSummary, PlutusCostModels, ProtocolParametersResponse,
QueryLedgerState, QueryUtxoByUtxoId, ReferenceScriptsCosts, ScriptExecutionPrices,
QueryLedgerState, QueryUtxoByUtxoId, ReferenceScriptsCosts, ScriptExecutionPriceLimits,
ScriptExecutionPrices,
},
types::{Asset, OgmiosBytesSize, OgmiosTx, OgmiosUtxo, OgmiosValue, SlotLength, TimeSeconds},
};
Expand Down Expand Up @@ -126,6 +127,9 @@ async fn protocol_parameters() {
"maxBlockBodySize": {
"bytes": 90112
},
"maxBlockHeaderSize": {
"bytes": 1100
},
"maxTransactionSize": {
"bytes": 16384
},
Expand All @@ -139,6 +143,11 @@ async fn protocol_parameters() {
"lovelace": 500000000
}
},
"minStakePoolCost": {
"ada": {
"lovelace": 0
}
},
"collateralPercentage": 150,
"maxCollateralInputs": 3,
"minUtxoDepositCoefficient": 4310,
Expand All @@ -161,6 +170,14 @@ async fn protocol_parameters() {
"memory": "577/10000",
"cpu": "721/10000000"
},
"maxExecutionUnitsPerTransaction": {
"memory": 14000000,
"cpu": 10000000000u64
},
"maxExecutionUnitsPerBlock": {
"memory": 62000000,
"cpu": 40000000000u64
},
"minFeeReferenceScripts": {
"base": 10.0,
"range": 0,
Expand All @@ -182,8 +199,11 @@ async fn protocol_parameters() {
min_fee_constant: OgmiosValue::new_lovelace(155381),
stake_pool_deposit: OgmiosValue::new_lovelace(500000000),
stake_credential_deposit: OgmiosValue::new_lovelace(2000000),
max_block_body_size: OgmiosBytesSize { bytes: 90112 },
max_block_header_size: OgmiosBytesSize { bytes: 1100 },
max_value_size: OgmiosBytesSize { bytes: 5000 },
max_transaction_size: OgmiosBytesSize { bytes: 16384 },
min_stake_pool_cost: OgmiosValue::new_lovelace(0),
min_utxo_deposit_coefficient: 4310,
script_execution_prices: ScriptExecutionPrices {
memory: fraction::Ratio::new_raw(577, 10000),
Expand All @@ -194,6 +214,14 @@ async fn protocol_parameters() {
plutus_v2: vec![43053543, 10],
plutus_v3: vec![-900, 166917843],
},
max_execution_units_per_transaction: ScriptExecutionPriceLimits {
memory: 14000000,
cpu: 10000000000
},
max_execution_units_per_block: ScriptExecutionPriceLimits {
memory: 62000000,
cpu: 40000000000
},
max_collateral_inputs: 3,
collateral_percentage: 150,
min_fee_reference_scripts: ReferenceScriptsCosts { base: 10.0 }
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ default = ["local-ci"]
aiken-contracts-lib = { path = "../../util/aiken-contracts-lib" }
hex.workspace = true
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
whisky = { git = "https://github.com/midnightntwrk/whisky", branch = "wasm-bindgen-update" }
whisky.workspace = true
tiny-bip39 = "2.0.0"
ogmios-client = { path = "../../partner-chains/toolkit/utils/ogmios-client" }
serde.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion util/aiken-contracts-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
hex.workspace = true
thiserror.workspace = true
whisky = { git = "https://github.com/midnightntwrk/whisky", branch = "wasm-bindgen-update" }
whisky.workspace = true
ogmios-client = { path = "../../partner-chains/toolkit/utils/ogmios-client" }
2 changes: 1 addition & 1 deletion util/aiken-deployer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }
serde_json.workspace = true
hex.workspace = true
thiserror.workspace = true
whisky = { git = "https://github.com/midnightntwrk/whisky", branch = "wasm-bindgen-update" }
whisky.workspace = true
ogmios-client = { path = "../../partner-chains/toolkit/utils/ogmios-client" }
3 changes: 3 additions & 0 deletions util/toolkit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ zstd = "0.13"
sqlx = { workspace = true, features = ["runtime-tokio", "postgres"] }
strum.workspace = true
rayon.workspace = true
ogmios-client = { workspace = true, features = ["jsonrpsee-client"] }
whisky.workspace = true
sidechain-domain.workspace = true

[dev-dependencies]
test-case = "3.3.1"
Expand Down
4 changes: 4 additions & 0 deletions util/toolkit/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::commands::{
bridge_transfer::{self, BridgeTransferArgs},
contract_address::{self, ContractAddressArgs},
contract_state::{self, ContractStateArgs},
dust_balance::{self, DustBalanceArgs, DustBalanceResult},
Expand Down Expand Up @@ -85,6 +86,8 @@ pub enum Commands {
Version,
/// Fetch
Fetch(FetchArgs),
/// Transfer cNight from a Cardano wallet to the ICS validator address
BridgeTransfer(BridgeTransferArgs),
}

/// Node Toolkit for Midnight
Expand Down Expand Up @@ -268,5 +271,6 @@ pub async fn run_command(cmd: Commands) -> Result<(), Box<dyn std::error::Error
Ok(())
},
Commands::Fetch(args) => fetch::execute(args).await,
Commands::BridgeTransfer(args) => bridge_transfer::execute(args).await,
}
}
Loading
Loading