Skip to content

Commit fa4225f

Browse files
committed
Merge branch 'main' into calin/vm-abort-message-2
2 parents cd2c1c1 + 99d5c8d commit fa4225f

File tree

41 files changed

+531
-82
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+531
-82
lines changed

api/test-context/src/test_context.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ pub fn new_test_context_inner(
176176
BUFFERED_STATE_TARGET_ITEMS_FOR_TEST,
177177
DEFAULT_MAX_NUM_NODES_PER_LRU_CACHE_SHARD,
178178
None,
179+
/* reset_hot_state = */ true,
179180
)
180181
.unwrap();
181182
if node_config

aptos-move/aptos-validator-interface/src/storage_interface.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@ impl DBDebuggerInterface {
2525
Ok(Self(Arc::new(
2626
AptosDB::open(
2727
StorageDirPaths::from_path(db_root_path),
28-
true,
28+
/* readonly = */ true,
2929
NO_OP_STORAGE_PRUNER_CONFIG,
3030
RocksdbConfigs::default(),
31-
false, /* indexer */
31+
/* enable_indexer = */ false,
3232
BUFFERED_STATE_TARGET_ITEMS,
3333
DEFAULT_MAX_NUM_NODES_PER_LRU_CACHE_SHARD,
34-
None,
34+
/* internal_indexer_db = */ None,
35+
/* reset_hot_state = */ false,
3536
)
3637
.map_err(anyhow::Error::from)?,
3738
)))

aptos-move/e2e-move-tests/src/tests/code_publishing.data/pack_stdlib/sources/string.move

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ module std::string {
3434
&s.bytes
3535
}
3636

37+
/// Returns the underlying byte vector.
38+
public fun into_bytes(self: String): vector<u8> {
39+
let String { bytes } = self;
40+
bytes
41+
}
42+
3743
/// Checks whether this string is empty.
3844
public fun is_empty(s: &String): bool {
3945
vector::is_empty(&s.bytes)

aptos-move/e2e-move-tests/src/tests/code_publishing.data/pack_stdlib_incompat/sources/string.move

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ module std::string {
3434
&s.bytes
3535
}
3636

37+
/// Returns the underlying byte vector.
38+
public fun into_bytes(self: String): vector<u8> {
39+
let String { bytes } = self;
40+
bytes
41+
}
42+
3743
/// Checks whether this string is empty.
3844
public fun is_empty(s: &String): bool {
3945
vector::is_empty(&s.bytes)

aptos-move/framework/aptos-experimental/doc/single_order_book.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,12 +1255,21 @@ Removes and returns the orders that are ready to be executed based on the time c
12551255
self: &<b>mut</b> <a href="single_order_book.md#0x7_single_order_book_SingleOrderBook">SingleOrderBook</a>&lt;M&gt;, order_limit: u64
12561256
): <a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;SingleOrder&lt;M&gt;&gt; {
12571257
<b>let</b> self_orders = &<b>mut</b> self.orders;
1258+
<b>let</b> self_client_order_ids = &<b>mut</b> self.client_order_ids;
12581259
<b>let</b> order_ids = self.pending_orders.<a href="single_order_book.md#0x7_single_order_book_take_ready_time_based_orders">take_ready_time_based_orders</a>(order_limit);
12591260
<b>let</b> orders = <a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector_empty">vector::empty</a>();
12601261

12611262
order_ids.for_each(|order_id| {
12621263
<b>let</b> order_with_state = self_orders.remove(&order_id);
12631264
<b>let</b> (order, _) = order_with_state.destroy_order_from_state();
1265+
<b>let</b> client_order_id = order.get_client_order_id();
1266+
<b>if</b> (client_order_id.is_some()) {
1267+
self_client_order_ids.remove(
1268+
&new_account_client_order_id(
1269+
order.get_account(), client_order_id.destroy_some()
1270+
)
1271+
);
1272+
};
12641273
orders.push_back(order);
12651274
});
12661275
orders

aptos-move/framework/aptos-experimental/sources/trading/order_book/single_order_book.move

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,12 +537,21 @@ module aptos_experimental::single_order_book {
537537
self: &mut SingleOrderBook<M>, order_limit: u64
538538
): vector<SingleOrder<M>> {
539539
let self_orders = &mut self.orders;
540+
let self_client_order_ids = &mut self.client_order_ids;
540541
let order_ids = self.pending_orders.take_ready_time_based_orders(order_limit);
541542
let orders = vector::empty();
542543

543544
order_ids.for_each(|order_id| {
544545
let order_with_state = self_orders.remove(&order_id);
545546
let (order, _) = order_with_state.destroy_order_from_state();
547+
let client_order_id = order.get_client_order_id();
548+
if (client_order_id.is_some()) {
549+
self_client_order_ids.remove(
550+
&new_account_client_order_id(
551+
order.get_account(), client_order_id.destroy_some()
552+
)
553+
);
554+
};
546555
orders.push_back(order);
547556
});
548557
orders

aptos-move/framework/aptos-experimental/sources/trading/tests/order_book/order_book_client_order_id.move

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
module aptos_experimental::order_book_client_order_id {
33
use std::option;
44
use std::signer;
5-
use aptos_experimental::order_book_types::{new_order_id_type, price_move_up_condition};
5+
use aptos_framework::timestamp;
6+
use aptos_experimental::order_book_types::{new_order_id_type, price_move_up_condition, new_time_based_trigger_condition};
67
use aptos_experimental::order_book_types::good_till_cancelled;
78
use aptos_experimental::order_book::{new_single_order_request, destroy_order_book, set_up_test_with_id};
89

@@ -535,4 +536,51 @@ module aptos_experimental::order_book_client_order_id {
535536
order_book.destroy_order_book();
536537
}
537538

539+
#[test(user1 = @0x456, aptos = @0x1)]
540+
public fun test_client_order_id_cleanup_for_time_based_pending_order(
541+
user1: &signer,
542+
aptos: &signer
543+
) {
544+
// Setup timestamp for time-based triggers
545+
timestamp::set_time_has_started_for_testing(aptos);
546+
timestamp::update_global_time_for_test_secs(1000);
547+
548+
// Setup a basic order book
549+
let order_book = set_up_test_with_id();
550+
let user1_addr = signer::address_of(user1);
551+
let client_order_id = std::string::utf8(b"time_order_1");
552+
let order_id = new_order_id_type(1);
553+
554+
// Create an order request with client order ID and time-based trigger
555+
let order_req =
556+
new_single_order_request(
557+
user1_addr,
558+
order_id,
559+
option::some(client_order_id),
560+
1000, // price
561+
100, // orig_size
562+
100, // remaining_size
563+
true, // is_bid
564+
option::some(new_time_based_trigger_condition(1500)), // trigger_condition - time-based
565+
good_till_cancelled(),
566+
42 // metadata
567+
);
568+
569+
// Place the maker order
570+
order_book.place_maker_order(order_req);
571+
572+
// Advance time to trigger the condition
573+
timestamp::update_global_time_for_test_secs(1600);
574+
575+
// This should remove the pending order from the pending orders map
576+
order_book.take_ready_time_based_orders(1);
577+
578+
// Try cancelling the order - should return none since it was already removed from pending orders
579+
let cancel_result =
580+
order_book.try_cancel_single_order_with_client_order_id(user1_addr, client_order_id);
581+
assert!(cancel_result.is_none());
582+
583+
order_book.destroy_order_book();
584+
}
585+
538586
}

aptos-move/framework/aptos-framework/doc/auth_data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@
209209

210210

211211
<pre><code><b>public</b> <b>fun</b> <a href="auth_data.md#0x1_auth_data_derivable_abstract_signature">derivable_abstract_signature</a>(self: &<a href="auth_data.md#0x1_auth_data_AbstractionAuthData">AbstractionAuthData</a>): &<a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt; {
212-
<b>assert</b>!(self is DerivableV1, <a href="../../aptos-stdlib/../move-stdlib/doc/error.md#0x1_error_invalid_argument">error::invalid_argument</a>(<a href="auth_data.md#0x1_auth_data_ENOT_REGULAR_AUTH_DATA">ENOT_REGULAR_AUTH_DATA</a>));
212+
<b>assert</b>!(self is DerivableV1, <a href="../../aptos-stdlib/../move-stdlib/doc/error.md#0x1_error_invalid_argument">error::invalid_argument</a>(<a href="auth_data.md#0x1_auth_data_ENOT_DERIVABLE_AUTH_DATA">ENOT_DERIVABLE_AUTH_DATA</a>));
213213
&self.abstract_signature
214214
}
215215
</code></pre>

aptos-move/framework/aptos-framework/doc/sui_derivable_account.md

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ Nonce: <digest>
3737
- [Function `split_signature_bytes`](#0x1_sui_derivable_account_split_signature_bytes)
3838
- [Function `derive_account_address_from_public_key`](#0x1_sui_derivable_account_derive_account_address_from_public_key)
3939
- [Function `authenticate_auth_data`](#0x1_sui_derivable_account_authenticate_auth_data)
40+
- [Function `authenticate_auth_data_internal`](#0x1_sui_derivable_account_authenticate_auth_data_internal)
4041
- [Function `authenticate`](#0x1_sui_derivable_account_authenticate)
4142
- [Specification](#@Specification_1)
4243
- [Function `derive_account_address_from_public_key`](#@Specification_1_derive_account_address_from_public_key)
4344
- [Function `authenticate_auth_data`](#@Specification_1_authenticate_auth_data)
45+
- [Function `authenticate_auth_data_internal`](#@Specification_1_authenticate_auth_data_internal)
4446
- [Function `authenticate`](#@Specification_1_authenticate)
4547

4648

@@ -398,6 +400,16 @@ https://github.com/MystenLabs/sui/blob/main/crates/shared-crypto/src/intent.rs#L
398400
## Constants
399401

400402

403+
<a id="0x1_sui_derivable_account_EMALFORMED_DATA"></a>
404+
405+
Malformed data with trailing bytes.
406+
407+
408+
<pre><code><b>const</b> <a href="sui_derivable_account.md#0x1_sui_derivable_account_EMALFORMED_DATA">EMALFORMED_DATA</a>: u64 = 8;
409+
</code></pre>
410+
411+
412+
401413
<a id="0x1_sui_derivable_account_EINVALID_PUBLIC_KEY"></a>
402414

403415
Invalid public key.
@@ -408,6 +420,16 @@ Invalid public key.
408420

409421

410422

423+
<a id="0x1_sui_derivable_account_EDEPRECATED"></a>
424+
425+
Function is deprecated and should not be called.
426+
427+
428+
<pre><code><b>const</b> <a href="sui_derivable_account.md#0x1_sui_derivable_account_EDEPRECATED">EDEPRECATED</a>: u64 = 9;
429+
</code></pre>
430+
431+
432+
411433
<a id="0x1_sui_derivable_account_EMISSING_ENTRY_FUNCTION_PAYLOAD"></a>
412434

413435
Entry function payload is missing.
@@ -515,6 +537,7 @@ serialized <code><a href="sui_derivable_account.md#0x1_sui_derivable_account_Sui
515537
<b>let</b> stream = <a href="../../aptos-stdlib/doc/bcs_stream.md#0x1_bcs_stream_new">bcs_stream::new</a>(*abstract_public_key);
516538
<b>let</b> sui_account_address = <a href="../../aptos-stdlib/doc/bcs_stream.md#0x1_bcs_stream_deserialize_vector">bcs_stream::deserialize_vector</a>&lt;u8&gt;(&<b>mut</b> stream, |x| deserialize_u8(x));
517539
<b>let</b> domain = <a href="../../aptos-stdlib/doc/bcs_stream.md#0x1_bcs_stream_deserialize_vector">bcs_stream::deserialize_vector</a>&lt;u8&gt;(&<b>mut</b> stream, |x| deserialize_u8(x));
540+
<b>assert</b>!(!<a href="../../aptos-stdlib/doc/bcs_stream.md#0x1_bcs_stream_has_remaining">bcs_stream::has_remaining</a>(&<b>mut</b> stream), <a href="sui_derivable_account.md#0x1_sui_derivable_account_EMALFORMED_DATA">EMALFORMED_DATA</a>);
518541
<a href="sui_derivable_account.md#0x1_sui_derivable_account_SuiAbstractPublicKey">SuiAbstractPublicKey</a> { sui_account_address, domain }
519542
}
520543
</code></pre>
@@ -544,6 +567,7 @@ Returns a tuple of the signature.
544567
<b>let</b> signature_type = <a href="../../aptos-stdlib/doc/bcs_stream.md#0x1_bcs_stream_deserialize_u8">bcs_stream::deserialize_u8</a>(&<b>mut</b> stream);
545568
<b>if</b> (signature_type == 0x00) {
546569
<b>let</b> signature = <a href="../../aptos-stdlib/doc/bcs_stream.md#0x1_bcs_stream_deserialize_vector">bcs_stream::deserialize_vector</a>&lt;u8&gt;(&<b>mut</b> stream, |x| deserialize_u8(x));
570+
<b>assert</b>!(!<a href="../../aptos-stdlib/doc/bcs_stream.md#0x1_bcs_stream_has_remaining">bcs_stream::has_remaining</a>(&<b>mut</b> stream), <a href="sui_derivable_account.md#0x1_sui_derivable_account_EMALFORMED_DATA">EMALFORMED_DATA</a>);
547571
SuiAbstractSignature::MessageV1 { signature }
548572
} <b>else</b> {
549573
<b>abort</b>(<a href="sui_derivable_account.md#0x1_sui_derivable_account_EINVALID_SIGNATURE_TYPE">EINVALID_SIGNATURE_TYPE</a>)
@@ -652,9 +676,10 @@ Derives the account address from the public key and returns it is a hex string w
652676

653677
## Function `authenticate_auth_data`
654678

679+
@deprecated This function is deprecated and will always abort.
655680

656681

657-
<pre><code><b>public</b> <b>fun</b> <a href="sui_derivable_account.md#0x1_sui_derivable_account_authenticate_auth_data">authenticate_auth_data</a>(aa_auth_data: <a href="auth_data.md#0x1_auth_data_AbstractionAuthData">auth_data::AbstractionAuthData</a>, entry_function_name: &<a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;)
682+
<pre><code><b>public</b> <b>fun</b> <a href="sui_derivable_account.md#0x1_sui_derivable_account_authenticate_auth_data">authenticate_auth_data</a>(_aa_auth_data: <a href="auth_data.md#0x1_auth_data_AbstractionAuthData">auth_data::AbstractionAuthData</a>, _entry_function_name: &<a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;)
658683
</code></pre>
659684

660685

@@ -664,6 +689,33 @@ Derives the account address from the public key and returns it is a hex string w
664689

665690

666691
<pre><code><b>public</b> <b>fun</b> <a href="sui_derivable_account.md#0x1_sui_derivable_account_authenticate_auth_data">authenticate_auth_data</a>(
692+
_aa_auth_data: AbstractionAuthData,
693+
_entry_function_name: &<a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;
694+
) {
695+
<b>abort</b>(<a href="sui_derivable_account.md#0x1_sui_derivable_account_EDEPRECATED">EDEPRECATED</a>)
696+
}
697+
</code></pre>
698+
699+
700+
701+
</details>
702+
703+
<a id="0x1_sui_derivable_account_authenticate_auth_data_internal"></a>
704+
705+
## Function `authenticate_auth_data_internal`
706+
707+
708+
709+
<pre><code><b>fun</b> <a href="sui_derivable_account.md#0x1_sui_derivable_account_authenticate_auth_data_internal">authenticate_auth_data_internal</a>(aa_auth_data: <a href="auth_data.md#0x1_auth_data_AbstractionAuthData">auth_data::AbstractionAuthData</a>, entry_function_name: &<a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;)
710+
</code></pre>
711+
712+
713+
714+
<details>
715+
<summary>Implementation</summary>
716+
717+
718+
<pre><code><b>fun</b> <a href="sui_derivable_account.md#0x1_sui_derivable_account_authenticate_auth_data_internal">authenticate_auth_data_internal</a>(
667719
aa_auth_data: AbstractionAuthData,
668720
entry_function_name: &<a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;
669721
) {
@@ -739,7 +791,7 @@ Authorization function for domain account abstraction.
739791

740792

741793
<pre><code><b>public</b> <b>fun</b> <a href="sui_derivable_account.md#0x1_sui_derivable_account_authenticate">authenticate</a>(<a href="account.md#0x1_account">account</a>: <a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, aa_auth_data: AbstractionAuthData): <a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a> {
742-
daa_authenticate(<a href="account.md#0x1_account">account</a>, aa_auth_data, |<a href="auth_data.md#0x1_auth_data">auth_data</a>, entry_name| <a href="sui_derivable_account.md#0x1_sui_derivable_account_authenticate_auth_data">authenticate_auth_data</a>(<a href="auth_data.md#0x1_auth_data">auth_data</a>, entry_name))
794+
daa_authenticate(<a href="account.md#0x1_account">account</a>, aa_auth_data, |<a href="auth_data.md#0x1_auth_data">auth_data</a>, entry_name| <a href="sui_derivable_account.md#0x1_sui_derivable_account_authenticate_auth_data_internal">authenticate_auth_data_internal</a>(<a href="auth_data.md#0x1_auth_data">auth_data</a>, entry_name))
743795
}
744796
</code></pre>
745797

@@ -773,7 +825,23 @@ Authorization function for domain account abstraction.
773825
### Function `authenticate_auth_data`
774826

775827

776-
<pre><code><b>public</b> <b>fun</b> <a href="sui_derivable_account.md#0x1_sui_derivable_account_authenticate_auth_data">authenticate_auth_data</a>(aa_auth_data: <a href="auth_data.md#0x1_auth_data_AbstractionAuthData">auth_data::AbstractionAuthData</a>, entry_function_name: &<a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;)
828+
<pre><code><b>public</b> <b>fun</b> <a href="sui_derivable_account.md#0x1_sui_derivable_account_authenticate_auth_data">authenticate_auth_data</a>(_aa_auth_data: <a href="auth_data.md#0x1_auth_data_AbstractionAuthData">auth_data::AbstractionAuthData</a>, _entry_function_name: &<a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;)
829+
</code></pre>
830+
831+
832+
833+
834+
<pre><code><b>pragma</b> verify = <b>false</b>;
835+
</code></pre>
836+
837+
838+
839+
<a id="@Specification_1_authenticate_auth_data_internal"></a>
840+
841+
### Function `authenticate_auth_data_internal`
842+
843+
844+
<pre><code><b>fun</b> <a href="sui_derivable_account.md#0x1_sui_derivable_account_authenticate_auth_data_internal">authenticate_auth_data_internal</a>(aa_auth_data: <a href="auth_data.md#0x1_auth_data_AbstractionAuthData">auth_data::AbstractionAuthData</a>, entry_function_name: &<a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;)
777845
</code></pre>
778846

779847

aptos-move/framework/aptos-framework/sources/account/auth_data.move

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ module aptos_framework::auth_data {
4747
}
4848

4949
public fun derivable_abstract_signature(self: &AbstractionAuthData): &vector<u8> {
50-
assert!(self is DerivableV1, error::invalid_argument(ENOT_REGULAR_AUTH_DATA));
50+
assert!(self is DerivableV1, error::invalid_argument(ENOT_DERIVABLE_AUTH_DATA));
5151
&self.abstract_signature
5252
}
5353

0 commit comments

Comments
 (0)