This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
seal_reentrant_count returns contract reentrant count
#11539
Closed
Closed
Changes from 11 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
a8214fd
Add logic, test, broken benchmark
yarikbratashchuk 143c158
Merge branch 'master' into seal_reentrant_count
yarikbratashchuk 219eb84
Merge branch 'master' into seal_reentrant_count
yarikbratashchuk fccd751
account_entrance_count
yarikbratashchuk 0a70239
Addressing comments
yarikbratashchuk 6f3655a
Address @agryaznov's comments
yarikbratashchuk f29884b
Add test for account_entrance_count, fix ci
yarikbratashchuk 72c8f83
Cargo fmt
yarikbratashchuk 0f6f894
Fix tests
yarikbratashchuk 949c438
Fix tests
yarikbratashchuk f34b6da
Remove delegated call from test, address comments
yarikbratashchuk a036585
Minor fixes and indentation in wat files
yarikbratashchuk 3be772e
Update test for account_entrance_count
yarikbratashchuk 5fdc100
Update reentrant_count_call test
yarikbratashchuk b656c88
Delegate call test
yarikbratashchuk 17bb81f
Cargo +nightly fmt
yarikbratashchuk 2f7f405
Address comments
yarikbratashchuk 5f01797
Update reentrant_count_works test
yarikbratashchuk 013e3bf
Merge branch 'master' into master
yarikbratashchuk 3948142
Apply weights diff
yarikbratashchuk 9c0c06f
Add fixture descriptions
yarikbratashchuk 9c5bb47
Update comments as suggested
yarikbratashchuk 35c0349
Update reentrant_count_call test to use seal_address
yarikbratashchuk 3400632
Merge branch 'paritytech:master' into master
RustNinja ebde8e1
Merge branch 'paritytech:master' into master
Artemka374 321a828
change account_entrance_count_call fixture to use seal_caller
Artemka374 ee63f37
Merge remote-tracking branch 'paritytech/master'
Artemka374 3463795
fix compilation errors and apply some suggestions
Artemka374 1649d37
apply suggestions
Artemka374 8d94425
cargo fmt
Artemka374 0e48a2d
apply suggestions
Artemka374 7db2660
Merge remote-tracking branch 'paritytech/master'
Artemka374 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| (module | ||
| (import "seal0" "seal_input" (func $seal_input (param i32 i32))) | ||
| (import "__unstable__" "seal_account_entrance_count" (func $seal_account_entrance_count (param i32) (result i32))) | ||
agryaznov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| (import "env" "memory" (memory 1 1)) | ||
|
|
||
| ;; [0, 32) buffer where input is copied | ||
|
|
||
| ;; [32, 36) size of the input buffer | ||
| (data (i32.const 32) "\20") | ||
|
|
||
| (func $assert (param i32) | ||
| (block $ok | ||
| (br_if $ok | ||
| (get_local 0) | ||
| ) | ||
| (unreachable) | ||
| ) | ||
| ) | ||
| (func (export "call") | ||
| (local $account_entrance_count i32) | ||
|
|
||
| ;; Reading "callee" contract address (which is the address of the caller) | ||
| (call $seal_input (i32.const 0) (i32.const 32)) | ||
|
|
||
| (set_local $account_entrance_count | ||
| (call $seal_account_entrance_count (i32.const 0)) | ||
| ) | ||
|
|
||
| ;; assert account_entrance_count == 1 | ||
| (call $assert | ||
| (i32.eq (get_local $account_entrance_count) (i32.const 1)) | ||
| ) | ||
yarikbratashchuk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) | ||
|
|
||
| (func (export "deploy")) | ||
|
|
||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| (module | ||
yarikbratashchuk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| (import "seal0" "seal_input" (func $seal_input (param i32 i32))) | ||
| (import "seal0" "seal_call" (func $seal_call (param i32 i32 i64 i32 i32 i32 i32 i32 i32) (result i32))) | ||
yarikbratashchuk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
yarikbratashchuk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| (import "__unstable__" "seal_reentrant_count" (func $seal_reentrant_count (result i32))) | ||
agryaznov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| (import "env" "memory" (memory 1 1)) | ||
|
|
||
| ;; [0, 32) buffer where input is copied | ||
|
|
||
| ;; [32, 36) size of the input buffer | ||
| (data (i32.const 32) "\20") | ||
|
|
||
| (func $assert (param i32) | ||
| (block $ok | ||
| (br_if $ok | ||
| (get_local 0) | ||
| ) | ||
| (unreachable) | ||
| ) | ||
| ) | ||
| (func (export "call") | ||
| (local $exit_code i32) | ||
yarikbratashchuk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| (local $reentrant_count i32) | ||
|
|
||
| (set_local $reentrant_count | ||
| (call $seal_reentrant_count) | ||
| ) | ||
|
|
||
yarikbratashchuk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| (get_local $reentrant_count) | ||
| (if | ||
| (then | ||
| ;; assert reentrant_count == 1 | ||
| (call $assert | ||
| (i32.eq (get_local $reentrant_count) (i32.const 1)) | ||
| ) | ||
athei marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) | ||
yarikbratashchuk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| (else | ||
| ;; Reading "callee" contract address (which is the address of the caller) | ||
| (call $seal_input (i32.const 0) (i32.const 32)) | ||
|
|
||
| ;; Call to itself | ||
| (set_local $exit_code | ||
| (call $seal_call | ||
| (i32.const 0) ;; Pointer to "callee" address. | ||
| (i32.const 32) ;; Length of "callee" address. | ||
| (i64.const 0) ;; How much gas to devote for the execution. 0 = all. | ||
| (i32.const 0) ;; Pointer to the buffer with value to transfer | ||
| (i32.const 0) ;; Length of the buffer with value to transfer. | ||
| (i32.const 0) ;; Pointer to input data buffer address | ||
| (i32.const 32) ;; Length of input data buffer | ||
| (i32.const 0xffffffff) ;; u32 max sentinel value: do not copy output | ||
| (i32.const 0) ;; Ptr to output buffer len | ||
| ) | ||
| ) | ||
|
|
||
| ;; assert reentrant_count == 0 | ||
| (call $assert | ||
| (i32.eq (get_local $reentrant_count) (i32.const 0)) | ||
| ) | ||
| ) | ||
yarikbratashchuk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) | ||
| ) | ||
|
|
||
| (func (export "deploy")) | ||
|
|
||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.