Implement syscalls for BALANCE and SELFBALANCE (#922)

* Implement syscalls for BALANCE and SELFBALANCE

* Remove stubs
This commit is contained in:
wborgeaud 2023-03-21 05:54:29 +01:00 committed by GitHub
parent fc6487cac0
commit 893b88c309
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 10 deletions

View File

@ -1,3 +1,20 @@
global sys_balance:
// stack: kexit_info, address
// TODO: assuming a cold account access for now.
%charge_gas_const(@GAS_COLDACCOUNTACCESS)
SWAP1
// stack: address, kexit_info
%balance
// stack: balance, kexit_info
SWAP1
EXIT_KERNEL
%macro balance
%stack (address) -> (address, %%after)
%jump(balance)
%%after:
%endmacro
global balance:
// stack: address, retdest
%mpt_read_state_trie
@ -13,11 +30,17 @@ retzero:
%stack (account_ptr, retdest) -> (retdest, 0)
JUMP
global sys_selfbalance:
// stack: kexit_info
%charge_gas_const(@GAS_LOW)
%selfbalance
// stack: balance, kexit_info
SWAP1
EXIT_KERNEL
global selfbalance:
// stack: retdest
%macro selfbalance
PUSH %%after
%address
PUSH balance
// stack: balance, address, retdest
JUMP
%jump(balance)
%%after:
%endmacro

View File

@ -13,8 +13,6 @@ global sys_sgt:
PANIC
global sys_sar:
PANIC
global sys_balance:
PANIC
global sys_origin:
PANIC
global sys_calldatasize:
@ -50,8 +48,6 @@ global sys_chainid:
// stack: chain_id, kexit_info
SWAP1
EXIT_KERNEL
global sys_selfbalance:
PANIC
global sys_basefee:
PANIC
global sys_log0: