forked from ethereum/solidity
-
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.
Co-authored-by: Kamil Śliwak <[email protected]>
- Loading branch information
Showing
28 changed files
with
200 additions
and
6 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
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
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
11 changes: 11 additions & 0 deletions
11
test/libsolidity/semanticTests/inlineAssembly/blobhash.sol
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,11 @@ | ||
contract C { | ||
function f() public view returns (bytes32 ret) { | ||
assembly { | ||
ret := blobhash(0) | ||
} | ||
} | ||
} | ||
// ==== | ||
// EVMVersion: >=cancun | ||
// ---- | ||
// f() -> 0x0100000000000000000000000000000000000000000000000000000000000001 |
14 changes: 14 additions & 0 deletions
14
test/libsolidity/semanticTests/inlineAssembly/blobhash_index_exceeding_blob_count.sol
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,14 @@ | ||
contract C { | ||
function f() public view returns (bytes32 ret) { | ||
assembly { | ||
// EIP-4844 specifies that if `index < len(tx.blob_versioned_hashes)`, `blobhash(index)` should return 0. | ||
// Thus, as we injected only two blob hashes in the transaction context in EVMHost, | ||
// the return value of the function below MUST be zero. | ||
ret := blobhash(2) | ||
} | ||
} | ||
} | ||
// ==== | ||
// EVMVersion: >=cancun | ||
// ---- | ||
// f() -> 0x00 |
21 changes: 21 additions & 0 deletions
21
test/libsolidity/semanticTests/inlineAssembly/blobhash_pre_cancun.sol
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,21 @@ | ||
contract C { | ||
function f() public pure returns (uint ret) { | ||
assembly { | ||
let blobhash := 1 | ||
ret := blobhash | ||
} | ||
} | ||
function g() public pure returns (uint ret) { | ||
assembly { | ||
function blobhash() -> r { | ||
r := 1000 | ||
} | ||
ret := blobhash() | ||
} | ||
} | ||
} | ||
// ==== | ||
// EVMVersion: <=shanghai | ||
// ---- | ||
// f() -> 1 | ||
// g() -> 1000 |
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,10 @@ | ||
contract C { | ||
function f() public view returns (bytes32 ret) { | ||
assembly { | ||
ret := blobhash(1) | ||
} | ||
} | ||
} | ||
// ==== | ||
// EVMVersion: >=cancun | ||
// ---- |
12 changes: 12 additions & 0 deletions
12
test/libsolidity/syntaxTests/inlineAssembly/blobhash_pre_cancun.sol
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,12 @@ | ||
contract C { | ||
function f() pure external returns (bytes32 ret) { | ||
assembly { | ||
ret := blobhash() | ||
} | ||
} | ||
} | ||
// ==== | ||
// EVMVersion: <=shanghai | ||
// ---- | ||
// DeclarationError 4619: (106-114): Function "blobhash" not found. | ||
// DeclarationError 8678: (99-116): Variable count for assignment to "ret" does not match number of values (1 vs. 0) |
14 changes: 14 additions & 0 deletions
14
test/libsolidity/syntaxTests/inlineAssembly/blobhash_reserved_cancun.sol
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,14 @@ | ||
contract C { | ||
function f() public pure returns (uint ret) { | ||
assembly { | ||
function blobhash() -> r { | ||
r := 1000 | ||
} | ||
ret := blobhash() | ||
} | ||
} | ||
} | ||
// ==== | ||
// EVMVersion: >=cancun | ||
// ---- | ||
// ParserError 5568: (103-111): Cannot use builtin function name "blobhash" as identifier name. |
9 changes: 9 additions & 0 deletions
9
test/libsolidity/syntaxTests/viewPureChecker/blobhash_not_pure.sol
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,9 @@ | ||
contract C { | ||
function f() public pure { | ||
assembly { pop(blobhash(0)) } | ||
} | ||
} | ||
// ==== | ||
// EVMVersion: >=cancun | ||
// ---- | ||
// TypeError 2527: (67-78): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view". |
1 change: 1 addition & 0 deletions
1
...solidity/syntaxTests/viewPureChecker/inline_assembly_instructions_allowed_view_cancun.sol
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 @@ | ||
contract C { | ||
function f() public view { | ||
assembly { | ||
pop(blobhash(0)) | ||
pop(blobbasefee()) | ||
} | ||
} | ||
|
4 changes: 3 additions & 1 deletion
4
...idity/syntaxTests/viewPureChecker/inline_assembly_instructions_disallowed_pure_cancun.sol
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,11 +1,13 @@ | ||
contract C { | ||
function f() public pure { | ||
assembly { | ||
pop(blobhash(0)) | ||
pop(blobbasefee()) | ||
} | ||
} | ||
} | ||
// ==== | ||
// EVMVersion: >=cancun | ||
// ---- | ||
// TypeError 2527: (79-92): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view". | ||
// TypeError 2527: (79-90): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view". | ||
// TypeError 2527: (108-121): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view". |
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,13 @@ | ||
{ | ||
sstore(0, blobhash(0)) | ||
sstore(1, blobhash(1)) | ||
sstore(2, blobhash(2)) // should store 0 since EVMHost has only two blob hashes injected in the block the transaction is being executed. | ||
} | ||
// ==== | ||
// EVMVersion: >=cancun | ||
// ---- | ||
// Trace: | ||
// Memory dump: | ||
// Storage dump: | ||
// 0000000000000000000000000000000000000000000000000000000000000000: 014916dd28fc4c10d78e287ca5d9cc51ee1ae73cbfde08c6b37324cbfaac8bc5 | ||
// 0000000000000000000000000000000000000000000000000000000000000001: 0167d3dbed802941483f1afa2a6bc68de5f653128aca9bf1461c5d0a3ad36ed2 |
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,15 @@ | ||
{ | ||
{ | ||
let blobhash := 1 | ||
} | ||
|
||
{ | ||
function blobhash() {} | ||
blobhash() | ||
} | ||
} | ||
|
||
// ==== | ||
// EVMVersion: >=cancun | ||
// ---- | ||
// ParserError 5568: (20-28): Cannot use builtin function name "blobhash" as identifier name. |
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,13 @@ | ||
{ | ||
{ | ||
let blobhash := 1 | ||
} | ||
|
||
{ | ||
function blobhash() {} | ||
blobhash() | ||
} | ||
} | ||
// ==== | ||
// EVMVersion: <=shanghai | ||
// ---- |
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