Skip to content

Commit

Permalink
Merge branch 'master' into oleksii/dependent-transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
Br1ght0ne authored Jan 30, 2024
2 parents 8b269b3 + 1221632 commit a027ff6
Show file tree
Hide file tree
Showing 23 changed files with 750 additions and 93 deletions.
38 changes: 34 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
# TODO: To be removed once https://github.com/FuelLabs/fuels-rs/issues/881 is unblocked.
- name: Build Sway test projects w type paths
run: forc build --terse --json-abi-with-callpaths
run: forc build --terse --error-on-warnings --json-abi-with-callpaths
working-directory: packages/fuels

- uses: actions/upload-artifact@v2
Expand All @@ -97,6 +97,25 @@ jobs:
!packages/fuels/tests/**/Forc.lock
!packages/fuels/tests/.gitignore
# TODO: To be removed once experimental encoding is the default
- name: Build Sway test projects w experimental logs
run: forc build --terse --error-on-warnings --json-abi-with-callpaths --experimental-new-encoding
working-directory: packages/fuels

- uses: actions/upload-artifact@v2
with:
retention-days: 2
name: sway-examples-w-experimental-logs
# cache only the sway build artifacts, skip all src files
path: |
packages/fuels/tests
!packages/fuels/tests/*.rs
!packages/fuels/tests/**/*.rs
!packages/fuels/tests/**/*.sw
!packages/fuels/tests/**/Forc.toml
!packages/fuels/tests/**/Forc.lock
!packages/fuels/tests/.gitignore
get-workspace-members:
runs-on: ubuntu-latest
outputs:
Expand Down Expand Up @@ -137,7 +156,7 @@ jobs:
toolchain: ${{ env.RUST_VERSION }}

- name: Publish crate check
uses: katyo/publish-crates@v2
uses: xgreenx/publish-crates@v1
with:
dry-run: true
check-repo: false
Expand Down Expand Up @@ -182,6 +201,11 @@ jobs:
args:
- command: check_doc_unresolved_links
args:
# TODO: To be removed once experimental encoding is the default
- command: test_experimental_logs
args:
download_sway_artifacts: sway-examples-w-experimental-logs
install_fuel_core: true
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand Down Expand Up @@ -218,8 +242,9 @@ jobs:
name: ${{ matrix.download_sway_artifacts }}
path: packages/fuels/tests/

# TODO: `test_experimental_logs` to be removed once experimental encoding is the default.
- name: Install nextest
if: ${{ matrix.cargo_command == 'nextest' }}
if: ${{ matrix.cargo_command == 'nextest' || matrix.command == 'test_experimental_logs' }}
uses: taiki-e/install-action@nextest

- name: Install cargo-machete
Expand Down Expand Up @@ -257,6 +282,11 @@ jobs:
run: |
! cargo doc --document-private-items |& grep -A 6 "warning: unresolved link to"
# TODO: To be removed once experimental encoding is the default.
- name: Test experimental logs
if: ${{ matrix.command == 'test_experimental_logs' }}
run: RUSTFLAGS='--cfg experimental' cargo nextest run --test logs

publish:
needs:
- cargo-verifications
Expand All @@ -279,7 +309,7 @@ jobs:
mv ./dasel /usr/local/bin/dasel
./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} Cargo.toml
- name: Publish crate
uses: katyo/publish-crates@v2
uses: xgreenx/publish-crates@v1
with:
publish-delay: 30000
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ readme = "README.md"
license = "Apache-2.0"
repository = "https://github.com/FuelLabs/fuels-rs"
rust-version = "1.74.0"
version = "0.54.0"
version = "0.55.0"

[workspace.dependencies]
Inflector = "0.11.4"
Expand Down Expand Up @@ -89,10 +89,10 @@ fuel-types = { version = "0.43.1" }
fuel-vm = { version = "0.43.1" }

# Workspace projects
fuels = { version = "0.54.0", path = "./packages/fuels" }
fuels-accounts = { version = "0.54.0", path = "./packages/fuels-accounts", default-features = false }
fuels-code-gen = { version = "0.54.0", path = "./packages/fuels-code-gen", default-features = false }
fuels-core = { version = "0.54.0", path = "./packages/fuels-core", default-features = false }
fuels-macros = { version = "0.54.0", path = "./packages/fuels-macros", default-features = false }
fuels-programs = { version = "0.54.0", path = "./packages/fuels-programs", default-features = false }
fuels-test-helpers = { version = "0.54.0", path = "./packages/fuels-test-helpers", default-features = false }
fuels = { version = "0.55.0", path = "./packages/fuels" }
fuels-accounts = { version = "0.55.0", path = "./packages/fuels-accounts", default-features = false }
fuels-code-gen = { version = "0.55.0", path = "./packages/fuels-code-gen", default-features = false }
fuels-core = { version = "0.55.0", path = "./packages/fuels-core", default-features = false }
fuels-macros = { version = "0.55.0", path = "./packages/fuels-macros", default-features = false }
fuels-programs = { version = "0.55.0", path = "./packages/fuels-programs", default-features = false }
fuels-test-helpers = { version = "0.55.0", path = "./packages/fuels-test-helpers", default-features = false }
4 changes: 2 additions & 2 deletions docs/src/connecting/short-lived.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ let wallet = launch_provider_and_get_wallet().await?;
The `fuel-core-lib` feature allows us to run a `fuel-core` node without installing the `fuel-core` binary on the local machine. Using the `fuel-core-lib` feature flag entails downloading all the dependencies needed to run the fuel-core node.

```rust,ignore
fuels = { version = "0.54.0", features = ["fuel-core-lib"] }
fuels = { version = "0.55.0", features = ["fuel-core-lib"] }
```

### RocksDB

The `rocksdb` is an additional feature that, when combined with `fuel-core-lib`, provides persistent storage capabilities while using `fuel-core` as a library.

```rust,ignore
fuels = { version = "0.54.0", features = ["rocksdb"] }
fuels = { version = "0.55.0", features = ["rocksdb"] }
```
19 changes: 19 additions & 0 deletions packages/fuels-core/src/codec/abi_decoder.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
mod bounded_decoder;
#[cfg(experimental)]
mod experimental_bounded_decoder;

use crate::{
codec::abi_decoder::bounded_decoder::BoundedDecoder,
types::{errors::Result, param_types::ParamType, Token},
};

#[cfg(experimental)]
use crate::codec::abi_decoder::experimental_bounded_decoder::ExperimentalBoundedDecoder;

#[derive(Debug, Clone, Copy)]
pub struct DecoderConfig {
/// Entering a struct, array, tuple, enum or vector increases the depth. Decoding will fail if
Expand Down Expand Up @@ -77,6 +82,20 @@ impl ABIDecoder {
pub fn decode_multiple(&self, param_types: &[ParamType], bytes: &[u8]) -> Result<Vec<Token>> {
BoundedDecoder::new(self.config).decode_multiple(param_types, bytes)
}

#[cfg(experimental)]
pub fn experimental_decode(&self, param_type: &ParamType, bytes: &[u8]) -> Result<Token> {
ExperimentalBoundedDecoder::new(self.config).decode(param_type, bytes)
}

#[cfg(experimental)]
pub fn experimental_decode_multiple(
&self,
param_types: &[ParamType],
bytes: &[u8],
) -> Result<Vec<Token>> {
ExperimentalBoundedDecoder::new(self.config).decode_multiple(param_types, bytes)
}
}

#[cfg(test)]
Expand Down
23 changes: 5 additions & 18 deletions packages/fuels-core/src/codec/abi_decoder/bounded_decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::{
checked_round_up_to_word_alignment,
codec::DecoderConfig,
constants::WORD_SIZE,
traits::Tokenizable,
types::{
enum_variants::EnumVariants,
errors::{error, Result},
Expand Down Expand Up @@ -36,7 +35,7 @@ impl BoundedDecoder {
}
}

pub fn decode(&mut self, param_type: &ParamType, bytes: &[u8]) -> Result<Token> {
pub(crate) fn decode(&mut self, param_type: &ParamType, bytes: &[u8]) -> Result<Token> {
param_type.validate_is_decodable(self.config.max_depth)?;
match param_type {
// Unit, U8 and Bool are returned as u64 from receipt "Return"
Expand Down Expand Up @@ -94,7 +93,7 @@ impl BoundedDecoder {
ParamType::U256 => Self::decode_u256(bytes),
ParamType::Bool => Self::decode_bool(bytes),
ParamType::B256 => Self::decode_b256(bytes),
ParamType::RawSlice => self.decode_raw_slice(bytes),
ParamType::RawSlice => Self::decode_raw_slice(bytes),
ParamType::StringSlice => Self::decode_string_slice(bytes),
ParamType::StringArray(len) => Self::decode_string_array(bytes, *len),
ParamType::Array(ref t, length) => {
Expand Down Expand Up @@ -215,22 +214,10 @@ impl BoundedDecoder {
})
}

fn decode_raw_slice(&mut self, bytes: &[u8]) -> Result<Decoded> {
let raw_slice_element = ParamType::U64;
let num_of_elements =
ParamType::calculate_num_of_elements(&raw_slice_element, bytes.len())?;
let param_type = ParamType::U64;
let (tokens, bytes_read) =
self.decode_params(std::iter::repeat(&param_type).take(num_of_elements), bytes)?;
let elements = tokens
.into_iter()
.map(u64::from_token)
.collect::<Result<Vec<u64>>>()
.map_err(|e| error!(InvalidData, "{e}"))?;

fn decode_raw_slice(bytes: &[u8]) -> Result<Decoded> {
Ok(Decoded {
token: Token::RawSlice(elements),
bytes_read,
token: Token::RawSlice(bytes.to_vec()),
bytes_read: bytes.len(),
})
}

Expand Down
Loading

0 comments on commit a027ff6

Please sign in to comment.