Skip to content

Spec for opcode BALANCE#48

Closed
silathdiir wants to merge 5 commits into
masterfrom
feat/opcode-balance
Closed

Spec for opcode BALANCE#48
silathdiir wants to merge 5 commits into
masterfrom
feat/opcode-balance

Conversation

@silathdiir
Copy link
Copy Markdown

@silathdiir silathdiir commented Aug 8, 2022

@silathdiir silathdiir changed the title [WIP] Spec for opcode BALANCE Spec for opcode BALANCE Aug 12, 2022
silathdiir and others added 2 commits August 12, 2022 22:49
* Implement opcode `ADDRESS`.

* Add Markdown doc for opcode `ADDRESS`.

* Fixed to `gas - 2`.
…thereum#246)

* fix: constraint system fix | related fixes in copy circuit

* chore: revert unnecessary change

* fix: update sha3 gadget, copy lookup only for length > 0
Comment thread specs/opcode/31BALANCE.md
@silathdiir silathdiir requested a review from DreamWuGit August 16, 2022 01:08
tx_id = instruction.call_context_lookup(CallContextFieldTag.TxId)
is_warm = instruction.add_account_to_access_list(tx_id, address, instruction.reversion_info())

balance = instruction.account_read(address, AccountFieldTag.Balance)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if need to constrain "If the given account
doesn't exist, then it will push 0 onto the stack instead." in the circuit , what do you think ? @
silathdiir

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that the balance is constrained to be equal with stack_push in next line:

instruction.constrain_equal(instruction.stack_push(), balance)

If the given account doesn't exist, stack_push should be 0 and also constrain balance to be 0. WDYT? Thanks.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After discussing with @DreamWuGit , will send PR to upstream with this question in comment.

@silathdiir
Copy link
Copy Markdown
Author

Moved to upstream privacy-ethereum#248

@silathdiir silathdiir closed this Aug 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants