mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-03 14:23:07 +00:00
Return 0 if account doesn't exist
This commit is contained in:
parent
6ed6574272
commit
ff4210ea78
@ -1,21 +1,23 @@
|
||||
%macro balance
|
||||
// stack: address
|
||||
global balance:
|
||||
// stack: address, retdest
|
||||
%mpt_read_state_trie
|
||||
// stack: account_ptr
|
||||
// stack: account_ptr, retdest
|
||||
DUP1 ISZERO %jumpi(retzero) // If the account pointer is null, return 0.
|
||||
%add_const(1)
|
||||
// stack: balance_ptr
|
||||
%mload_trie_data
|
||||
// stack: balance
|
||||
%endmacro
|
||||
|
||||
global balance:
|
||||
// stack: address, retdest
|
||||
%balance
|
||||
// stack: balance, retdest
|
||||
SWAP1 JUMP
|
||||
|
||||
%macro selfbalance
|
||||
// stack: (empty)
|
||||
ADDRESS
|
||||
%balance
|
||||
%endmacro
|
||||
retzero:
|
||||
%stack (account_ptr, retdest) -> (retdest, 0)
|
||||
JUMP
|
||||
|
||||
|
||||
global selfbalance:
|
||||
// stack: retdest
|
||||
%address
|
||||
PUSH balance
|
||||
// stack: balance, address, retdest
|
||||
JUMP
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user