Skip to content
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
60 changes: 58 additions & 2 deletions .github/workflows/flow-rust-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ jobs:
uses: hiero-ledger/hiero-solo-action@6a1a77601cf3e69661fb6880530a4edf656b40d5 # v0.14.0
with:
installMirrorNode: true
hieroVersion: v0.65.0

- name: Create env file
run: |
Expand All @@ -129,4 +128,61 @@ jobs:
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
. $HOME/.cargo/env
cargo test --workspace
cargo test --workspace -- --skip node::update
dab-tests:
needs: ['check']
runs-on: hiero-client-sdk-linux-medium
steps:
- name: Harden Runner
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
with:
egress-policy: audit

- name: Checkout Code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: 'recursive'

- name: Setup Rust
uses: dtolnay/rust-toolchain@6d653acede28d24f02e3cd41383119e8b1b35921 # v1
with:
toolchain: 1.88.0

- name: Setup GCC and OpenSSL
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends gcc libc6-dev libc-dev libssl-dev pkg-config openssl

- name: Install Protoc
uses: step-security/setup-protoc@f6eb248a6510dbb851209febc1bd7981604a52e3 # v3.0.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup NodeJS
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
with:
node-version: ${{ env.NODE_VERSION }}

- name: Prepare Hiero Solo for DAB Tests
id: solo-dab
uses: hiero-ledger/hiero-solo-action@9471711c98a56179def6123e1040ab6c2e668881 # branch: 75-add-support-for-multiple-consensus-nodes
with:
hieroVersion: v0.68.0-rc.1
installMirrorNode: true
mirrorNodeVersion: v0.142.0
dualMode: true

- name: Create env file for DAB Tests
run: |
touch .env
echo TEST_OPERATOR_KEY="${{ steps.solo-dab.outputs.privateKey }}" >> .env
echo TEST_OPERATOR_ID="${{ steps.solo-dab.outputs.accountId }}" >> .env
echo TEST_NETWORK_NAME="localhost" >> .env
echo TEST_RUN_NONFREE="1" >> .env
cat .env

- name: Run DAB Tests
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
. $HOME/.cargo/env
cargo test --test e2e node::update -- --test-threads=1
185 changes: 184 additions & 1 deletion protobufs/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,16 @@
.chain(read_dir(&services_tmp_path.join("auxiliary").join("tss"))?)
.filter_map(|entry| {
let entry = entry.ok()?;
let path = entry.path();

entry.file_type().ok()?.is_file().then(|| entry.path())
// Skip hook-related proto files
if let Some(file_name) = path.file_name().and_then(|n| n.to_str()) {
if file_name.starts_with("hook_") || file_name.starts_with("lambda_") {
return None;
}
}

entry.file_type().ok()?.is_file().then(|| path)
})
.collect();

Expand All @@ -67,6 +75,8 @@
let contents = contents.replace("com.hedera.hapi.services.auxiliary.history.", "");
let contents = contents.replace("com.hedera.hapi.services.auxiliary.tss.", "");
let contents = contents.replace("com.hedera.hapi.platform.event.", "");
let contents = contents.replace("com.hedera.hapi.node.hooks.", "");
let contents = contents.replace("com.hedera.hapi.node.hooks.legacy.", "");

let contents = remove_unused_types(&contents);

Expand Down Expand Up @@ -259,6 +269,121 @@
Ok(())
}

// Helper function to comment out entire oneof blocks by name
fn comment_out_oneof(contents: &str, oneof_name: &str) -> String {

Check warning on line 273 in protobufs/build.rs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

protobufs/build.rs#L273

Method comment_out_oneof has a cyclomatic complexity of 16 (limit is 8)
let lines: Vec<&str> = contents.lines().collect();
let mut result = Vec::new();
let mut i = 0;
let oneof_pattern = format!("oneof {} {{", oneof_name);

while i < lines.len() {
let line = lines[i].trim();
if line.starts_with(&oneof_pattern) || line == &format!("oneof {}", oneof_name) {
// Found the start of the oneof, comment it out and track brace depth
let original_line = lines[i];
let indent = original_line.len() - original_line.trim_start().len();
let indent_str = &original_line[..indent];

let mut depth = 0;
let mut found_opening_brace = line.contains('{');

result.push(format!("{}// {}", indent_str, lines[i].trim_start()));
if found_opening_brace {
depth = 1;
}
i += 1;

// Comment out all lines until we close the oneof block
while i < lines.len() && (depth > 0 || !found_opening_brace) {
let current_line = lines[i];
let current_indent = current_line.len() - current_line.trim_start().len();
let current_indent_str = &current_line[..current_indent.min(current_line.len())];

result.push(format!("{}// {}", current_indent_str, current_line.trim_start()));

if !found_opening_brace && current_line.trim_start().starts_with('{') {
found_opening_brace = true;
depth = 1;
}

if found_opening_brace {
for ch in current_line.chars() {
if ch == '{' {
depth += 1;
} else if ch == '}' {
depth -= 1;
}
}
}

i += 1;
if depth == 0 && found_opening_brace {
break;
}
}
} else {
result.push(lines[i].to_string());
i += 1;
}
}

result.join("\n")
}

// Helper function to comment out entire message blocks
fn comment_out_message(contents: &str, message_name: &str) -> String {

Check warning on line 334 in protobufs/build.rs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

protobufs/build.rs#L334

Method comment_out_message has a cyclomatic complexity of 16 (limit is 8)
let lines: Vec<&str> = contents.lines().collect();
let mut result = Vec::new();
let mut i = 0;
let message_start = format!("message {} {{", message_name);

while i < lines.len() {
let line = lines[i].trim();
if line.starts_with(&message_start) || line == &format!("message {}", message_name) {
// Found the start of the message, comment it out and track brace depth
let mut depth = 0;
let mut found_opening_brace = line.contains('{');

result.push(format!("// {}", lines[i]));
if found_opening_brace {
depth = 1;
}
i += 1;

// Comment out all lines until we close the message block
while i < lines.len() && (depth > 0 || !found_opening_brace) {
let current_line = lines[i];
result.push(format!("// {}", current_line));

if !found_opening_brace && current_line.trim_start().starts_with('{') {
found_opening_brace = true;
depth = 1;
}

if found_opening_brace {
for ch in current_line.chars() {
if ch == '{' {
depth += 1;
} else if ch == '}' {
depth -= 1;
}
}
}

i += 1;
if depth == 0 && found_opening_brace {
break;
}
}
} else {
result.push(lines[i].to_string());
i += 1;
}
}

result.join("\n")
}

// Temporary function to remove unused types in transaction.proto
fn remove_unused_types(contents: &str) -> String {
let contents = contents.replace(
Expand Down Expand Up @@ -332,6 +457,64 @@
"// com.hedera.hapi.services.auxiliary.hints.CrsPublicationTransactionBody",
);

// Comment out hook-related imports
let contents = contents.replace(
"import \"services/hook_types.proto\";",
"// import \"services/hook_types.proto\";",
);

let contents = contents.replace(
"import \"services/hook_dispatch.proto\";",
"// import \"services/hook_dispatch.proto\";",
);

let contents = contents.replace(
"import \"services/lambda_sstore.proto\";",
"// import \"services/lambda_sstore.proto\";",
);

// Comment out hook transaction bodies in transaction.proto
// Note: After package replacement, these become just the class name
let contents = contents.replace(
"HookDispatchTransactionBody hook_dispatch",
"// HookDispatchTransactionBody hook_dispatch",
);

let contents = contents.replace(
"LambdaSStoreTransactionBody lambda_sstore",
"// LambdaSStoreTransactionBody lambda_sstore",
);

// Comment out hook creation details in various transaction bodies
// Note: After package replacement, this becomes just "HookCreationDetails"
let contents = contents.replace(
"repeated HookCreationDetails hook_creation_details",
"// repeated HookCreationDetails hook_creation_details",
);

// Comment out hook_ids_to_delete field
let contents = contents
.replace("repeated int64 hook_ids_to_delete", "// repeated int64 hook_ids_to_delete");

// Comment out HookId references
let contents = contents.replace("proto.HookId", "// proto.HookId");
let contents = contents.replace("HookId hook_id", "// HookId hook_id");

// Comment out entire Hook message blocks
let contents = comment_out_message(&contents, "HookId");
let contents = comment_out_message(&contents, "HookEntityId");
let contents = comment_out_message(&contents, "HookCall");
let contents = comment_out_message(&contents, "EvmHookCall");

// Comment out all hook-related oneofs that contain HookCall fields
let contents = comment_out_oneof(&contents, "hook_call");
let contents = comment_out_oneof(&contents, "sender_allowance_hook_call");
let contents = comment_out_oneof(&contents, "receiver_allowance_hook_call");

// Comment out hook-related enum values in HederaFunctionality
let contents = contents.replace("LambdaSStore = 109;", "// LambdaSStore = 109;");
let contents = contents.replace("HookDispatch = 110;", "// HookDispatch = 110;");

contents
}

Expand Down
2 changes: 1 addition & 1 deletion protobufs/services
Submodule services updated 2901 files
17 changes: 17 additions & 0 deletions src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,23 @@ impl Client {
});
}

/// Triggers an immediate network update from the address book.
/// Note: This method is not part of the public API and may be changed or removed in future versions.
pub(crate) async fn refresh_network(&self) {
match NodeAddressBookQuery::new()
.execute_mirrornet(self.mirrornet().load().channel(), None)
.await
{
Ok(address_book) => {
log::info!("Successfully updated network address book");
self.set_network_from_address_book(address_book);
}
Err(e) => {
log::warn!("Failed to update network address book: {e:?}");
}
}
}

/// Returns the Account ID for the operator.
#[must_use]
pub fn get_operator_account_id(&self) -> Option<AccountId> {
Expand Down
2 changes: 1 addition & 1 deletion src/client/network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ impl NetworkData {
node_ids = self.node_ids.to_vec();
}

let node_sample_amount = (node_ids.len() + 2) / 3;
let node_sample_amount = node_ids.len();

let node_id_indecies =
rand::seq::index::sample(&mut thread_rng(), node_ids.len(), node_sample_amount);
Expand Down
Loading
Loading