forked from hyperledger-solang/solang
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump should be hashed by last (hyperledger-solang#1440)
Presently, we hash include the bump in the `seeds` array passed to a Solana runtime call in the same order specified by developers when they are writing the contract's constructor. This is not the intended behavior, though. The bump must always be the last element in the array. This PR ensures that. Signed-off-by: Lucas Steuernagel <lucas.tnagel@gmail.com>
- Loading branch information
Showing
2 changed files
with
46 additions
and
2 deletions.
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
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,40 @@ | ||
// RUN: --target solana --emit cfg | ||
|
||
contract C1 { | ||
@payer(payer) | ||
@space(57) | ||
@bump(25) | ||
constructor(@seed bytes my_seed) { | ||
print("In C1"); | ||
} | ||
// BEGIN-CHECK: solang_dispatch | ||
// 25 must be the last seed in the call. | ||
// CHECK: external call::regular address:address 0x0 payload:%instruction.temp.14 value:uint64 0 gas:uint64 0 accounts:%metas.temp.11 seeds:[1] [ [2] [ bytes(%my_seed), bytes(bytes from:bytes1 (bytes1 25)) ] ] contract|function:_ flags: | ||
} | ||
|
||
contract C2 { | ||
@payer(payer) | ||
@space(57) | ||
@seed("apple") | ||
@bump(12) | ||
@seed("pine_tree") | ||
constructor(@seed bytes my_seed) { | ||
print("In C2"); | ||
} | ||
// BEGIN-CHECK: solang_dispatch | ||
// 12 must be the last seed in the call. | ||
// CHECK: external call::regular address:address 0x0 payload:%instruction.temp.25 value:uint64 0 gas:uint64 0 accounts:%metas.temp.22 seeds:[1] [ [4] [ (alloc slice bytes1 uint32 5 "apple"), (alloc slice bytes1 uint32 9 "pine_tree"), bytes(%my_seed), bytes(bytes from:bytes1 (bytes1 12)) ] ] contract|function:_ flags: | ||
} | ||
|
||
contract C3 { | ||
@payer(payer) | ||
@space(57) | ||
@seed("pineapple") | ||
@seed("avocado") | ||
constructor(@bump uint8 bp, @seed bytes my_seed) { | ||
print("In C3"); | ||
} | ||
// BEGIN-CHECK: solang_dispatch | ||
// bp must be the last seed in the call | ||
// CHECK: external call::regular address:address 0x0 payload:%instruction.temp.37 value:uint64 0 gas:uint64 0 accounts:%metas.temp.34 seeds:[1] [ [4] [ (alloc slice bytes1 uint32 9 "pineapple"), (alloc slice bytes1 uint32 7 "avocado"), bytes(%my_seed), bytes(bytes from:bytes1 (%bp)) ] ] contract|function:_ flags: | ||
} |