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

Add --policy-config argument to create-genesis-config #3414

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
28 changes: 6 additions & 22 deletions CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -491,39 +491,23 @@ Create genesis configuration for a Linera deployment. Create initial user chains

Default value: `0`
* `--start-timestamp <START_TIMESTAMP>` — The start timestamp: no blocks can be created before this time
* `--block-price <BLOCK_PRICE>` — Set the base price for creating a block
* `--policy-config <POLICY_CONFIG>` — Configure the resource control policy (notably fees) according to pre-defined settings

Default value: `0`
* `--fuel-unit-price <FUEL_UNIT_PRICE>` — Set the price per unit of fuel
Default value: `default`

Default value: `0`
* `--read-operation-price <READ_OPERATION_PRICE>` — Set the price per read operation
Possible values: `default`, `only-fuel`, `fuel-and-block`, `all-categories`, `devnet`

Default value: `0`
* `--block-price <BLOCK_PRICE>` — Set the base price for creating a block
* `--fuel-unit-price <FUEL_UNIT_PRICE>` — Set the price per unit of fuel
* `--read-operation-price <READ_OPERATION_PRICE>` — Set the price per read operation
* `--write-operation-price <WRITE_OPERATION_PRICE>` — Set the price per write operation

Default value: `0`
* `--byte-read-price <BYTE_READ_PRICE>` — Set the price per byte read

Default value: `0`
* `--byte-written-price <BYTE_WRITTEN_PRICE>` — Set the price per byte written

Default value: `0`
* `--byte-stored-price <BYTE_STORED_PRICE>` — Set the price per byte stored

Default value: `0`
* `--operation-price <OPERATION_PRICE>` — Set the base price of sending an operation from a block..

Default value: `0`
* `--operation-byte-price <OPERATION_BYTE_PRICE>` — Set the additional price for each byte in the argument of a user operation

Default value: `0`
* `--message-price <MESSAGE_PRICE>` — Set the base price of sending a message from a block..

Default value: `0`
* `--message-byte-price <MESSAGE_BYTE_PRICE>` — Set the additional price for each byte in the argument of a user message

Default value: `0`
* `--maximum-fuel-per-block <MAXIMUM_FUEL_PER_BLOCK>` — Set the maximum amount of fuel per block
* `--maximum-executed-block-size <MAXIMUM_EXECUTED_BLOCK_SIZE>` — Set the maximum size of an executed block
* `--maximum-bytecode-size <MAXIMUM_BYTECODE_SIZE>` — Set the maximum size of decompressed contract or service bytecode, in bytes
Expand Down
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.

49 changes: 27 additions & 22 deletions linera-client/src/client_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,49 +640,54 @@ pub enum ClientCommand {
/// Number of initial (aka "root") chains to create in addition to the admin chain.
num_other_initial_chains: u32,

/// Configure the resource control policy (notably fees) according to pre-defined
/// settings.
#[arg(long, default_value = "default")]
policy_config: ResourceControlPolicyConfig,

/// Set the base price for creating a block.
#[arg(long, default_value = "0")]
block_price: Amount,
#[arg(long)]
block_price: Option<Amount>,

/// Set the price per unit of fuel.
#[arg(long, default_value = "0")]
fuel_unit_price: Amount,
#[arg(long)]
fuel_unit_price: Option<Amount>,

/// Set the price per read operation.
#[arg(long, default_value = "0")]
read_operation_price: Amount,
#[arg(long)]
read_operation_price: Option<Amount>,

/// Set the price per write operation.
#[arg(long, default_value = "0")]
write_operation_price: Amount,
#[arg(long)]
write_operation_price: Option<Amount>,

/// Set the price per byte read.
#[arg(long, default_value = "0")]
byte_read_price: Amount,
#[arg(long)]
byte_read_price: Option<Amount>,

/// Set the price per byte written.
#[arg(long, default_value = "0")]
byte_written_price: Amount,
#[arg(long)]
byte_written_price: Option<Amount>,

/// Set the price per byte stored.
#[arg(long, default_value = "0")]
byte_stored_price: Amount,
#[arg(long)]
byte_stored_price: Option<Amount>,

/// Set the base price of sending an operation from a block..
#[arg(long, default_value = "0")]
operation_price: Amount,
#[arg(long)]
operation_price: Option<Amount>,

/// Set the additional price for each byte in the argument of a user operation.
#[arg(long, default_value = "0")]
operation_byte_price: Amount,
#[arg(long)]
operation_byte_price: Option<Amount>,

/// Set the base price of sending a message from a block..
#[arg(long, default_value = "0")]
message_price: Amount,
#[arg(long)]
message_price: Option<Amount>,

/// Set the additional price for each byte in the argument of a user message.
#[arg(long, default_value = "0")]
message_byte_price: Amount,
#[arg(long)]
message_byte_price: Option<Amount>,

/// Set the maximum amount of fuel per block.
#[arg(long)]
Expand Down
1 change: 1 addition & 0 deletions linera-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ current_platform = "0.2.0"
fs-err = { workspace = true, features = ["tokio"] }
fs_extra = { workspace = true, optional = true }
futures.workspace = true
heck.workspace = true
hex.workspace = true
http.workspace = true
k8s-openapi = { workspace = true, optional = true }
Expand Down
8 changes: 4 additions & 4 deletions linera-service/src/cli_wrappers/local_kubernetes_net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use linera_base::{
command::{resolve_binary, CommandExt},
data_types::Amount,
};
use linera_execution::ResourceControlPolicy;
use linera_client::client_options::ResourceControlPolicyConfig;
use tempfile::{tempdir, TempDir};
use tokio::process::Command;
#[cfg(with_testing)]
Expand Down Expand Up @@ -48,7 +48,7 @@ pub struct LocalKubernetesNetConfig {
pub binaries: BuildArg,
pub no_build: bool,
pub docker_image_name: String,
pub policy: ResourceControlPolicy,
pub policy_config: ResourceControlPolicyConfig,
}

/// A wrapper of [`LocalKubernetesNetConfig`] to create a shared local Kubernetes network
Expand Down Expand Up @@ -102,7 +102,7 @@ impl SharedLocalKubernetesNetTestingConfig {
binaries,
no_build: false,
docker_image_name: String::from("linera:latest"),
policy: ResourceControlPolicy::devnet(),
policy_config: ResourceControlPolicyConfig::Devnet,
})
}
}
Expand Down Expand Up @@ -142,7 +142,7 @@ impl LineraNetConfig for LocalKubernetesNetConfig {
.create_genesis_config(
self.num_other_initial_chains,
self.initial_amount,
self.policy,
self.policy_config,
)
.await
.unwrap();
Expand Down
12 changes: 7 additions & 5 deletions linera-service/src/cli_wrappers/local_net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ use linera_base::{
command::{resolve_binary, CommandExt},
data_types::Amount,
};
use linera_client::storage::{StorageConfig, StorageConfigNamespace};
use linera_client::{
client_options::ResourceControlPolicyConfig,
storage::{StorageConfig, StorageConfigNamespace},
};
use linera_core::node::ValidatorNodeProvider;
use linera_execution::ResourceControlPolicy;
#[cfg(all(feature = "storage-service", with_testing))]
use linera_storage_service::common::storage_service_test_endpoint;
#[cfg(all(feature = "scylladb", with_testing))]
Expand Down Expand Up @@ -161,7 +163,7 @@ pub struct LocalNetConfig {
pub initial_amount: Amount,
pub num_initial_validators: usize,
pub num_shards: usize,
pub policy: ResourceControlPolicy,
pub policy_config: ResourceControlPolicyConfig,
pub storage_config_builder: StorageConfigBuilder,
pub path_provider: PathProvider,
}
Expand Down Expand Up @@ -258,7 +260,7 @@ impl LocalNetConfig {
network,
num_other_initial_chains: 2,
initial_amount: Amount::from_tokens(1_000_000),
policy: ResourceControlPolicy::devnet(),
policy_config: ResourceControlPolicyConfig::Devnet,
testing_prng_seed: Some(37),
namespace: linera_views::random::generate_test_namespace(),
num_initial_validators: 4,
Expand Down Expand Up @@ -294,7 +296,7 @@ impl LineraNetConfig for LocalNetConfig {
.create_genesis_config(
self.num_other_initial_chains,
self.initial_amount,
self.policy,
self.policy_config,
)
.await
.unwrap();
Expand Down
69 changes: 7 additions & 62 deletions linera-service/src/cli_wrappers/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ use anyhow::{bail, ensure, Context, Result};
use async_graphql::InputType;
use async_tungstenite::tungstenite::{client::IntoClientRequest as _, http::HeaderValue};
use futures::{SinkExt as _, Stream, StreamExt as _, TryStreamExt as _};
use heck::ToKebabCase;
use linera_base::{
abi::ContractAbi,
command::{resolve_binary, CommandExt},
crypto::CryptoHash,
data_types::{Amount, Bytecode},
identifiers::{Account, ApplicationId, BytecodeId, ChainId, MessageId, Owner},
};
use linera_client::wallet::Wallet;
use linera_client::{client_options::ResourceControlPolicyConfig, wallet::Wallet};
use linera_core::worker::Notification;
use linera_execution::{system::SystemChannel, ResourceControlPolicy};
use linera_execution::system::SystemChannel;
use linera_faucet::ClaimOutcome;
use linera_faucet_client::Faucet;
use serde::{de::DeserializeOwned, ser::Serialize};
Expand Down Expand Up @@ -232,29 +233,8 @@ impl ClientWrapper {
&self,
num_other_initial_chains: u32,
initial_funding: Amount,
policy: ResourceControlPolicy,
policy_config: ResourceControlPolicyConfig,
) -> Result<()> {
let ResourceControlPolicy {
block,
fuel_unit,
read_operation,
write_operation,
byte_read,
byte_written,
byte_stored,
operation,
operation_byte,
message,
message_byte,
maximum_fuel_per_block,
maximum_executed_block_size,
maximum_blob_size,
maximum_published_blobs,
maximum_bytecode_size,
maximum_block_proposal_size,
maximum_bytes_read_per_block,
maximum_bytes_written_per_block,
} = policy;
let mut command = self.command().await?;
command
.args([
Expand All @@ -264,46 +244,11 @@ impl ClientWrapper {
.args(["--initial-funding", &initial_funding.to_string()])
.args(["--committee", "committee.json"])
.args(["--genesis", "genesis.json"])
.args(["--block-price", &block.to_string()])
.args(["--fuel-unit-price", &fuel_unit.to_string()])
.args(["--read-operation-price", &read_operation.to_string()])
.args(["--byte-read-price", &byte_read.to_string()])
.args(["--byte-written-price", &byte_written.to_string()])
.args(["--byte-stored-price", &byte_stored.to_string()])
.args(["--message-byte-price", &message_byte.to_string()])
.args(["--write-operation-price", &write_operation.to_string()])
.args(["--operation-price", &operation.to_string()])
.args(["--operation-byte-price", &operation_byte.to_string()])
.args(["--message-price", &message.to_string()])
.args([
"--maximum-fuel-per-block",
&maximum_fuel_per_block.to_string(),
])
.args([
"--maximum-executed-block-size",
&maximum_executed_block_size.to_string(),
])
.args(["--maximum-blob-size", &maximum_blob_size.to_string()])
.args([
"--maximum-published-blobs",
&maximum_published_blobs.to_string(),
])
.args([
"--maximum-bytecode-size",
&maximum_bytecode_size.to_string(),
])
.args([
"--maximum-block-proposal-size",
&maximum_block_proposal_size.to_string(),
])
.args([
"--maximum-bytes-read-per-block",
&maximum_bytes_read_per_block.to_string(),
])
.args([
"--maximum-bytes-written-per-block",
&maximum_bytes_written_per_block.to_string(),
"--policy-config",
&policy_config.to_string().to_kebab_case(),
]);

if let Some(seed) = self.testing_prng_seed {
command.arg("--testing-prng-seed").arg(seed.to_string());
}
Expand Down
Loading