Skip to content

Conversation

@igor-aptos
Copy link
Contributor

@igor-aptos igor-aptos commented Dec 19, 2025

Description

How Has This Been Tested?

Key Areas to Review

Type of Change

  • New feature
  • Bug fix
  • Breaking change
  • Performance improvement
  • Refactoring
  • Dependency update
  • Documentation update
  • Tests

Which Components or Systems Does This Change Impact?

  • Validator Node
  • Full Node (API, Indexer, etc.)
  • Move/Aptos Virtual Machine
  • Aptos Framework
  • Aptos CLI/SDK
  • Developer Infrastructure
  • Move Compiler
  • Other (specify)

Checklist

  • I have read and followed the CONTRIBUTING doc
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I identified and added all stakeholders and component owners affected by this change as reviewers
  • I tested both happy and unhappy path of the functionality
  • I have made corresponding changes to the documentation

Note

Introduce aptos-trading-natives and experimental 0x7::orders_index (native order placement/matching), wire into VM, and add workloads/tests and docs.

  • Experimental Framework / Move:
    • Add 0x7::orders_index module (enum OrdersIndex, native fns: place_maker_order, is_taker_order, get_single_match_for_taker).
    • Generate docs for orders_index and include in experimental overview.
  • Natives / VM Integration:
    • New crate aptos-trading-natives with orders_index and order_book_types natives (order parsing/matching, packing helpers).
    • Register natives in aptos-vm-environment (under EXPERIMENTAL_CODE_ADDRESS) and add deps in aptos-vm, aptos-vm-environment, aptos-vm-profiling.
    • Extend native-interface helpers with safely_get_struct_variant_field_as! macro.
  • Benchmarks / Tests:
    • Add order_index_example.move and wire new transaction types (OrderIndex*) into transaction-workloads-lib and single_node_performance.py.
    • Route EntryPoints::OrderBook to order_index_example when use_order_index.
  • Tooling / Diagnostics:
    • Add defensive panics in Move builder/verifier paths for missing modules/structs/functions to aid debugging.

Written by Cursor Bugbot for commit 66d385c. This will update automatically on new commits. Configure here.

let is_bid = safely_pop_arg!(args, bool);
let price = safely_pop_arg!(args, u64);

println!("price: {}, is_bid: {}, trigger: {:?}", price, is_bid, trigger_condition);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug println statement left in production code

A println!() debug statement is present in native_is_taker_order that logs price, is_bid, and trigger condition. This debug output will pollute logs in production and may leak internal order information.

Fix in Cursor Fix in Web

panic!(
"Struct {}::{} doesn't yet exist in the cache",
module_id, struct_name
);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Panic statements will crash instead of returning errors

Multiple panic!() calls have been added before return Err(...) statements. Since panic occurs before the return, the code will always crash instead of gracefully returning an error. This affects lookup failure handling in find_struct and import_call_by_name, which will crash the process instead of propagating errors.

Additional Locations (2)

Fix in Cursor Fix in Web

if Some(ModuleHandleIndex(idx as u16)) != self_module
&& !context.dependency_map.contains_key(&module_id)
{
panic!("Couldn't find {} in dependency map", module_id);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Panic statements in bytecode verifier cause crashes

Multiple panic!() calls added before error returns in verify_imported_modules, verify_imported_structs, and verify_imported_functions. These panics execute before the return statements, causing the verifier to crash when encountering missing dependencies instead of returning proper verification errors. This can crash nodes during module verification.

Additional Locations (2)

Fix in Cursor Fix in Web

}
}

static ORDERS_INDEXES_NATIVE_STATE: Lazy<Mutex<OrdersIndexesNativeState>> = Lazy::new(|| Mutex::new(OrdersIndexesNativeState { orders_indexes: BTreeMap::new() }));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Global static state causes incorrect blockchain state isolation

ORDERS_INDEXES_NATIVE_STATE uses a global static Lazy<Mutex<...>> to store order book state. In a blockchain context, this breaks state isolation between transactions, persists state incorrectly across block boundaries, and can cause data inconsistency. Native functions should interact with the Move VM's storage layer rather than using process-global state.

Fix in Cursor Fix in Web

// do something
} else {
self.place_ready_maker_order_with_unique_idx(order_req, ascending_idx)?;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orders with trigger conditions silently discarded

When order_req.trigger_condition.is_some() is true, the place_maker_or_pending_order function has an empty block with just a // do something comment, then returns Ok(()). This means orders with trigger conditions (like stop-loss or time-based orders) are silently discarded while appearing to succeed. The order is never stored and is lost, but the caller receives no error indication.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants