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

[KIP-XX] Calldata gas reduction #23

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
52 changes: 52 additions & 0 deletions KIPs/kip-xx.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
kip: to be assigned
title: Transaction data gas cost reduction
author: Lake (@hyunsooda) and Ollie (@blukat29)
discussions-to: https://github.com/kaiachain/kips/issues/22
status: Draft
type: Standards Track
category: Core
created: 2024-10-18
---

## Simple Summary

Changing to calldata gas cost.

blukat29 marked this conversation as resolved.
Show resolved Hide resolved
## Abstract

This KIP introduces a new tag for calldata gas payment, defining a calculation method that distinguishes between zero and non-zero bytes, with distinct costs assigned to each byte.
hyunsooda marked this conversation as resolved.
Show resolved Hide resolved

## Motivation

TBD

## Specification

The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.
hyunsooda marked this conversation as resolved.
Show resolved Hide resolved

The gas cost distinguishes between non-zero and zero bytes, assigning 16 and 4 gas units to each, respectively.
blukat29 marked this conversation as resolved.
Show resolved Hide resolved

### Overview

Since the genesis block, calldata gas calculation has followed two branches:

- Non-zero bytes: 68 gas units per byte
- Zero bytes: 4 gas units per byte

With the Istanbul hardfork, the gas calculation was modified to no longer distinguish between zero and non-zero bytes, introducing a flat rate of 100 gas units per byte.

The Prague hardfork reverted to the original logic from the genesis block, reintroducing the distinction between non-zero and zero bytes. However, the assigned costs were adjusted to 16 gas units per non-zero byte and 4 gas units per zero byte.

In summary, these changes result in a reduction of 84 gas units per non-zero byte and 96 gas units per zero byte.
blukat29 marked this conversation as resolved.
Show resolved Hide resolved

## Backward Compatibility

Since the Kaia client implementation applies different logic based on the hardfork state, the correct gas cost is determined according to the block number associated with each hardfork.
hyunsooda marked this conversation as resolved.
Show resolved Hide resolved

## References
[EIP-2028](https://eips.ethereum.org/EIPS/eip-2028)

## Copyright

Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).
Loading