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: add more supported opcodes #579

Merged
merged 4 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cli:
plugins:
sources:
- id: trunk
ref: v1.2.6
ref: v1.3.0
uri: https://github.com/trunk-io/plugins
runtimes:
enabled:
Expand All @@ -32,7 +32,7 @@ lint:
- [email protected]
- [email protected]
- [email protected]
- checkov@3.0.40
- checkov@3.1.9
- git-diff-check
- [email protected]
- [email protected]
Expand All @@ -43,7 +43,7 @@ lint:
- [email protected]
- [email protected]
- [email protected]
- [email protected].0
- [email protected].2-rc0
- [email protected]
actions:
disabled:
Expand Down
4 changes: 2 additions & 2 deletions crates/evm/src/errors.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ enum EVMError {
ReturnDataError: felt252,
JumpError: felt252,
NotImplemented,
UnknownOpcode: u8,
InvalidOpcode: u8,
SyscallFailed: felt252,
WriteInStaticContext: felt252,
InvalidMachineState: felt252,
Expand All @@ -74,7 +74,7 @@ impl EVMErrorImpl of EVMErrorTrait {
EVMError::JumpError(error_message) => error_message,
EVMError::NotImplemented => 'NotImplemented',
// TODO: refactor with dynamic strings once supported
EVMError::UnknownOpcode => 'UnknownOpcode'.into(),
EVMError::InvalidOpcode => 'InvalidOpcode'.into(),
EVMError::SyscallFailed(error_message) => error_message.into(),
EVMError::WriteInStaticContext(error_message) => error_message.into(),
EVMError::InvalidMachineState(error_message) => error_message.into(),
Expand Down
2 changes: 1 addition & 1 deletion crates/evm/src/instructions/system_operations.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl SystemOperations of SystemOperationsTrait {
/// INVALID
/// # Specification: https://www.evm.codes/#fe?fork=shanghai
fn exec_invalid(ref self: Machine) -> Result<(), EVMError> {
Result::Err(EVMError::NotImplemented)
Result::Err(EVMError::InvalidOpcode(0xfe))
}

/// RETURN
Expand Down
2 changes: 1 addition & 1 deletion crates/evm/src/interpreter.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ impl EVMInterpreterImpl of EVMInterpreterTrait {
return machine.exec_selfdestruct();
}
// Unknown opcode
return Result::Err(EVMError::UnknownOpcode(opcode));
return Result::Err(EVMError::InvalidOpcode(opcode));
}

/// Finalizes the revert of an execution context.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ fn test_exec_staticcall() {


#[test]
#[available_gas(70000000)]
#[available_gas(500000000)]
fn test_exec_staticcall_no_return() {
// Given
let mut interpreter = EVMInterpreterTrait::new();
Expand Down
18 changes: 9 additions & 9 deletions docs/supported_opcodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ This document describes the opcodes supported by Kakarot.
| Opcode Value | Opcode Name | Description | Implemented |
| ------------ | ----------- | ---------------------------------------------------------- | ----------- |
| 0x40 | BLOCKHASH | Get the hash of one of the 256 most recent complete blocks | ✅ |
| 0x41 | COINBASE | Get the block's beneficiary address | |
| 0x41 | COINBASE | Get the block's beneficiary address | |
| 0x42 | TIMESTAMP | Get the block's timestamp | ✅ |
| 0x43 | NUMBER | Get the block's number | ✅ |
| 0x44 | PREVRANDAO | Get the block's difficulty | ✅ |
Expand Down Expand Up @@ -214,15 +214,15 @@ This document describes the opcodes supported by Kakarot.

| Opcode Value | Opcode Name | Description | Implemented |
| ------------ | ------------ | ----------------------------------------------------------------- | ----------- |
| 0xf0 | CREATE | Create a new account with associated code | |
| 0xf1 | CALL | Message-call into an account | |
| 0xf2 | CALLCODE | Message-call into this account with alternative account's code | |
| 0xf0 | CREATE | Create a new account with associated code | |
| 0xf1 | CALL | Message-call into an account | |
| 0xf2 | CALLCODE | Message-call into this account with alternative account's code | |
| 0xf3 | RETURN | Halt execution returning output data | ✅ |
| 0xf4 | DELEGATECALL | Message-call into this account with an alternative account’s code | |
| 0xf5 | CREATE2 | Create a new account with associated code | |
| 0xfa | STATICCALL | Static message-call into an account | |
| 0xfd | REVERT | Halt execution reverting state changes | |
| 0xfe | INVALID | Designated invalid instruction | |
| 0xf4 | DELEGATECALL | Message-call into this account with an alternative account’s code | |
| 0xf5 | CREATE2 | Create a new account with associated code | |
| 0xfa | STATICCALL | Static message-call into an account | |
| 0xfd | REVERT | Halt execution reverting state changes | |
| 0xfe | INVALID | Designated invalid instruction | |
| 0xff | SELFDESTRUCT | Halt execution and register account for later deletion | ✅ |

<!-- markdownlint-restore -->