-
Notifications
You must be signed in to change notification settings - Fork 448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: improvements and testing for RLP ink! contracts #2375
Open
peterwht
wants to merge
28
commits into
master
Choose a base branch
from
peter/rlp
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
1981ce4
feat(generator): add DECODE and RETURN const to trait message generat…
peterwht e73a039
test: compile tests for RLP and ALL encoding -- wip
peterwht 227aefe
feat(generator): wip RLP encoding for trait messages
peterwht 17b9c95
fix(generator): don't double generate message with encoding ALL when …
peterwht f77d68e
feat(primitives): AccountId derives RlpEncodable
peterwht dea8dce
test(integration): RLP cross-contract call ink! <> ink!; wip
peterwht 019ad69
build(deps): use consistent workspace import format
peterwht 4c3f21c
test(integration): update RLP test to use revive
peterwht 0144497
test(integration): refactor RLP test to use OriginFor. Cleanup commen…
peterwht f16844a
test(integration): rlp cross-contract test uses revive -- fails with …
peterwht 01e4f46
feat: invoke contract uses DecodeDispatch return -- wip
peterwht 9e16702
Revert "feat: invoke contract uses DecodeDispatch return -- wip"
peterwht ae5f44a
Merge branch 'master' into peter/rlp
peterwht bf08b28
fix(codegen): expected function signature of rlp_return_value
peterwht 2a042dc
test(e2e): setup hardhat-revive for solidity testing
peterwht 1a49c84
test(e2e): wip .sol calling ink! contract
peterwht b38b608
merge master
peterwht 31f7667
feat(e2e): add node `url` to `Client`
peterwht 5e971e4
test(e2e): solidity calls ink!, setup eth-rpc, setup, and run hardhat…
peterwht ba88473
chore(spellcheck): include alith
peterwht cabfcd9
test(e2e): verify value after flip from sol
peterwht 2fbd8df
test(e2e): refactor to e2e_tests.rs file
peterwht e69d711
test(e2e): refactor hardhat command + general cleanup
peterwht 379d03c
merge master
peterwht 5eea25b
chore: remove comment
peterwht 1daeb6d
style(deps): match base branch whitespace
peterwht 9c6258b
style(tests): add new line to UI test
peterwht c2364c4
chore: address review; add whitespace, fix version, initial TODOs
peterwht 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 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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
110 | ||
|
||
ABI | ||
alith | ||
AST | ||
BLAKE2 | ||
BLAKE2b | ||
|
This file contains 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 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 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 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 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 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
65 changes: 65 additions & 0 deletions
65
crates/ink/tests/ui/contract/pass/message-selector-encoding-all.rs
This file contains 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 @@ | ||
use contract::Contract; | ||
peterwht marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#[ink::contract(abi_encoding = "all")] | ||
mod contract { | ||
#[ink(storage)] | ||
pub struct Contract {} | ||
|
||
#[ink::trait_definition] | ||
pub trait Messages { | ||
#[ink(message, selector = 1)] | ||
fn message_1(&self); | ||
} | ||
|
||
impl Contract { | ||
#[ink(constructor)] | ||
pub fn constructor() -> Self { | ||
Self {} | ||
} | ||
|
||
#[ink(message, selector = 0xC0DE_CAFE)] | ||
pub fn message_2(&self) {} | ||
|
||
#[ink(message)] | ||
pub fn message_3(&self) {} | ||
} | ||
|
||
impl Messages for Contract { | ||
#[ink(message, selector = 1)] | ||
fn message_1(&self) {} | ||
} | ||
|
||
#[ink::trait_definition] | ||
pub trait Messages2 { | ||
#[ink(message, selector = 0x12345678)] | ||
fn message_4(&self); | ||
} | ||
|
||
impl Messages2 for Contract { | ||
#[ink(message, selector = 0x12345678)] | ||
fn message_4(&self) {} | ||
} | ||
} | ||
|
||
fn main() { | ||
assert_eq!( | ||
<Contract as ::ink::reflect::DispatchableMessageInfo<1_u32>>::SELECTOR, | ||
1_u32.to_be_bytes(), | ||
); | ||
assert_eq!( | ||
<Contract as ::ink::reflect::DispatchableMessageInfo<0xC0DE_CAFE_u32>>::SELECTOR, | ||
0xC0DE_CAFE_u32.to_be_bytes(), | ||
); | ||
|
||
// manually calculated "message_3" | ||
const INHERENT_ID_RLP: u32 = 0x0cd0f0f1; | ||
assert_eq!( | ||
<Contract as ::ink::reflect::DispatchableMessageInfo<INHERENT_ID_RLP>>::SELECTOR, | ||
[0x0C, 0xD0, 0xF0, 0xF1], | ||
); | ||
|
||
assert_eq!( | ||
<Contract as ::ink::reflect::DispatchableMessageInfo<0x12345678_u32>>::SELECTOR, | ||
0x12345678_u32.to_be_bytes(), | ||
); | ||
} |
65 changes: 65 additions & 0 deletions
65
crates/ink/tests/ui/contract/pass/message-selector-encoding-rlp.rs
This file contains 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 @@ | ||
use contract::Contract; | ||
|
||
#[ink::contract(abi_encoding = "rlp")] | ||
mod contract { | ||
#[ink(storage)] | ||
pub struct Contract {} | ||
|
||
#[ink::trait_definition] | ||
pub trait Messages { | ||
#[ink(message, selector = 1)] | ||
fn message_1(&self); | ||
} | ||
|
||
impl Contract { | ||
#[ink(constructor)] | ||
pub fn constructor() -> Self { | ||
Self {} | ||
} | ||
|
||
#[ink(message, selector = 0xC0DE_CAFE)] | ||
pub fn message_2(&self) {} | ||
|
||
#[ink(message)] | ||
pub fn message_3(&self) {} | ||
} | ||
|
||
impl Messages for Contract { | ||
#[ink(message, selector = 1)] | ||
fn message_1(&self) {} | ||
} | ||
|
||
#[ink::trait_definition] | ||
pub trait Messages2 { | ||
#[ink(message, selector = 0x12345678)] | ||
fn message_4(&self); | ||
} | ||
|
||
impl Messages2 for Contract { | ||
#[ink(message, selector = 0x12345678)] | ||
fn message_4(&self) {} | ||
} | ||
} | ||
|
||
fn main() { | ||
assert_eq!( | ||
<Contract as ::ink::reflect::DispatchableMessageInfo<1_u32>>::SELECTOR, | ||
1_u32.to_be_bytes(), | ||
); | ||
assert_eq!( | ||
<Contract as ::ink::reflect::DispatchableMessageInfo<0xC0DE_CAFE_u32>>::SELECTOR, | ||
0xC0DE_CAFE_u32.to_be_bytes(), | ||
); | ||
|
||
// manually calculated "message_3" | ||
const INHERENT_ID_RLP: u32 = 0x0cd0f0f1; | ||
assert_eq!( | ||
<Contract as ::ink::reflect::DispatchableMessageInfo<INHERENT_ID_RLP>>::SELECTOR, | ||
[0x0C, 0xD0, 0xF0, 0xF1], | ||
); | ||
|
||
assert_eq!( | ||
<Contract as ::ink::reflect::DispatchableMessageInfo<0x12345678_u32>>::SELECTOR, | ||
0x12345678_u32.to_be_bytes(), | ||
); | ||
} |
This file contains 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 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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a temporary fix for compilation. Added TODO in #2401