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
contracts: add sr25519_verify #13724
Merged
paritytech-processbot
merged 45 commits into
master
from
pg/contracts-add-sr25519_recover
Apr 12, 2023
Merged
Changes from 37 commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
dab8913
wip
pgherveou d2da027
fix
pgherveou dd14d7f
wip
pgherveou d57ffcb
fix lint
pgherveou 1a0f97d
rm fixture fix
pgherveou feba43d
missing comment
pgherveou d560208
fix lint
pgherveou c7e5430
add comment to the wsm file
pgherveou 505919c
fix comment
pgherveou c5fba3a
Apply suggestions from code review
pgherveou a2ed618
wip
pgherveou 1c305a4
wip weights
pgherveou 5aa4bf1
wip weights
pgherveou 57120be
Merge branch 'master' into pg/contracts-add-sr25519_recover
pgherveou 2e7b44d
PR comment: test with return code
pgherveou f93e934
wip
pgherveou 5084dbb
PR review add mock test
pgherveou 90fd7ca
remove
pgherveou 24fcbd4
lint
pgherveou 66a9322
Update frame/contracts/fixtures/sr25519_verify.wat
pgherveou 03ad784
fix comments
pgherveou dcd849d
Update frame/contracts/src/benchmarking/mod.rs
pgherveou b896c4c
Update frame/contracts/src/wasm/runtime.rs
pgherveou 8a30502
Update frame/contracts/fixtures/sr25519_verify.wat
pgherveou d49c633
Update frame/contracts/src/benchmarking/mod.rs
pgherveou 851111a
fix lint
pgherveou f7dda14
Merge branch 'master' of https://github.com/paritytech/substrate into…
a7ab12b
".git/.scripts/commands/bench/bench.sh" pallet dev pallet_contracts
d11b430
Update frame/contracts/src/wasm/runtime.rs
pgherveou 9534b05
PR: review use unstable + remove arbitrary index 4
pgherveou c0a436a
Add benchmark for calculating overhead of calling sr25519_verify
pgherveou a39c784
fix message length encoding
pgherveou 4f2b8e9
fix weights
pgherveou 6fdb544
Merge branch 'master' of https://github.com/paritytech/substrate into…
3fbe20f
".git/.scripts/commands/bench/bench.sh" pallet dev pallet_contracts
44c0dca
Apply suggestions from code review
pgherveou 5907075
Update frame/contracts/src/wasm/runtime.rs
pgherveou 6c1bbdb
Update frame/contracts/src/wasm/runtime.rs
pgherveou 4c1cee8
Update frame/contracts/src/benchmarking/mod.rs
pgherveou e2d01de
Update frame/contracts/src/benchmarking/mod.rs
pgherveou 7d206cf
Update frame/contracts/src/schedule.rs
pgherveou 5f1eb72
Update frame/contracts/src/schedule.rs
pgherveou 9529c0a
Update frame/contracts/src/wasm/runtime.rs
pgherveou 3b9b849
Update frame/contracts/src/wasm/runtime.rs
pgherveou e5c9723
PR review
pgherveou 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,55 @@ | ||
| ;; This contract: | ||
| ;; 1) Reads signature, message and public key from the input | ||
| ;; 2) Calls and return the result of sr25519_verify | ||
|
|
||
| (module | ||
| ;; import the host functions from the seal0 module | ||
| (import "seal0" "sr25519_verify" (func $sr25519_verify (param i32 i32 i32 i32) (result i32))) | ||
| (import "seal0" "seal_input" (func $seal_input (param i32 i32))) | ||
| (import "seal0" "seal_return" (func $seal_return (param i32 i32 i32))) | ||
|
|
||
| ;; give the program 1 page of memory | ||
| (import "env" "memory" (memory 1 1)) | ||
|
|
||
| ;; [0, 4) length of signature + message + public key - 64 + 11 + 32 = 107 bytes | ||
| ;; write the length of the input (6b = 107) bytes at offset 0 | ||
| (data (i32.const 0) "\6b") | ||
|
|
||
| (func (export "deploy")) | ||
|
|
||
| (func (export "call") | ||
| ;; define local variables | ||
| (local $signature_ptr i32) | ||
| (local $pub_key_ptr i32) | ||
| (local $message_len i32) | ||
| (local $message_ptr i32) | ||
|
|
||
| ;; set the pointers to the memory locations | ||
| ;; Memory layout during `call` | ||
| ;; [10, 74) signature | ||
| ;; [74, 106) public key | ||
| ;; [106, 117) message (11 bytes) | ||
| (local.set $signature_ptr (i32.const 10)) | ||
| (local.set $pub_key_ptr (i32.const 74)) | ||
| (local.set $message_ptr (i32.const 106)) | ||
|
|
||
| ;; store the input into the memory, starting at the signature and | ||
| ;; up to 107 bytes stored at offset 0 | ||
| (call $seal_input (local.get $signature_ptr) (i32.const 0)) | ||
|
|
||
| ;; call sr25519_verify and store the return code | ||
| (i32.store | ||
| (i32.const 0) | ||
| (call $sr25519_verify | ||
| (local.get $signature_ptr) | ||
| (local.get $pub_key_ptr) | ||
| (i32.const 11) | ||
| (local.get $message_ptr) | ||
| ) | ||
| ) | ||
|
|
||
| ;; exit with success and take transfer return code to the output buffer | ||
| (call $seal_return (i32.const 0) (i32.const 0) (i32.const 4)) | ||
| ) | ||
| ) | ||
|
|
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.