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
1 change: 1 addition & 0 deletions .genvm-tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ def collect_integration(ctx: genvm_tool.tests.stage.collection.Context):
integration.integration_test_directory(
ctx,
cases_dir=ctx.shared.root_dir / 'tests' / 'system' / 'cross-major' / 'cases',
executor_major=3,
reroute_to=build_info['executor_versions']['v0.3'],
save_hashes=False,
manager_service=manager_service,
Expand Down
4 changes: 2 additions & 2 deletions crates/modules-interfaces/src/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub struct ExecutionData {
#[serde(default)]
#[calldata(default = default_host_hello_data)]
pub host_hello_data: Vec<Bytes>,
pub bucket_totals: Vec<num_bigint::BigInt>,
pub bucket_totals: std::collections::BTreeMap<String, num_bigint::BigInt>,
/// Host-provided `node` fee constants (moved off `host_data`).
pub gas_data: std::collections::BTreeMap<String, String>,
/// Message-fee allocation tree passed alongside the execution.
Expand Down Expand Up @@ -410,7 +410,7 @@ pub struct ReportedResult {
pub nondet_disagreement: Option<u32>,
pub leader_public_data: bytes::Bytes,

pub data_fees_remaining: Vec<primitive_types::U256>,
pub data_fees_remaining: std::collections::BTreeMap<String, primitive_types::U256>,
pub data_fees_consumed: BucketsConsumed,

pub llm_consumed_gen_wei: primitive_types::U256,
Expand Down
32 changes: 10 additions & 22 deletions crates/modules-interfaces/src/domain/fees/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,46 +50,34 @@ fn push_address(buf: &mut Vec<u8>, addr: Option<&genlayer_calldata::Address>) {
}
}

/// `callKey` is already a 32-byte word; `None` is the `CALL_KEY_WILDCARD` = `bytes32(0)`.
/// `callKey` is already a 32-byte word; `None` is `CALL_KEY_WILDCARD`.
fn push_call_key(buf: &mut Vec<u8>, call_key: Option<&crate::abi_stub::CallKey>) {
match call_key {
Some(ck) => buf.extend_from_slice(&ck.0),
None => buf.extend_from_slice(&[0u8; 32]),
None => buf.extend_from_slice(&super::CALL_KEY_WILDCARD.0),
}
}

/// ABI-encodes the nested allocation tree as the chain's flat
/// `MessageAllocationNode[]` representation (matching `abi.encode(nodes)`).
pub(super) fn encode(roots: &[MessageAllocationNode]) -> Vec<u8> {
// Pre-order flatten: (node, parentIndex). Parents always precede children,
// so the parent's array index is already assigned when a child is visited.
/// Encodes the transport payload consumed by `decodeAllocationSubtree`.
pub(super) fn encode(root: &MessageAllocationNode) -> Vec<u8> {
let mut flat: Vec<(&MessageAllocationNode, U256)> = Vec::new();
fn flatten<'a>(
nodes: &'a [MessageAllocationNode],
parent: U256,
out: &mut Vec<(&'a MessageAllocationNode, U256)>,
) {
for node in nodes {
let my_index = U256::from(out.len() as u64);
out.push((node, parent));
flatten(&node.children, my_index, out);
let mut queue = std::collections::VecDeque::from([(root, NODE_ROOT_SENTINEL)]);
while let Some((node, parent_index)) = queue.pop_front() {
let node_index = U256::from(flat.len());
flat.push((node, parent_index));
for child in &node.children {
queue.push_back((child, node_index));
}
}
flatten(roots, NODE_ROOT_SENTINEL, &mut flat);

// Encode each element as its own self-contained dynamic tuple.
let elements: Vec<Vec<u8>> = flat
.iter()
.map(|(node, parent_index)| encode_node(node, *parent_index))
.collect();

// `abi.encode(MessageAllocationNode[])`: leading offset (0x20) to the array.
let mut buf = Vec::new();
push_word(&mut buf, 0x20);

// Dynamic array of dynamic elements: length, then per-element head offsets
// (relative to the start of the head region, i.e. right after the length),
// then the element tails.
push_word(&mut buf, elements.len() as u64);
let mut offset = elements.len() * 32;
for element in &elements {
Expand Down
17 changes: 10 additions & 7 deletions crates/modules-interfaces/src/domain/fees/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ use primitive_types::U256;

use crate::On;

pub const CALL_KEY_WILDCARD: crate::abi_stub::CallKey = crate::abi_stub::CallKey([
0xc5, 0xd2, 0x46, 0x01, 0x86, 0xf7, 0x23, 0x3c, 0x92, 0x7e, 0x7d, 0xb2, 0xdc, 0xc7, 0x03, 0xc0,
0xe5, 0x00, 0xb6, 0x53, 0xca, 0x82, 0x27, 0x3b, 0x7b, 0xfa, 0xd8, 0x04, 0x5d, 0x85, 0xa4, 0x70,
]);

#[derive(
Debug,
Clone,
Expand Down Expand Up @@ -83,7 +88,7 @@ pub struct MessageAllocationNode {
/// Target contract address; `None` means wildcard (any recipient).
pub recipient: Option<genlayer_calldata::Address>,
/// `None` = wildcard: all call keys for this recipient
/// (chain sentinel: `CALL_KEY_WILDCARD` = `bytes32(0)`).
/// (chain sentinel: `CALL_KEY_WILDCARD` = `keccak256("")`).
pub call_key: Option<crate::abi_stub::CallKey>,
/// Max budget for matching messages.
pub budget: U256,
Expand All @@ -94,12 +99,10 @@ pub struct MessageAllocationNode {
}

impl MessageAllocationNode {
/// ABI-encodes the nested allocation tree as the chain's flat
/// `MessageAllocationNode[]` representation (matching `abi.encode(nodes)`),
/// flattening children to parent-pointer form via pre-order traversal so that
/// every parent precedes its children and their `parentIndex` is well-defined.
pub fn abi_encode(roots: &[MessageAllocationNode]) -> Vec<u8> {
abi::encode(roots)
/// ABI-encodes this matched node and its descendants for transport to the chain.
/// The matched node is element 0 and descendants are in BFS order.
pub fn abi_encode(&self) -> Vec<u8> {
abi::encode(self)
}

#[allow(clippy::if_same_then_else)]
Expand Down
14 changes: 6 additions & 8 deletions docs/schemas/default-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -351,19 +351,17 @@
"genvm-fees-bucket-conf": {
"type": "object",
"properties": {
"bucket_no": {
"buckets": {
"oneOf": [
{
"type": "integer",
"minimum": 0,
"maximum": 255
"type": "string",
"minLength": 1
},
{
"type": "array",
"items": {
"type": "integer",
"minimum": 0,
"maximum": 255
"type": "string",
"minLength": 1
},
"minItems": 1
}
Expand All @@ -379,7 +377,7 @@
"description": "cost charged per change, evaluated with the `units` variable; see `expr_prelude`"
}
},
"required": ["bucket_no", "delta_expr"],
"required": ["buckets", "delta_expr"],
"additionalProperties": false
},
"genvm-fees-conf": {
Expand Down
Loading
Loading