mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 08:01:09 +00:00
Rework the event system of sc-network (#1370)
This commit introduces a new concept called `NotificationService` which allows Polkadot protocols to communicate with the underlying notification protocol implementation directly, without routing events through `NetworkWorker`. This implies that each protocol has its own service which it uses to communicate with remote peers and that each `NotificationService` is unique with respect to the underlying notification protocol, meaning `NotificationService` for the transaction protocol can only be used to send and receive transaction-related notifications. The `NotificationService` concept introduces two additional benefits: * allow protocols to start using custom handshakes * allow protocols to accept/reject inbound peers Previously the validation of inbound connections was solely the responsibility of `ProtocolController`. This caused issues with light peers and `SyncingEngine` as `ProtocolController` would accept more peers than `SyncingEngine` could accept which caused peers to have differing views of their own states. `SyncingEngine` would reject excess peers but these rejections were not properly communicated to those peers causing them to assume that they were accepted. With `NotificationService`, the local handshake is not sent to remote peer if peer is rejected which allows it to detect that it was rejected. This commit also deprecates the use of `NetworkEventStream` for all notification-related events and going forward only DHT events are provided through `NetworkEventStream`. If protocols wish to follow each other's events, they must introduce additional abtractions, as is done for GRANDPA and transactions protocols by following the syncing protocol through `SyncEventStream`. Fixes https://github.com/paritytech/polkadot-sdk/issues/512 Fixes https://github.com/paritytech/polkadot-sdk/issues/514 Fixes https://github.com/paritytech/polkadot-sdk/issues/515 Fixes https://github.com/paritytech/polkadot-sdk/issues/554 Fixes https://github.com/paritytech/polkadot-sdk/issues/556 --- These changes are transferred from https://github.com/paritytech/substrate/pull/14197 but there are no functional changes compared to that PR --------- Co-authored-by: Dmitry Markin <dmitry@markin.tech> Co-authored-by: Alexandru Vasile <60601340+lexnv@users.noreply.github.com>
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
@@ -44,8 +44,8 @@
|
||||
;; [0..4) - size of the call
|
||||
;; [4..8) - action to perform
|
||||
;; [8..42) - code hash of the callee
|
||||
(set_local $action (i32.load (i32.const 4)))
|
||||
(set_local $code_hash_ptr (i32.const 8))
|
||||
(local.set $action (i32.load (i32.const 4)))
|
||||
(local.set $code_hash_ptr (i32.const 8))
|
||||
|
||||
;; Assert input size == 36 (4 for action + 32 for code_hash).
|
||||
(call $assert
|
||||
@@ -56,25 +56,25 @@
|
||||
)
|
||||
|
||||
;; Call add_delegate_dependency when action == 1.
|
||||
(if (i32.eq (get_local $action) (i32.const 1))
|
||||
(if (i32.eq (local.get $action) (i32.const 1))
|
||||
(then
|
||||
(call $add_delegate_dependency (get_local $code_hash_ptr))
|
||||
(call $add_delegate_dependency (local.get $code_hash_ptr))
|
||||
)
|
||||
(else)
|
||||
)
|
||||
|
||||
;; Call remove_delegate_dependency when action == 2.
|
||||
(if (i32.eq (get_local $action) (i32.const 2))
|
||||
(if (i32.eq (local.get $action) (i32.const 2))
|
||||
(then
|
||||
(call $remove_delegate_dependency
|
||||
(get_local $code_hash_ptr)
|
||||
(local.get $code_hash_ptr)
|
||||
)
|
||||
)
|
||||
(else)
|
||||
)
|
||||
|
||||
;; Call terminate when action == 3.
|
||||
(if (i32.eq (get_local $action) (i32.const 3))
|
||||
(if (i32.eq (local.get $action) (i32.const 3))
|
||||
(then
|
||||
(call $terminate
|
||||
(i32.const 100) ;; Pointer to beneficiary address
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok (get_local 0))
|
||||
(br_if $ok (local.get 0))
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
@@ -37,10 +37,10 @@
|
||||
)
|
||||
|
||||
;; Read current balance into local variable.
|
||||
(set_local $sp (i32.const 1024))
|
||||
(local.set $sp (i32.const 1024))
|
||||
|
||||
;; Fail to deploy the contract since it returns a non-zero exit status.
|
||||
(set_local $exit_code
|
||||
(local.set $exit_code
|
||||
(call $seal_instantiate
|
||||
(i32.const 24) ;; Pointer to the code hash.
|
||||
(i64.const 0) ;; How much ref_time weight to devote for the execution. 0 = all.
|
||||
@@ -60,11 +60,11 @@
|
||||
|
||||
;; Check non-zero exit status.
|
||||
(call $assert
|
||||
(i32.eq (get_local $exit_code) (i32.const 2)) ;; ReturnCode::CalleeReverted
|
||||
(i32.eq (local.get $exit_code) (i32.const 2)) ;; ReturnCode::CalleeReverted
|
||||
)
|
||||
|
||||
;; Fail to deploy the contract due to insufficient ref_time weight.
|
||||
(set_local $exit_code
|
||||
(local.set $exit_code
|
||||
(call $seal_instantiate
|
||||
(i32.const 24) ;; Pointer to the code hash.
|
||||
(i64.const 1) ;; Supply too little ref_time weight
|
||||
@@ -85,11 +85,11 @@
|
||||
|
||||
;; Check for special trap exit status.
|
||||
(call $assert
|
||||
(i32.eq (get_local $exit_code) (i32.const 1)) ;; ReturnCode::CalleeTrapped
|
||||
(i32.eq (local.get $exit_code) (i32.const 1)) ;; ReturnCode::CalleeTrapped
|
||||
)
|
||||
|
||||
;; Fail to deploy the contract due to insufficient ref_time weight.
|
||||
(set_local $exit_code
|
||||
(local.set $exit_code
|
||||
(call $seal_instantiate
|
||||
(i32.const 24) ;; Pointer to the code hash.
|
||||
(i64.const 0) ;; How much ref_time weight to devote for the execution. 0 = all.
|
||||
@@ -110,17 +110,17 @@
|
||||
|
||||
;; Check for special trap exit status.
|
||||
(call $assert
|
||||
(i32.eq (get_local $exit_code) (i32.const 1)) ;; ReturnCode::CalleeTrapped
|
||||
(i32.eq (local.get $exit_code) (i32.const 1)) ;; ReturnCode::CalleeTrapped
|
||||
)
|
||||
|
||||
;; Length of the output buffer
|
||||
(i32.store
|
||||
(i32.sub (get_local $sp) (i32.const 4))
|
||||
(i32.sub (local.get $sp) (i32.const 4))
|
||||
(i32.const 256)
|
||||
)
|
||||
|
||||
;; Deploy the contract successfully.
|
||||
(set_local $exit_code
|
||||
(local.set $exit_code
|
||||
(call $seal_instantiate
|
||||
(i32.const 24) ;; Pointer to the code hash.
|
||||
(i64.const 0) ;; How much ref_time weight to devote for the execution. 0 = all.
|
||||
@@ -130,7 +130,7 @@
|
||||
(i32.const 8) ;; Pointer to input data buffer address
|
||||
(i32.const 8) ;; Length of input data buffer
|
||||
(i32.const 16) ;; Pointer to the address output buffer
|
||||
(i32.sub (get_local $sp) (i32.const 4)) ;; Pointer to the address buffer length
|
||||
(i32.sub (local.get $sp) (i32.const 4)) ;; Pointer to the address buffer length
|
||||
(i32.const 4294967295) ;; u32 max sentinel value: do not copy output
|
||||
(i32.const 0) ;; Length is ignored in this case
|
||||
(i32.const 0) ;; salt_ptr
|
||||
@@ -141,28 +141,28 @@
|
||||
|
||||
;; Check for success exit status.
|
||||
(call $assert
|
||||
(i32.eq (get_local $exit_code) (i32.const 0)) ;; ReturnCode::Success
|
||||
(i32.eq (local.get $exit_code) (i32.const 0)) ;; ReturnCode::Success
|
||||
)
|
||||
|
||||
;; Check that address has the expected length
|
||||
(call $assert
|
||||
(i32.eq (i32.load (i32.sub (get_local $sp) (i32.const 4))) (i32.const 32))
|
||||
(i32.eq (i32.load (i32.sub (local.get $sp) (i32.const 4))) (i32.const 32))
|
||||
)
|
||||
|
||||
;; Zero out destination buffer of output
|
||||
(i32.store
|
||||
(i32.sub (get_local $sp) (i32.const 4))
|
||||
(i32.sub (local.get $sp) (i32.const 4))
|
||||
(i32.const 0)
|
||||
)
|
||||
|
||||
;; Length of the output buffer
|
||||
(i32.store
|
||||
(i32.sub (get_local $sp) (i32.const 8))
|
||||
(i32.sub (local.get $sp) (i32.const 8))
|
||||
(i32.const 4)
|
||||
)
|
||||
|
||||
;; Call the new contract and expect it to return failing exit code.
|
||||
(set_local $exit_code
|
||||
(local.set $exit_code
|
||||
(call $seal_call
|
||||
(i32.const 0) ;; Set no flag
|
||||
(i32.const 16) ;; Pointer to "callee" address.
|
||||
@@ -172,29 +172,29 @@
|
||||
(i32.const 0) ;; Pointer to the buffer with value to transfer
|
||||
(i32.const 9) ;; Pointer to input data buffer address
|
||||
(i32.const 7) ;; Length of input data buffer
|
||||
(i32.sub (get_local $sp) (i32.const 4)) ;; Ptr to output buffer
|
||||
(i32.sub (get_local $sp) (i32.const 8)) ;; Ptr to output buffer len
|
||||
(i32.sub (local.get $sp) (i32.const 4)) ;; Ptr to output buffer
|
||||
(i32.sub (local.get $sp) (i32.const 8)) ;; Ptr to output buffer len
|
||||
)
|
||||
)
|
||||
|
||||
;; Check non-zero exit status.
|
||||
(call $assert
|
||||
(i32.eq (get_local $exit_code) (i32.const 2)) ;; ReturnCode::CalleeReverted
|
||||
(i32.eq (local.get $exit_code) (i32.const 2)) ;; ReturnCode::CalleeReverted
|
||||
)
|
||||
|
||||
;; Check that output buffer contains the expected return data.
|
||||
(call $assert
|
||||
(i32.eq (i32.load (i32.sub (get_local $sp) (i32.const 8))) (i32.const 3))
|
||||
(i32.eq (i32.load (i32.sub (local.get $sp) (i32.const 8))) (i32.const 3))
|
||||
)
|
||||
(call $assert
|
||||
(i32.eq
|
||||
(i32.load (i32.sub (get_local $sp) (i32.const 4)))
|
||||
(i32.load (i32.sub (local.get $sp) (i32.const 4)))
|
||||
(i32.const 0x00776655)
|
||||
)
|
||||
)
|
||||
|
||||
;; Fail to call the contract due to insufficient ref_time weight.
|
||||
(set_local $exit_code
|
||||
(local.set $exit_code
|
||||
(call $seal_call
|
||||
(i32.const 0) ;; Set no flag
|
||||
(i32.const 16) ;; Pointer to "callee" address.
|
||||
@@ -211,11 +211,11 @@
|
||||
|
||||
;; Check for special trap exit status.
|
||||
(call $assert
|
||||
(i32.eq (get_local $exit_code) (i32.const 1)) ;; ReturnCode::CalleeTrapped
|
||||
(i32.eq (local.get $exit_code) (i32.const 1)) ;; ReturnCode::CalleeTrapped
|
||||
)
|
||||
|
||||
;; Fail to call the contract due to insufficient proof_size weight.
|
||||
(set_local $exit_code
|
||||
(local.set $exit_code
|
||||
(call $seal_call
|
||||
(i32.const 0) ;; Set no flag
|
||||
(i32.const 16) ;; Pointer to "callee" address.
|
||||
@@ -232,23 +232,23 @@
|
||||
|
||||
;; Check for special trap exit status.
|
||||
(call $assert
|
||||
(i32.eq (get_local $exit_code) (i32.const 1)) ;; ReturnCode::CalleeTrapped
|
||||
(i32.eq (local.get $exit_code) (i32.const 1)) ;; ReturnCode::CalleeTrapped
|
||||
)
|
||||
|
||||
;; Zero out destination buffer of output
|
||||
(i32.store
|
||||
(i32.sub (get_local $sp) (i32.const 4))
|
||||
(i32.sub (local.get $sp) (i32.const 4))
|
||||
(i32.const 0)
|
||||
)
|
||||
|
||||
;; Length of the output buffer
|
||||
(i32.store
|
||||
(i32.sub (get_local $sp) (i32.const 8))
|
||||
(i32.sub (local.get $sp) (i32.const 8))
|
||||
(i32.const 4)
|
||||
)
|
||||
|
||||
;; Call the contract successfully.
|
||||
(set_local $exit_code
|
||||
(local.set $exit_code
|
||||
(call $seal_call
|
||||
(i32.const 0) ;; Set no flag
|
||||
(i32.const 16) ;; Pointer to "callee" address.
|
||||
@@ -258,23 +258,23 @@
|
||||
(i32.const 0) ;; Pointer to the buffer with value to transfer
|
||||
(i32.const 8) ;; Pointer to input data buffer address
|
||||
(i32.const 8) ;; Length of input data buffer
|
||||
(i32.sub (get_local $sp) (i32.const 4)) ;; Ptr to output buffer
|
||||
(i32.sub (get_local $sp) (i32.const 8)) ;; Ptr to output buffer len
|
||||
(i32.sub (local.get $sp) (i32.const 4)) ;; Ptr to output buffer
|
||||
(i32.sub (local.get $sp) (i32.const 8)) ;; Ptr to output buffer len
|
||||
)
|
||||
)
|
||||
|
||||
;; Check for success exit status.
|
||||
(call $assert
|
||||
(i32.eq (get_local $exit_code) (i32.const 0)) ;; ReturnCode::Success
|
||||
(i32.eq (local.get $exit_code) (i32.const 0)) ;; ReturnCode::Success
|
||||
)
|
||||
|
||||
;; Check that the output buffer contains the expected return data.
|
||||
(call $assert
|
||||
(i32.eq (i32.load (i32.sub (get_local $sp) (i32.const 8))) (i32.const 4))
|
||||
(i32.eq (i32.load (i32.sub (local.get $sp) (i32.const 8))) (i32.const 4))
|
||||
)
|
||||
(call $assert
|
||||
(i32.eq
|
||||
(i32.load (i32.sub (get_local $sp) (i32.const 4)))
|
||||
(i32.load (i32.sub (local.get $sp) (i32.const 4)))
|
||||
(i32.const 0x77665544)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok (get_local 0))
|
||||
(br_if $ok (local.get 0))
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok (get_local 0))
|
||||
(br_if $ok (local.get 0))
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
|
||||
@@ -59,8 +59,10 @@
|
||||
(call $seal_input (local.get $input_ptr) (local.get $input_len_ptr))
|
||||
(local.set $chosen_hash_fn (i32.load8_u (local.get $input_ptr)))
|
||||
(if (i32.gt_u (local.get $chosen_hash_fn) (i32.const 7))
|
||||
;; We check that the chosen hash fn identifier is within bounds: [0,7]
|
||||
(unreachable)
|
||||
(then
|
||||
;; We check that the chosen hash fn identifier is within bounds: [0,7]
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(local.set $input_ptr (i32.add (local.get $input_ptr) (i32.const 1)))
|
||||
(local.set $input_len (i32.sub (i32.load (local.get $input_len_ptr)) (i32.const 1)))
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
(func $assert_eq (param i32 i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(i32.eq (get_local 0) (get_local 1))
|
||||
(i32.eq (local.get 0) (local.get 1))
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
(func $assert_eq (param i32 i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(i32.eq (get_local 0) (get_local 1))
|
||||
(i32.eq (local.get 0) (local.get 1))
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
(func $assert_eq (param i32 i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(i32.eq (get_local 0) (get_local 1))
|
||||
(i32.eq (local.get 0) (local.get 1))
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
@@ -70,7 +70,7 @@
|
||||
)
|
||||
|
||||
;; Call deployed library contract code.
|
||||
(set_local $exit_code
|
||||
(local.set $exit_code
|
||||
(call $seal_delegate_call
|
||||
(i32.const 0) ;; Set no call flags
|
||||
(i32.const 64) ;; Pointer to "callee" code_hash.
|
||||
@@ -83,7 +83,7 @@
|
||||
|
||||
;; Check for success exit status.
|
||||
(call $assert
|
||||
(i32.eq (get_local $exit_code) (i32.const 0)) ;; ReturnCode::Success
|
||||
(i32.eq (local.get $exit_code) (i32.const 0)) ;; ReturnCode::Success
|
||||
)
|
||||
|
||||
(call $assert
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
@@ -36,11 +36,11 @@
|
||||
(call $seal_input (i32.const 32) (i32.const 36))
|
||||
|
||||
;; reading manually passed reentrant count
|
||||
(set_local $expected_reentrance_count (i32.load (i32.const 32)))
|
||||
(local.set $expected_reentrance_count (i32.load (i32.const 32)))
|
||||
|
||||
;; reentrance count is calculated correctly
|
||||
(call $assert
|
||||
(i32.eq (call $reentrance_count) (get_local $expected_reentrance_count))
|
||||
(i32.eq (call $reentrance_count) (local.get $expected_reentrance_count))
|
||||
)
|
||||
|
||||
;; re-enter 5 times in a row and assert that the reentrant counter works as expected
|
||||
@@ -52,7 +52,7 @@
|
||||
(i32.store (i32.const 32) (i32.add (i32.load (i32.const 32)) (i32.const 1)))
|
||||
|
||||
;; Call to itself
|
||||
(set_local $seal_call_exit_code
|
||||
(local.set $seal_call_exit_code
|
||||
(call $seal_call
|
||||
(i32.const 8) ;; Allow reentrancy flag set
|
||||
(i32.const 0) ;; Pointer to "callee" address
|
||||
@@ -66,7 +66,7 @@
|
||||
)
|
||||
|
||||
(call $assert
|
||||
(i32.eq (get_local $seal_call_exit_code) (i32.const 0))
|
||||
(i32.eq (local.get $seal_call_exit_code) (i32.const 0))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
@@ -30,7 +30,7 @@
|
||||
(call $seal_input (i32.const 0) (i32.const 36))
|
||||
|
||||
;; reading passed callstack height
|
||||
(set_local $callstack_height (i32.load (i32.const 32)))
|
||||
(local.set $callstack_height (i32.load (i32.const 32)))
|
||||
|
||||
;; incrementing callstack height
|
||||
(i32.store (i32.const 32) (i32.add (i32.load (i32.const 32)) (i32.const 1)))
|
||||
@@ -40,12 +40,12 @@
|
||||
(i32.eq (call $reentrance_count) (i32.const 0))
|
||||
)
|
||||
|
||||
(i32.eq (get_local $callstack_height) (i32.const 5))
|
||||
(i32.eq (local.get $callstack_height) (i32.const 5))
|
||||
(if
|
||||
(then) ;; exit recursion case
|
||||
(else
|
||||
;; Call to itself
|
||||
(set_local $delegate_call_exit_code
|
||||
(local.set $delegate_call_exit_code
|
||||
(call $seal_delegate_call
|
||||
(i32.const 0) ;; Set no call flags
|
||||
(i32.const 0) ;; Pointer to "callee" code_hash.
|
||||
@@ -57,13 +57,13 @@
|
||||
)
|
||||
|
||||
(call $assert
|
||||
(i32.eq (get_local $delegate_call_exit_code) (i32.const 0))
|
||||
(i32.eq (local.get $delegate_call_exit_code) (i32.const 0))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(call $assert
|
||||
(i32.le_s (get_local $callstack_height) (i32.const 5))
|
||||
(i32.le_s (local.get $callstack_height) (i32.const 5))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
@@ -27,11 +27,11 @@
|
||||
|
||||
(call $seal_input (i32.const 0) (i32.const 32))
|
||||
|
||||
(set_local $exit_code
|
||||
(local.set $exit_code
|
||||
(call $seal_set_code_hash (i32.const 0)) ;; Pointer to the input data.
|
||||
)
|
||||
(call $assert
|
||||
(i32.eq (get_local $exit_code) (i32.const 0)) ;; ReturnCode::Success
|
||||
(i32.eq (local.get $exit_code) (i32.const 0)) ;; ReturnCode::Success
|
||||
)
|
||||
|
||||
;; we return 1 after setting new code_hash
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
|
||||
@@ -1506,7 +1506,7 @@ mod tests {
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
@@ -1531,7 +1531,7 @@ mod tests {
|
||||
)
|
||||
|
||||
;; Find out the size of the buffer
|
||||
(set_local $buf_size
|
||||
(local.set $buf_size
|
||||
(i32.load (i32.const 32))
|
||||
)
|
||||
|
||||
@@ -1539,7 +1539,7 @@ mod tests {
|
||||
(call $seal_return
|
||||
(i32.const 0)
|
||||
(i32.const 36)
|
||||
(get_local $buf_size)
|
||||
(local.get $buf_size)
|
||||
)
|
||||
|
||||
;; env:seal_return doesn't return, so this is effectively unreachable.
|
||||
@@ -1575,7 +1575,7 @@ mod tests {
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
@@ -1633,7 +1633,7 @@ mod tests {
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
@@ -1680,7 +1680,7 @@ mod tests {
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
@@ -1726,7 +1726,7 @@ mod tests {
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
@@ -1773,7 +1773,7 @@ mod tests {
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
@@ -1836,7 +1836,7 @@ mod tests {
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
@@ -1925,7 +1925,7 @@ mod tests {
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
@@ -1966,7 +1966,7 @@ mod tests {
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
@@ -2013,7 +2013,7 @@ mod tests {
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
@@ -2067,7 +2067,7 @@ mod tests {
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
@@ -2137,7 +2137,7 @@ mod tests {
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
@@ -2327,7 +2327,7 @@ mod tests {
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
@@ -2995,7 +2995,7 @@ mod tests {
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
@@ -3047,7 +3047,7 @@ mod tests {
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
@@ -3162,18 +3162,18 @@ mod tests {
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(func (export "call")
|
||||
(local $exit_code i32)
|
||||
(set_local $exit_code
|
||||
(local.set $exit_code
|
||||
(call $seal_set_code_hash (i32.const 0))
|
||||
)
|
||||
(call $assert
|
||||
(i32.eq (get_local $exit_code) (i32.const 0)) ;; ReturnCode::Success
|
||||
(i32.eq (local.get $exit_code) (i32.const 0)) ;; ReturnCode::Success
|
||||
)
|
||||
)
|
||||
|
||||
@@ -3202,18 +3202,18 @@ mod tests {
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(func (export "call")
|
||||
(local $return_val i32)
|
||||
(set_local $return_val
|
||||
(local.set $return_val
|
||||
(call $reentrance_count)
|
||||
)
|
||||
(call $assert
|
||||
(i32.eq (get_local $return_val) (i32.const 12))
|
||||
(i32.eq (local.get $return_val) (i32.const 12))
|
||||
)
|
||||
)
|
||||
|
||||
@@ -3234,18 +3234,18 @@ mod tests {
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(func (export "call")
|
||||
(local $return_val i32)
|
||||
(set_local $return_val
|
||||
(local.set $return_val
|
||||
(call $account_reentrance_count (i32.const 0))
|
||||
)
|
||||
(call $assert
|
||||
(i32.eq (get_local $return_val) (i32.const 12))
|
||||
(i32.eq (local.get $return_val) (i32.const 12))
|
||||
)
|
||||
)
|
||||
|
||||
@@ -3267,7 +3267,7 @@ mod tests {
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
(local.get 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user