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: arithmetic opcodes #339

Merged
merged 4 commits into from
Jan 3, 2025
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
1 change: 1 addition & 0 deletions cairo/ethereum/cancun/vm.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ namespace EvmImpl {
code=evm.value.code,
gas_left=evm.value.gas_left,
env=evm.value.env,
valid_jump_destinations=evm.value.valid_jump_destinations,
logs=evm.value.logs,
refund_counter=evm.value.refund_counter,
running=evm.value.running,
Expand Down
51 changes: 51 additions & 0 deletions cairo/ethereum/cancun/vm/gas.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,54 @@ func calculate_data_fee{range_check_ptr}(excess_blob_gas: U64, tx: Transaction)
let data_fee = Uint(total_blob_gas.value * blob_gas_price.value);
return data_fee;
}

namespace GasConstants {
const GAS_JUMPDEST = 1;
const GAS_BASE = 2;
const GAS_VERY_LOW = 3;
const GAS_STORAGE_SET = 20000;
const GAS_STORAGE_UPDATE = 5000;
const GAS_STORAGE_CLEAR_REFUND = 4800;
const GAS_LOW = 5;
const GAS_MID = 8;
const GAS_HIGH = 10;
const GAS_EXPONENTIATION = 10;
const GAS_EXPONENTIATION_PER_BYTE = 50;
const GAS_MEMORY = 3;
const GAS_KECCAK256 = 30;
const GAS_KECCAK256_WORD = 6;
const GAS_COPY = 3;
const GAS_BLOCK_HASH = 20;
const GAS_LOG = 375;
const GAS_LOG_DATA = 8;
const GAS_LOG_TOPIC = 375;
const GAS_CREATE = 32000;
const GAS_CODE_DEPOSIT = 200;
const GAS_ZERO = 0;
const GAS_NEW_ACCOUNT = 25000;
const GAS_CALL_VALUE = 9000;
const GAS_CALL_STIPEND = 2300;
const GAS_SELF_DESTRUCT = 5000;
const GAS_SELF_DESTRUCT_NEW_ACCOUNT = 25000;
const GAS_ECRECOVER = 3000;
const GAS_SHA256 = 60;
const GAS_SHA256_WORD = 12;
const GAS_RIPEMD160 = 600;
const GAS_RIPEMD160_WORD = 120;
const GAS_IDENTITY = 15;
const GAS_IDENTITY_WORD = 3;
const GAS_RETURN_DATA_COPY = 3;
const GAS_FAST_STEP = 5;
const GAS_BLAKE2_PER_ROUND = 1;
const GAS_COLD_SLOAD = 2100;
const GAS_COLD_ACCOUNT_ACCESS = 2600;
const GAS_WARM_ACCESS = 100;
const GAS_INIT_CODE_WORD_COST = 2;
const GAS_BLOBHASH_OPCODE = 3;
const GAS_POINT_EVALUATION = 50000;

const TARGET_BLOB_GAS_PER_BLOCK = 393216;
const GAS_PER_BLOB = 2 ** 17;
const MIN_BLOB_GASPRICE = 1;
const BLOB_GASPRICE_UPDATE_FRACTION = 3338477;
}
Loading
Loading