diff --git a/documentation/cli/03_build.md b/documentation/cli/03_build.md index 4ce327d16..463467a80 100644 --- a/documentation/cli/03_build.md +++ b/documentation/cli/03_build.md @@ -59,6 +59,11 @@ The build also generates an **ABI file** at `build/abi.json` describing your pro The network to deploy to. Overrides the `NETWORK` environment variable. --endpoint The endpoint to deploy to. Overrides the `ENDPOINT` environment variable. +--network-retries + Number of times to retry a network request on transient transport failure, with + exponential backoff (1 s, 2 s, 4 s, … capped at 64 s). Overrides the + NETWORK_RETRIES environment variable. Defaults to 2. HTTP errors and broadcast + calls are not retried. --devnet Whether the network is a devnet. If not set, defaults to the `DEVNET` environment variable. --consensus-heights diff --git a/documentation/cli/06_deploy.md b/documentation/cli/06_deploy.md index 9d3b460ea..eba4a0534 100644 --- a/documentation/cli/06_deploy.md +++ b/documentation/cli/06_deploy.md @@ -135,6 +135,10 @@ The endpoint to deploy to. Overrides any `ENDPOINT` environment variable set man +#### `--network-retries ` + +Number of times to retry a network request on transient transport failure, with exponential backoff (1 s, 2 s, 4 s, … capped at 64 s). Overrides the `NETWORK_RETRIES` environment variable. Defaults to `2`. HTTP errors (4xx/5xx) and broadcast calls are not retried. + #### `--devnet` Specifies whether the network being deployed to is a devnet. If not set, defaults to the `DEVNET` environment variable. diff --git a/documentation/cli/08_execute.md b/documentation/cli/08_execute.md index d576dd0ff..bc87b2465 100644 --- a/documentation/cli/08_execute.md +++ b/documentation/cli/08_execute.md @@ -105,6 +105,10 @@ The endpoint to deploy to. Overrides any `ENDPOINT` environment variable set man +#### `--network-retries ` + +Number of times to retry a network request on transient transport failure, with exponential backoff (1 s, 2 s, 4 s, … capped at 64 s). Overrides the `NETWORK_RETRIES` environment variable. Defaults to `2`. HTTP errors (4xx/5xx) and broadcast calls are not retried. + #### `--devnet` Specifies whether the network being deployed to is a devnet. If not set, defaults to the `DEVNET` environment variable. diff --git a/documentation/cli/10_query.md b/documentation/cli/10_query.md index 63a636874..d0005c4ef 100644 --- a/documentation/cli/10_query.md +++ b/documentation/cli/10_query.md @@ -56,6 +56,10 @@ Specifies the network to deploy to. Overrides any `NETWORK` environment variable The endpoint to deploy to. Overrides any `ENDPOINT` environment variable set manually or in a `.env` file. +#### `--network-retries ` + +Number of times to retry a network request on transient transport failure, with exponential backoff (1 s, 2 s, 4 s, … capped at 64 s). Overrides the `NETWORK_RETRIES` environment variable. Defaults to `2`. HTTP errors (4xx/5xx) and broadcast calls are not retried. + #### `--latest` #### `-l` @@ -132,6 +136,10 @@ Specifies the network to deploy to. Overrides any `NETWORK` environment variable The endpoint to deploy to. Overrides any `ENDPOINT` environment variable set manually or in a `.env` file. +#### `--network-retries ` + +Number of times to retry a network request on transient transport failure, with exponential backoff (1 s, 2 s, 4 s, … capped at 64 s). Overrides the `NETWORK_RETRIES` environment variable. Defaults to `2`. HTTP errors (4xx/5xx) and broadcast calls are not retried. + #### `--confirmed` #### `-c` @@ -194,6 +202,10 @@ Specifies the network to deploy to. Overrides any `NETWORK` environment variable The endpoint to deploy to. Overrides any `ENDPOINT` environment variable set manually or in a `.env` file. +#### `--network-retries ` + +Number of times to retry a network request on transient transport failure, with exponential backoff (1 s, 2 s, 4 s, … capped at 64 s). Overrides the `NETWORK_RETRIES` environment variable. Defaults to `2`. HTTP errors (4xx/5xx) and broadcast calls are not retried. + #### `--mappings` Lists all mappings defined in the latest deployed edition of the program. @@ -224,6 +236,10 @@ Specifies the network to deploy to. Overrides any `NETWORK` environment variable The endpoint to deploy to. Overrides any `ENDPOINT` environment variable set manually or in a `.env` file. +#### `--network-retries ` + +Number of times to retry a network request on transient transport failure, with exponential backoff (1 s, 2 s, 4 s, … capped at 64 s). Overrides the `NETWORK_RETRIES` environment variable. Defaults to `2`. HTTP errors (4xx/5xx) and broadcast calls are not retried. + --- ## `leo query committee` @@ -240,6 +256,10 @@ Specifies the network to deploy to. Overrides any `NETWORK` environment variable The endpoint to deploy to. Overrides any `ENDPOINT` environment variable set manually or in a `.env` file. +#### `--network-retries ` + +Number of times to retry a network request on transient transport failure, with exponential backoff (1 s, 2 s, 4 s, … capped at 64 s). Overrides the `NETWORK_RETRIES` environment variable. Defaults to `2`. HTTP errors (4xx/5xx) and broadcast calls are not retried. + --- ## `leo query mempool` @@ -280,6 +300,10 @@ Specifies the network to deploy to. Overrides any `NETWORK` environment variable The endpoint to deploy to. Overrides any `ENDPOINT` environment variable set manually or in a `.env` file. +#### `--network-retries ` + +Number of times to retry a network request on transient transport failure, with exponential backoff (1 s, 2 s, 4 s, … capped at 64 s). Overrides the `NETWORK_RETRIES` environment variable. Defaults to `2`. HTTP errors (4xx/5xx) and broadcast calls are not retried. + --- ## `leo query peers` @@ -311,3 +335,7 @@ Specifies the network to deploy to. Overrides any `NETWORK` environment variable #### `--endpoint ` The endpoint to deploy to. Overrides any `ENDPOINT` environment variable set manually or in a `.env` file. + +#### `--network-retries ` + +Number of times to retry a network request on transient transport failure, with exponential backoff (1 s, 2 s, 4 s, … capped at 64 s). Overrides the `NETWORK_RETRIES` environment variable. Defaults to `2`. HTTP errors (4xx/5xx) and broadcast calls are not retried. diff --git a/documentation/cli/12_run.md b/documentation/cli/12_run.md index 8c1f31742..e498880eb 100644 --- a/documentation/cli/12_run.md +++ b/documentation/cli/12_run.md @@ -78,6 +78,11 @@ leo run -- -- ... The network to deploy to. Overrides the `NETWORK` environment variable. --endpoint The endpoint to deploy to. Overrides the `ENDPOINT` environment variable. +--network-retries + Number of times to retry a network request on transient transport failure, with + exponential backoff (1 s, 2 s, 4 s, … capped at 64 s). Overrides the + NETWORK_RETRIES environment variable. Defaults to 2. HTTP errors and broadcast + calls are not retried. --devnet Whether the network is a devnet. If not set, defaults to the `DEVNET` environment variable. --consensus-heights diff --git a/documentation/cli/15_upgrade.md b/documentation/cli/15_upgrade.md index 504015a92..f0eb1629c 100644 --- a/documentation/cli/15_upgrade.md +++ b/documentation/cli/15_upgrade.md @@ -40,6 +40,10 @@ The endpoint to deploy to. Overrides any `ENDPOINT` environment variable set man +#### `--network-retries ` + +Number of times to retry a network request on transient transport failure, with exponential backoff (1 s, 2 s, 4 s, … capped at 64 s). Overrides the `NETWORK_RETRIES` environment variable. Defaults to `2`. HTTP errors (4xx/5xx) and broadcast calls are not retried. + #### `--devnet` Specifies whether the network being deployed to is a devnet. If not set, defaults to the `DEVNET` environment variable. diff --git a/documentation/cli/16_synthesize.md b/documentation/cli/16_synthesize.md index de0e91364..e2b506d7c 100644 --- a/documentation/cli/16_synthesize.md +++ b/documentation/cli/16_synthesize.md @@ -37,6 +37,10 @@ Specifies the network to deploy to. Overrides any `NETWORK` environment variable The endpoint to deploy to. Overrides any `ENDPOINT` environment variable set manually or in a `.env` file. +#### `--network-retries ` + +Number of times to retry a network request on transient transport failure, with exponential backoff (1 s, 2 s, 4 s, … capped at 64 s). Overrides the `NETWORK_RETRIES` environment variable. Defaults to `2`. HTTP errors (4xx/5xx) and broadcast calls are not retried. + #### `--local` #### `-l` diff --git a/documentation/language/01_layout.md b/documentation/language/01_layout.md index 7901efb66..615889a94 100644 --- a/documentation/language/01_layout.md +++ b/documentation/language/01_layout.md @@ -165,6 +165,85 @@ fn increment(x: field) -> field { } ``` +### Accessing Submodules of Imported Programs + +When an imported program organizes its source across submodules, you can reach any `struct`, `const`, or helper `fn` from those submodules using an extended locator path: + +``` +program.aleo::submodule::item +``` + +For example, suppose `provider.aleo` has a submodule `colors` that defines a `Color` struct, a `MAX_CH` constant, and a `blend` helper: + +```leo title="provider/src/colors.leo" +const MAX_CH: u32 = 255u32; + +struct Color { + r: u32, + g: u32, + b: u32, +} + +fn blend(a: Color, b: Color) -> Color { + return Color { + r: (a.r + b.r) / 2u32, + g: (a.g + b.g) / 2u32, + b: (a.b + b.b) / 2u32, + }; +} +``` + +```leo title="provider/src/main.leo" +program provider.aleo { + fn sum_channels(c: colors::Color) -> u32 { + return c.r + c.g + c.b; + } + + fn mix_colors(a: colors::Color, b: colors::Color) -> colors::Color { + return colors::blend(a, b); + } + + @noupgrade + constructor() {} +} +``` + +A program that imports `provider.aleo` can reach the submodule struct, constant, and helper through the extended path, and can also call `provider.aleo`'s top-level entry functions: + +```leo title="consumer/src/main.leo" +import provider.aleo; + +program consumer.aleo { + // Struct and const from the submodule. + fn make_white() -> provider.aleo::colors::Color { + return provider.aleo::colors::Color { + r: provider.aleo::colors::MAX_CH, + g: provider.aleo::colors::MAX_CH, + b: provider.aleo::colors::MAX_CH, + }; + } + + // Top-level entry function from the provider. + fn mix(a: provider.aleo::colors::Color, b: provider.aleo::colors::Color) -> provider.aleo::colors::Color { + return provider.aleo::mix_colors(a, b); + } + + // Submodule helper called directly — inlined into consumer's bytecode. + fn average(a: provider.aleo::colors::Color, b: provider.aleo::colors::Color) -> provider.aleo::colors::Color { + return provider.aleo::colors::blend(a, b); + } + + @noupgrade + constructor() {} +} +``` + +Helper `fn`s reached through `program.aleo::submodule::name(...)` are inlined directly into the caller's bytecode; they are not separate on-chain calls and do not appear in the provider's ABI. Only top-level entry functions declared inside `program provider.aleo { ... }` remain part of its on-chain interface. + +Submodule paths can be arbitrarily deep — `program.aleo::a::b::item` is valid if `program.aleo` has a nested submodule `a/b.leo`. The same extended path syntax applies to library submodules (see [Leo Libraries](./06_libraries.md#submodules)). + +`interface` definitions may also be referenced through the same path syntax — both library submodules (`program my_app.aleo: my_lib::interfaces::Adder { ... }`) and imported program submodules (`program my_app.aleo: other_prog.aleo::interfaces::Adder { ... }`) work in a program header. +