Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: A4 - LOG4 Opcode #300

Closed
Eikix opened this issue Sep 7, 2023 · 2 comments
Closed

feat: A4 - LOG4 Opcode #300

Eikix opened this issue Sep 7, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request opcode Implementation of an opcode smart-contract-logic A specific type of opcode that requires smart contract logic as opposed to pure cairo

Comments

@Eikix
Copy link
Member

Eikix commented Sep 7, 2023

Append log record with four topics

Official Specification: https://github.com/ethereum/execution-specs/blob/master/src/ethereum/shanghai/vm/instructions/log.py#L33

Kakarot v0 implementation:
https://github.com/kkrt-labs/kakarot/blob/44dabfcab05a87f85bcfe0a457809059d11d83fb/src/kakarot/instructions/logging_operations.cairo#L83

And test cases from Geth:
https://github.com/ethereum/go-ethereum/tree/master/core/vm/testdata

Test cases from Kakarot v0:
https://github.com/kkrt-labs/kakarot/blob/44dabfcab05a87f85bcfe0a457809059d11d83fb/src/kakarot/instructions/logging_operations.cairo

Context on Logs in Cairo and Starknet:
https://docs.starknet.io/documentation/architecture_and_concepts/Smart_Contracts/starknet-events/
https://book.cairo-lang.org/ch99-01-03-03-contract-events.html?highlight=event#events

SinceGroup
FrontierLogging Operations

Index 1 is top of the stack. See PUSH.

Notes

This instruction has no effect on the EVM state. See here.

Stack input

  1. offset: byte offset in the memory in bytes.
  2. size: byte size to copy.
  3. topic1: 32-byte value.
  4. topic2: 32-byte value.
  5. topic3: 32-byte value.
  6. topic4: 32-byte value.

Error cases

The state changes done by the current context are reverted in those cases:

  • Not enough gas.
  • Not enough values on the stack.
  • The current execution context is from a STATICCALL (since Byzantium fork).

Dynamic gas

static_gas = 375
dynamic_gas = 375 * topic_count + 8 * size + memory_expansion_cost

For LOG4, topic_count is 4. The memory expansion cost explanation can be found here.

Estimate your gas cost

Input: offset
Input: size
State: current memory size
Static gas + dynamic gas = 1875
@Eikix Eikix added the enhancement New feature or request label Sep 7, 2023
@github-project-automation github-project-automation bot moved this to 🆕 Backlog in Kakarot on Starknet Sep 7, 2023
@Eikix Eikix added smart-contract-logic A specific type of opcode that requires smart contract logic as opposed to pure cairo opcode Implementation of an opcode labels Sep 7, 2023
@Eikix Eikix added this to the Kakarot Cairo Migration milestone Sep 7, 2023
@Eikix
Copy link
Member Author

Eikix commented Sep 8, 2023

Important update: we are gathering some bugs in the Kakarot v0 codebase, we need to make sure each issue and each PR in Kakarot-ssj is aware of the lists of known bugs. Look at this tracking issue everytime you take an issue and check your issue isn't targeted by a known bug.

@Quentash
Copy link
Contributor

Quentash commented Sep 8, 2023

Sorry I forgot to mention I could take this one.

@Eikix Eikix closed this as completed Oct 5, 2023
@github-project-automation github-project-automation bot moved this from 🆕 Backlog to ✅ Done in Kakarot on Starknet Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request opcode Implementation of an opcode smart-contract-logic A specific type of opcode that requires smart contract logic as opposed to pure cairo
Projects
No open projects
Archived in project
Development

No branches or pull requests

2 participants