Precompiles exist (#1008)

* Precompiles exist

* Fix
This commit is contained in:
wborgeaud 2023-04-26 06:26:41 +02:00 committed by GitHub
parent 11a03c5ebc
commit 67a3edb2f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 6 deletions

View File

@ -35,9 +35,7 @@ global pop_and_return_success:
// stack: retdest
%mload_txn_field(@TXN_FIELD_TO)
// stack: addr, retdest
DUP1 %ge_const(@ECREC) DUP2 %le_const(@BLAKE2_F)
// stack: addr<=9, addr>=1, addr, retdest
MUL // Cheaper than AND
DUP1 %is_precompile
%jumpi(handle_precompiles_from_eoa)
// stack: addr, retdest
POP

View File

@ -28,11 +28,24 @@
// stack: to == 0
%endmacro
%macro is_precompile
// stack: addr
DUP1 %ge_const(@ECREC) SWAP1 %le_const(@BLAKE2_F)
// stack: addr>=1, addr<=9
MUL // Cheaper than AND
%endmacro
// Returns 1 if the account is non-existent, 0 otherwise.
%macro is_non_existent
// stack: addr
%mpt_read_state_trie
ISZERO
DUP1
// stack: addr, addr
%mpt_read_state_trie ISZERO
SWAP1
// stack: addr, zero_state_trie
%is_precompile ISZERO
// stack: not_precompile, zero_state_trie
MUL // Cheaper than AND
%endmacro
// Returns 1 if the account is empty, 0 otherwise.
@ -65,5 +78,5 @@
// stack: addr
DUP1 %is_non_existent
SWAP1 %is_empty
ADD // OR
OR
%endmacro