From 3ba4d446a8630618c8c953b2bde8eb04e39fa6e9 Mon Sep 17 00:00:00 2001 From: akhercha Date: Thu, 5 Dec 2024 14:14:58 +0100 Subject: [PATCH 1/2] feat(oracle_rewrite): --- crates/accounts/src/oracle/oracle.masm | 2 ++ crates/accounts/tests/test_oracle.rs | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/accounts/src/oracle/oracle.masm b/crates/accounts/src/oracle/oracle.masm index 012cdb8..7402fd7 100644 --- a/crates/accounts/src/oracle/oracle.masm +++ b/crates/accounts/src/oracle/oracle.masm @@ -282,6 +282,8 @@ export.get_median # increments the nonce (anyone should be able to call that function) push.1 exec.account::incr_nonce + + exec.sys::truncate_stack end #! Registers a new publishers into the Oracle. diff --git a/crates/accounts/tests/test_oracle.rs b/crates/accounts/tests/test_oracle.rs index ab98613..3716b4d 100644 --- a/crates/accounts/tests/test_oracle.rs +++ b/crates/accounts/tests/test_oracle.rs @@ -265,8 +265,6 @@ fn test_oracle_get_median() { expected_median = expected_median ); - println!("{}", tx_script_code); - let tx_script = TransactionScript::compile( tx_script_code, [], From b7020d7715d62464a51d06f45f2db8fae464f263 Mon Sep 17 00:00:00 2001 From: akhercha Date: Thu, 5 Dec 2024 14:19:21 +0100 Subject: [PATCH 2/2] feat(oracle_rewrite): Smol comments refactoring --- crates/accounts/src/oracle/oracle.masm | 54 +++++++++++++------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/crates/accounts/src/oracle/oracle.masm b/crates/accounts/src/oracle/oracle.masm index 7402fd7..34a62ce 100644 --- a/crates/accounts/src/oracle/oracle.masm +++ b/crates/accounts/src/oracle/oracle.masm @@ -101,65 +101,65 @@ proc.ram_bubble_sort dup # => [N, N] sub.1 dup - # => [N-1(i),N-1(i),N] + # => [N-1(i), N-1(i), N] push.1 - # => [1,N-1(i),N-1(i),N] + # => [1, N-1(i), N-1(i), N] gt while.true - # => [N-1(i),N] + # => [N-1(i), N] dup - # => [N-1(i),N-1(i),N] + # => [N-1(i), N-1(i), N] # => Inner index push.0 - # => [0(j), N-1(i),N-1(i),N] + # => [0(j), N-1(i), N-1(i), N] dup - # => [0(j),0(j), N-1(i),N-1(i),N] + # => [0(j), 0(j), N-1(i), N-1(i), N] swap.2 - # => [N-1(i),0(j),0(j),N-1(i),N] + # => [N-1(i), 0(j), 0(j), N-1(i), N] # We exit this loop if j > i-1 lte - # => [bool,N-1(i),0(j),N] + # => [bool, N-1(i), 0(j), N] while.true - # => [0(j),N-1(i),N] + # => [0(j), N-1(i), N] dup - # => [0(j),0(j),N-1(i),N] + # => [0(j), 0(j), N-1(i), N] add.1 - # => [0(j)+1,0(j),N-1(i),N] + # => [0(j)+1, 0(j), N-1(i), N] swap - # => [0(j),0(j)+1,N-1(i),N] + # => [0(j), 0(j)+1, N-1(i), N] exec.ram_is_lower - # => [bool, 0(j),0(j)+1,N-1(i),N] + # => [bool, 0(j), 0(j)+1, N-1(i), N] if.true else dup - # => [0(j),0(j),0(j)+1,N-1(i),N] + # => [0(j), 0(j), 0(j)+1, N-1(i), N] dup.2 - # => [0(j)+1,0(j),0(j),0(j)+1,N-1(i),N] + # => [0(j)+1, 0(j), 0(j), 0(j)+1, N-1(i), N] swap - # => [0(j),0(j)+1,0(j),0(j)+1,N-1(i),N] + # => [0(j), 0(j)+1, 0(j), 0(j)+1, N-1(i), N] exec.ram_swap - # => [0(j),0(j)+1,N-1(i),N] + # => [0(j), 0(j)+1, N-1(i), N] end drop - # => [0(j)+1,N-1(i),N] + # => [0(j)+1, N-1(i), N] dup - # => [0(j)+1,0(j)+1,N-1(i),N] + # => [0(j)+1, 0(j)+1, N-1(i), N] dup.2 - # => [N-1(i),0(j)+1,0(j)+1,N-1(i),N] + # => [N-1(i), 0(j)+1, 0(j)+1, N-1(i), N] lt - # => [bool,0(j)+1,N-1(i),N] + # => [bool, 0(j)+1, N-1(i), N] end - # => [0(j)+1,N-1(i),N] + # => [0(j)+1, N-1(i), N] drop - # => [N-1(i),N] + # => [N-1(i), N] sub.1 - # => [N-2(i-1),N] + # => [N-2(i-1), N] dup - # => [N-2(i-1),N-2(i-1),N] + # => [N-2(i-1), N-2(i-1), N] push.1 - # => [1,N-2(i-1),N-2(i-1),N] + # => [1, N-2(i-1), N-2(i-1), N] gte - # => [bool,N-2(i-1),N] + # => [bool, N-2(i-1), N] end drop end