Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Ankr network #1

Open
wants to merge 166 commits into
base: BEP8_modify
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
166 commits
Select commit Hold shift + click to select a range
648b328
Merge pull request #73 from binance-chain/BEP8_modify
EnderCrypto Jul 10, 2020
34e1d19
bep20 token
Aug 25, 2020
ca7f7c0
Merge pull request #75 from binance-chain/bep20
darren-liu Aug 27, 2020
a00bc3a
upgrade BEP status (#78)
EnderCrypto Aug 28, 2020
5eafc6c
Frontier Wallet has rebranded to Frontier (#76)
philiparthurmoore Aug 28, 2020
d9ad1bc
add bep20 to readme (#77)
Aug 28, 2020
a1eb176
BEP for token owner changes
fletcher142 Dec 11, 2020
17809ae
description adjustment
fletcher142 Dec 30, 2020
3036913
BEP-87: Token Symbol Minimum Length Change (#87)
fletcher142 Jan 19, 2021
843ae04
R4R: BEP86 Dynamic Extra Incentive To BSC Relayers (#86)
Jan 19, 2021
e01bb47
add bep87: Visual Fork of Binance Smart Chain
unclezoro Dec 13, 2020
ced92c6
mirror and sync
Dec 14, 2020
ac0d28d
resolve comment
Dec 28, 2020
c903b11
add link in README
Jan 11, 2021
a51d775
Merge pull request #84 from binance-chain/mirror-sync
unclezoro Jan 19, 2021
07186be
Merge pull request #83 from guagualvcha/bep87
unclezoro Jan 19, 2021
e7ac31d
Merge pull request #82 from binance-chain/tokenowner_improve
darren-liu Jan 19, 2021
874afab
edit index (#96)
chainwhisper Jan 29, 2021
3af4be1
Update BEP20.md (#100)
wangkui0508 Apr 9, 2021
573aabe
propose BEP to improve gasceil (#101)
May 20, 2021
2a349d8
Update BEP91.md (#109)
chainwhisper May 25, 2021
f85df8f
add bep93
unclezoro Sep 10, 2021
e1d408a
Merge pull request #114 from binance-chain/bep93
unclezoro Oct 20, 2021
18548f3
add bep 95
victor-cage Oct 22, 2021
3d4fae6
Merge pull request #116 from victor-cage/add_bep95
yutianwu Oct 22, 2021
4bf59ae
update bep index
victor-cage Oct 22, 2021
c0d3265
Merge pull request #117 from victor-cage/update_index
yutianwu Oct 22, 2021
cade766
BEP-99: init
SolidityGo Dec 29, 2021
5b9649b
BEP-99: update
SolidityGo Dec 29, 2021
f510b30
create bep for staking reward distribution
Jan 7, 2022
873b215
change title
Jan 7, 2022
b00febe
change bep number
Jan 7, 2022
af88ed0
rename BEP99 to BEP127
unclezoro Jan 10, 2022
9f69c28
update readme for bep127
unclezoro Jan 10, 2022
33e3f15
improve wording
Jan 11, 2022
a812763
update assets
Jan 28, 2022
80aa5af
update chain names
Feb 17, 2022
42ca896
feat: modify bsc to BNB Smart Chain
SolidityGo Feb 17, 2022
9474eb0
improve wording
Mar 7, 2022
9191cbd
Merge pull request #128 from forcodedancing/staking-reward-distribution
unclezoro Mar 10, 2022
aa1fd15
add BEP128 into index
Mar 10, 2022
0e0b96e
Merge pull request #133 from forcodedancing/update_index
unclezoro Mar 10, 2022
9f17c22
re-brand to BNB Chain
darren-liu May 4, 2022
c67c07d
Merge branch 'master' into bep-99
SolidityGo May 5, 2022
d67666d
Merge pull request #127 from SolidityGo/bep-99
unclezoro May 5, 2022
e48963a
add bep-131
j75689 Feb 15, 2022
461ed64
refine the BEP131
unclezoro Feb 15, 2022
a74df96
resolve comments
unclezoro Feb 15, 2022
80fcca5
update BEP131.md
j75689 Feb 18, 2022
bf9e67c
update
j75689 Feb 21, 2022
4d9517b
Update BEP131.md
j75689 Apr 13, 2022
db4fa58
update docs
j75689 May 5, 2022
4ca2e5f
Merge pull request #131 from j75689/bep-131
unclezoro May 5, 2022
757ddc5
Update BEP131.md
j75689 May 20, 2022
6440376
Merge pull request #146 from j75689/bep-131
unclezoro May 20, 2022
dd55e6e
BEP-151: Decommission Decentralized Exchange on BNB Beacon Chain (#151)
owen-reorg Jul 11, 2022
ca61762
[R4R]BEP-153: Introduce Native Staking on BSC (#153)
pythonberg1997 Aug 17, 2022
c37ab71
Update SampleStakingContract.sol (#157)
pythonberg1997 Aug 24, 2022
10c322d
bep-131: update diagram (#160)
j75689 Sep 6, 2022
58edbb5
bep173: enable text proposal on BNB Smart Chain (#173)
randyahx Nov 18, 2022
edd5de1
update status of several implemented BEPs
brilliant-lx Dec 5, 2022
6c53e33
BEP-159: Introduce A New Staking Mechanism on BNB Beacon Chain (#159)
owen-reorg Dec 23, 2022
c722823
BEP-1: update the BEP workflow. (#185)
brilliant-lx Jan 9, 2023
324bfd1
reform: update BEP format, README.md and rebrand (#187)
brilliant-lx Jan 12, 2023
e744c89
BEP-130: Parallel Transaction Execution (#130)
setunapo Feb 14, 2023
87d30de
readme: add BNB Chain Upgrades section (#199)
brilliant-lx Feb 21, 2023
e5b4a1d
[R4R] BEP-172: Network Stability Enhancement On Slash Occur (#172)
qinglin89 Feb 22, 2023
416d58e
[WIP] BEP-126: Introduce Fast Finality Mechanism (#126)
keefel Feb 22, 2023
32dd90e
format BEP126 (#205)
NathanBSC Feb 22, 2023
9fc0338
BEP-188: Early Broadcast block for an in-turn validator (#188)
kyrie-yl Feb 27, 2023
e09b912
feat: add BEP-171 and modify readme (#171)
cosinlink Mar 1, 2023
71ad9c7
BEP-174: Cross Chain Relayer Management (#174)
bnb-tw Mar 1, 2023
3cbe525
update readme & BEPs format (#207)
brilliant-lx Mar 2, 2023
accdceb
more update on the BSC upgrade forecast (#210)
brilliant-lx Mar 7, 2023
f689e5a
BEP-126: remove naturally justified setting (#211)
NathanBSC Mar 9, 2023
34abb41
readme: link upgrades section to bnb chain forum. (#214)
brilliant-lx Mar 21, 2023
0614c4c
BEP-126: revert the chain liveness to ½*v+ from ⅔*v+ (#219)
NathanBSC Apr 4, 2023
996ddc9
BEP-126: distribute additional reward for collecting extra votes (#220)
NathanBSC Apr 4, 2023
f45910b
BEP216: Implement EIP-3855 PUSH0 instruction (#216)
sunny2022da Apr 12, 2023
76b20da
BEP-217: Implement EIP3860 Limit and meter initcode (#217)
sunny2022da Apr 12, 2023
c93e7c3
BEP-221: CometBFT Light Block Validation (#221)
keefel Apr 14, 2023
2f41027
bep-194: Node Discovery ENR filtering (#194)
MatusKysel Apr 25, 2023
bb3335e
feat: update lock period for large BNB cross-chain transfer (#237)
cosinlink May 2, 2023
ad01317
BEP-126: add fine description for slashing (#239)
NathanBSC May 8, 2023
523bb61
BEP-226: Implement EIP-1559 with base fee of 0 (#226)
Mister-EA May 25, 2023
1a94502
BEP-227: Implement EIP-3198: BASEFEE opcode (#227)
Mister-EA May 25, 2023
fa3dec3
BEP-228: Implement EIP-3541: Prevent deploying contracts starting wit…
Mister-EA May 25, 2023
76cd948
BEP-212: Implement EIP-3529: Reduction in Refunds (#212)
bnb-tw May 25, 2023
13d2393
BEP-225: Implement EIP-2565 ModExp Gas Cost (#225)
sunny2022da May 25, 2023
0a644b9
BEP-229: Implement EIP-2718 Typed Transaction Envelope (#229)
sunny2022da May 25, 2023
9bf0ec1
BEP-230: Implement EIP-2929 Gas cost increases for state access opcod…
sunny2022da May 25, 2023
fb48549
BEP-231: Implement EIP-2930: Optional access lists (#231)
sunny2022da May 25, 2023
2778a39
BEP126: more details about reward rules (#243)
NathanBSC May 31, 2023
e5d57b5
doc: update the brand name (#249)
brilliant-lx Jun 30, 2023
205b74d
BEP-255: Beacon Chain Asset Reconciliation for Security Enhancement (…
forcodedancing Jul 6, 2023
2cd42e9
BEP-1: update workflow (#267)
brilliant-lx Aug 2, 2023
c16a184
Update BEP1.md to include opBNB (#269)
RumeelHussainbnb Aug 2, 2023
bfe4fdb
Restructured repo to move BEP docs in a subfolder (#268)
RumeelHussainbnb Aug 2, 2023
d376af4
BEP-311: Implement EIP-3651 Warm COINBASE (#311)
buddh0 Nov 17, 2023
c4ef59b
BEP-312: Announce EIP-6049 Deprecate SELFDESTRUCT (#312)
buddh0 Nov 17, 2023
58aa565
BEP-319: Optimize the incentive mechanism of the Fast Finality featur…
buddh0 Nov 20, 2023
8a09679
update doc about burn ratio in BEP-319 (#328)
buddh0 Nov 22, 2023
37aeaab
BEP-293: Greenfield Link to opBNB (#293)
yutianwu Nov 28, 2023
531f51c
add Shanghai BEPs into README.md (#335)
buddh0 Dec 7, 2023
f6372b7
BEP-206: Hybrid Mode State Expiry (#206)
setunapo Jan 9, 2024
2415066
state: update the status of some BEPs (#340)
zzzckck Jan 9, 2024
268f2f1
BEP-342: Implement EIP-5656: MCOPY (#342)
MatusKysel Jan 17, 2024
b015df5
BEP-345: Implement EIP-7516: BLOBBASEFEE opcode (#345)
MatusKysel Jan 17, 2024
b1c5f4c
BEP-343: Implement EIP-1153: Transient storage opcodes (#343)
MatusKysel Jan 17, 2024
f558a7f
BEP-344: Implement EIP-6780: SELFDESTRUCT only in same transaction (#…
MatusKysel Jan 17, 2024
55803ce
BEP-323: Bundle Format for Greenfield (#323)
yutianwu Feb 20, 2024
d9d0550
BEP-297: BSC Native Governance Module (#297)
SolidityGo Feb 27, 2024
fea003d
BEP-294: BSC Native Staking after BC Fusion (#294)
pythonberg1997 Feb 27, 2024
7ba9265
BEP-299: Token Migration after BC Fusion (#299)
j75689 Feb 27, 2024
0dc5a6b
BEP-333: BNB Chain Fusion (#333)
forcodedancing Feb 27, 2024
4246395
fix: add the missing BEPS in the readme (#357)
unclezoro Feb 27, 2024
51bd1f3
fix: fix the wrong internal link (#358)
unclezoro Feb 28, 2024
d3238b5
Implement EIP-4844: Shard Blob Transactions (#336)
emailtovamos Mar 5, 2024
58d6fc5
BEP-336: some update to the BSC-4844 (#359)
zzzckck Mar 7, 2024
5b98a3a
readme: add BEP-336, EIP-4844 on BSC (#360)
zzzckck Mar 7, 2024
706e30b
BEP-346:Streamline off-chain authentication on Greenfield
clydemeng Mar 14, 2024
b3218c9
Merge pull request #361 from bnb-chain/BEP-346-offchainauth
ruojunm Mar 15, 2024
4f7cc19
bep-364 (#364)
alexgao001 Mar 18, 2024
03afa4e
BEP-335: Simplify Greenfield storage provider exit (#338)
alexgao001 Mar 18, 2024
4bd8a53
BEP-334: Greenfield CrossChain Permission Module (#334)
SolidityGo Mar 18, 2024
173493b
BEP-362: Greenfield Storage Fee Paymaster (#362)
yutianwu Mar 18, 2024
1f0ffe3
BEP-366: Atomic object update (#346)
alexgao001 Mar 18, 2024
d1ac2a2
BEP-322: Builder API Specification for BNB Smart Chain (#322)
forcodedancing Mar 18, 2024
4571d61
chore: update readme to include un-indexed beps (#367)
forcodedancing Mar 19, 2024
aed6ce5
chore: fix some typos (#375)
HongKuang Apr 8, 2024
9edceaf
BEP-336: update BlobGasPrice (#368)
zzzckck Apr 8, 2024
01485ff
BEP-64: fix typos (#376)
loselarry Apr 23, 2024
a4da4d3
update BEP status (#382)
NathanBSC May 9, 2024
a8ebe19
BEP-381: Precompile for secp256r1 Curve Support (#381)
MatusKysel May 21, 2024
4d10496
remove outdated content for bep322 (#384)
forcodedancing May 22, 2024
622399d
doc: remove broken doc links of BeaconChain BEPs (#388)
zzzckck May 30, 2024
0b1dd10
update the stale doc link (#389)
unclezoro May 30, 2024
8fc7aa0
fix the gnfd doc link (#390)
unclezoro May 30, 2024
9267b77
remove invalid content in the bep322 (#397)
forcodedancing Jun 19, 2024
a232450
BEP-363: Improve Greenfield cross-chain programming capability (#363)
pythonberg1997 Jul 2, 2024
c605f1e
BEP-404: Clear Miner History when Switching Validators Set (#404)
buddh0 Jul 2, 2024
1390735
BEP-402: Complete Missing Fields in Block Header to Generate Signatur…
buddh0 Jul 3, 2024
d79d411
BEP-410: Add Agent for Validators (#410)
cosinlink Jul 18, 2024
d17f65c
Update BEP322.md (#412)
huihzhao Jul 18, 2024
ec476ef
update status of BEPs in README.md (#413)
buddh0 Jul 22, 2024
048b73b
BEP-341: Validators can produce consecutive blocks (#341)
NathanBSC Jul 29, 2024
5446e6c
BEP-1: add vote part for BEP workflow (#416)
zzzckck Aug 1, 2024
38c9f61
BEP414: EOA based Paymaster API Spec (#414)
unclezoro Aug 7, 2024
408c81f
update the title of BEP414
unclezoro Aug 8, 2024
d81901d
Merge pull request #419 from unclezoro/b414
1nanosecond Aug 8, 2024
2c5ab6d
BEP174: fix some typos (#420)
murongshaozong Aug 15, 2024
23e1117
Update README (#434)
Olexandr88 Sep 11, 2024
00f6976
BEP-440: Implement EIP-2935: Serve historical block hashes from state…
buddh0 Oct 8, 2024
29a6f0f
BEP-439: Implement EIP-2537: Precompile for BLS12-381 curve operation…
buddh0 Oct 8, 2024
75a125c
BEP-441: Implement EIP-7702: Set EOA account code (#441)
buddh0 Oct 8, 2024
24de019
Update README.md (#446)
zzzckck Oct 10, 2024
1160b8c
change the status of BEP-414.md
unclezoro Oct 31, 2024
5e62e81
BEP-466: Make the block format compatible with EIP-7685 (#466)
buddh0 Nov 25, 2024
943bdb0
update BEP-441 (#467)
buddh0 Nov 25, 2024
e84746f
Update BEP-466.md (#469)
zzzckck Nov 28, 2024
726f077
Update BEP-466.md (#484)
buddh0 Dec 13, 2024
4e29e73
Update bep 439 and 441 (#489)
buddh0 Dec 16, 2024
296225d
BEP-496: Implement EIP-7623: Increase calldata cost (#496)
galaio Dec 19, 2024
0acb3af
BEP-497: Implement EIP-7691: Blob throughput increase (#497)
galaio Dec 19, 2024
31984f2
chore: fix license issue of some beps (#504)
forcodedancing Jan 2, 2025
8c1e757
feat: bundle data API (#460)
irrun Jan 6, 2025
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
58 changes: 0 additions & 58 deletions BEP1.md

This file was deleted.

133 changes: 133 additions & 0 deletions BEPs/BEP-225.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
<pre>
BEP: 225
Title: Implement EIP2565 ModExp Gas Cost
Status: Enabled
Type: Standards
Created: 2023-4-27
</pre>

# BEP-225: Implement EIP-2565 ModExp Gas Cost
- [BEP-225: Implement EIP2565 ModExp Gas Cost](#bep-225-implement-eip-2565-modexp-gas-cost)
- [1. Summary](#1-summary)
- [2. Abstract](#2-abstract)
- [3. Motivation](#3-motivation)
- [4. Specification](#4-specification)
- [5. Rationale](#5-rationale)
- [6. Test Cases](#6-test-cases)
- [7. Security Considerations](#7-security-considerations)
- [8. License](#8-license)
- [9. Reference](#9-reference)

## 1. Summary

As part of Berlin upgrade, EIP-2565: ModExp Gas Cost is required to be implemented to BSC.

This EIP Defines the gas cost of the `ModExp (0x00..05)` precompile.

## 2. Abstract

To accurately reflect the real world operational cost of the `ModExp` precompile, this EIP specifies an algorithm for
calculating the gas cost.

This algorithm approximates the multiplication complexity cost and multiplies that by an approximation of the
iterations required to execute the exponentiation.

## 3. Motivation

Refer to EIP-2565 description:

Modular exponentiation is a foundational arithmetic operation for many cryptographic functions including signatures,
VDFs, SNARKs, accumulators, and more. Unfortunately, the ModExp precompile is currently over-priced, making these
operations inefficient and expensive.

By reducing the cost of this precompile, these cryptographic functions become more practical, enabling improved
security, stronger randomness (VDFs), and more.

## 4. Specification

As of `FORK_BLOCK_NUMBER`, the gas cost of calling the precompile at address `0x0000000000000000000000000000000000000005`
will be calculated as follows:

```
def calculate_multiplication_complexity(base_length, modulus_length):
max_length = max(base_length, modulus_length)
words = math.ceil(max_length / 8)
return words**2

def calculate_iteration_count(exponent_length, exponent):
iteration_count = 0
if exponent_length <= 32 and exponent == 0: iteration_count = 0
elif exponent_length <= 32: iteration_count = exponent.bit_length() - 1
elif exponent_length > 32: iteration_count = (8 * (exponent_length - 32)) + ((exponent & (2**256 - 1)).bit_length() - 1)
return max(iteration_count, 1)

def calculate_gas_cost(base_length, modulus_length, exponent_length, exponent):
multiplication_complexity = calculate_multiplication_complexity(base_length, modulus_length)
iteration_count = calculate_iteration_count(exponent_length, exponent)
return max(200, math.floor(multiplication_complexity * iteration_count / 3))
```

## 5. Rationale

After benchmarking the ModExp precompile, we discovered that it is ‘overpriced’ relative to other precompiles. We also discovered that the current gas pricing formula could be improved to better estimate the computational complexity of various ModExp input variables. The following changes improve the accuracy of the ModExp pricing:

### Modify `computational complexity` formula to better reflect the computational complexity
The complexity function defined in EIP-198 is as follow:

```
def mult_complexity(x):
if x <= 64: return x ** 2
elif x <= 1024: return x ** 2 // 4 + 96 * x - 3072
else: return x ** 2 // 16 + 480 * x - 199680
```

where is x is max(length_of_MODULUS, length_of_BASE)

The complexity formula in EIP-198 was meant to approximate the difficulty of Karatsuba multiplication. However, we found a better approximation for modelling modular exponentiation. In the complexity formula defined in this EIP, x is divided by 8 to account for the number of limbs in multiprecision arithmetic. A comparison of the current ‘complexity’ function and the proposed function against the execution time can be seen below:

![Complexity Function](./assets/BEP-225/Complexity_Regression.png)

The complexity function defined here has a better fit vs. the execution time when compared to the EIP-198 complexity function. This better fit is because this complexity formula accounts for the use of binary exponentiation algorithms that are used by ‘bigint’ libraries for large exponents. You may also notice the regression line of the proposed complexity function bisects the test vector data points. This is because the run time varies depending on if the modulus is even or odd.

### Change the value of GQUADDIVISOR
After changing the ‘computational complexity’ formula in EIP-198 to the one defined here it is necessary to change QGUADDIVSOR to bring the gas costs inline with their runtime. By setting the QGUADDIVISOR to 3 the cost of the ModExp precompile will have a higher cost (gas/second) than other precompiles such as ECRecover.

![GQuad_Change](./assets/BEP-225/GQuad_Change.png)

### Set a minimum gas cost to prevent abuse
This prevents the precompile from underpricing small input values.

## 6. Test Cases
There are no changes to the underlying interface or arithmetic algorithms, so the existing test vectors can be reused. Below is a table with the updated test vectors:

| Test Case | EIP-198 Pricing | EIP-2565 Pricing |
| --------- | -----------------|------------------|
| modexp_nagydani_1_square | 204 | 200 |
| modexp_nagydani_1_qube | 204 | 200 |
| modexp_nagydani_1_pow0x10001 | 3276 | 341 |
| modexp_nagydani_2_square |665| 200 |
| modexp_nagydani_2_qube |665| 200 |
| modexp_nagydani_2_pow0x10001 |10649| 1365 |
| modexp_nagydani_3_square |1894| 341 |
| modexp_nagydani_3_qube |1894| 341 |
| modexp_nagydani_3_pow0x10001 |30310 | 5461 |
| modexp_nagydani_4_square |5580 | 1365 |
| modexp_nagydani_4_qube |5580 | 1365 |
| modexp_nagydani_4_pow0x10001 |89292 | 21845 |
| modexp_nagydani_5_square |17868 | 5461 |
| modexp_nagydani_5_qube |17868 | 5461 |
| modexp_nagydani_5_pow0x10001 |285900 | 87381 |

## 7. Security Considerations

The biggest security consideration for this EIP is creating a potential DoS vector by making ModExp operations too inexpensive relative to their computation time.

## 8. License

The content is licensed under [CC0](https://creativecommons.org/publicdomain/zero/1.0/).

## 9. Reference

Most description of this BEP refer to [EIP-2565](https://eips.ethereum.org/EIPS/eip-2565):

Kelly Olson (@ineffectualproperty), Sean Gulley (@sean-sn), Simon Peffers (@simonatsn), Justin Drake (@justindrake), Dankrad Feist (@dankrad), "EIP-2565: ModExp Gas Cost," Ethereum Improvement Proposals, no. 2565, March 2020. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-2565.
95 changes: 95 additions & 0 deletions BEPs/BEP-229.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<pre>
BEP: 229
Title: Implement EIP-2718 Typed Transaction Envelope
Status: Enabled
Type: Standards
Created: 2023-4-19
</pre>

# BEP-229: Implement EIP-2718 Typed Transaction Envelope
- [BEP-229: Implement EIP-2718 Typed Transaction Envelope](#bep-229-implement-eip-2718-typed-transaction-envelope)
- [1. Summary](#1-summary)
- [2. Abstract](#2-abstract)
- [3. Motivation](#3-motivation)
- [4. Specification](#4-specification)
- [5. Rationale](#5-rationale)
- [6. Backwards Compatibility](#6-backwards-compatibility)
- [7. Security Considerations](#7-security-considerations)
- [8. License](#8-license)
- [9. Reference](#9-reference)

## 1. Summary
As part of Berlin upgrade, EIP-2718 Typed Transaction Envelope is required to be implemented to BSC.

## 2. Abstract
`TransactionType || TransactionPayload` is a valid transaction and `TransactionType || ReceiptPayload` is a valid transaction receipt where `TransactionType` identifies the format of the transaction and `*Payload` is the transaction/receipt contents, which are defined in future EIPs.

## 3. Motivation
In the past, when we have wanted to add new transaction types we have had to ensure they were backward compatible with all other transactions, meaning that you could differentiate them based only on the encoded payload, and it was not possible to have a transaction that matched both types.
This was seen in [EIP-155](./eip-155.md) where the new value was bit-packed into one of the encoded fields.
There are multiple proposals in discussion that define new transaction types such as one that allows EOA accounts to execute code directly within their context, one that enables someone besides `msg.sender` to pay for gas, and proposals related to layer 1 multi-sig transactions.
These all need to be defined in a way that is mutually compatible, which quickly becomes burdensome to EIP authors and to clients who now have to follow complex rules for differentiating transaction type.

By introducing an envelope transaction type, we only need to ensure backward compatibility with existing transactions and from then on we just need to solve the much simpler problem of ensuring there is no numbering conflict between `TransactionType`s.

## 4. Specification
### Definitions
* `||` is the byte/byte-array concatenation operator.

### Transactions
As of `FORK_BLOCK_NUMBER`, the transaction root in the block header **MUST** be the root hash of `patriciaTrie(rlp(Index) => Transaction)` where:
* `Index` is the index in the block of this transaction
* `Transaction` is either `TransactionType || TransactionPayload` or `LegacyTransaction`
* `TransactionType` is a positive unsigned 8-bit number between `0` and `0x7f` that represents the type of the transaction
* `TransactionPayload` is an opaque byte array whose interpretation is dependent on the `TransactionType` and defined in future EIPs
* `LegacyTransaction` is `rlp([nonce, gasPrice, gasLimit, to, value, data, v, r, s])`

All signatures for future transaction types **SHOULD** include the `TransactionType` as the first byte of the signed data.
This makes it so we do not have to worry about signatures for one transaction type being used as signatures for a different transaction type.

### Receipts
As of `FORK_BLOCK_NUMBER`, the receipt root in the block header **MUST** be the root hash of `patriciaTrie(rlp(Index) => Receipt)` where:
* `Index` is the index in the block of the transaction this receipt is for
* `Receipt` is either `TransactionType || ReceiptPayload` or `LegacyReceipt`
* `TransactionType` is a positive unsigned 8-bit number between `0` and `0x7f` that represents the type of the transaction
* `ReceiptPayload` is an opaque byte array whose interpretation is dependent on the `TransactionType` and defined in future EIPs
* `LegacyReceipt` is `rlp([status, cumulativeGasUsed, logsBloom, logs])`

The `TransactionType` of the receipt **MUST** match the `TransactionType` of the transaction with a matching `Index`.

## 5. Rationale
### TransactionType only goes up to 0x7f
For the forseable future, 0x7f is plenty and it leaves open a number of options for extending the range such as using the high bit as a continuation bit.
This also prevents us from colliding with legacy transaction types, which always start with a byte `>= 0xc0`.
### **SHOULD** instead of **MUST** for the TransactionType being first byte of signed data
While it is strongly recommended that all future transactions sign the first byte to ensure that there is no problem with signature reuse, the authors acknowledge that this may not always make sense or be possible.
One example where this isn't possible is wrapped legacy transactions that are signature compatible with the legacy signing scheme.
Another potential situation is one where transactions don't have a signature in the traditional sense and instead have some other mechanism for determining validity.
### TransactionType selection algorithm
There was discussion about defining the `TransactionType` identifier assignment/selection algorithm in this standard.
While it would be nice to have a standardized mechanism for assignment, at the time of writing of this standard there is not a strong need for it so it was deemed out of scope.
A future EIP may introduce a standard for TransactionType identifier assignment if it is deemed necessary.
### Opaque byte array rather than an RLP array
By having the second byte on be opaque bytes, rather than an RLP (or other encoding) list, we can support different encoding formats for the transaction payload in the future such as SSZ, LEB128, or a fixed width format.
### ORIGIN and CALLER
There was discussion about having ORIGIN and CALLER opcodes become dependent on the transaction type, so that each transaction type could define what those opcodes returned.
However, there is a desire to make transaction type opaque to the contracts to discourage contracts treating different types of transactions differently.
There also were concerns over backward compatibility with existing contracts which make assumptions about ORIGIN and CALLER opcodes.
Going forward, we will assume that all transaction types will have an address that reasonably represents a `CALLER` of the first EVM frame and `ORIGIN` will be the same address in all cases.
If a transaction type needs to supply additional information to contracts, they will need a new opcode.

## 6. Backwards Compatibility
Clients can differentiate between the legacy transactions and typed transactions by looking at the first byte.
If it starts with a value in the range `[0, 0x7f]` then it is a new transaction type, if it starts with a value in the range `[0xc0, 0xfe]` then it is a legacy transaction type.
`0xff` is not realistic for an RLP encoded transaction, so it is reserved for future use as an extension sentinel value.

## 7. Security Considerations
When designing a new 2718 transaction type, it is **STRONGLY** recommended to include the transaction type as the first byte of the signed payload. If you fail to do this, it is possible that your transaction may be signature compatible with transactions of another type which can introduce security vulnerabilities for users.

## 8. License
The content is licensed under [CC0](https://creativecommons.org/publicdomain/zero/1.0/).

## 9. Reference
Most description of this BEP refer to [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718)

Micah Zoltu (@MicahZoltu), "EIP-2718: Typed Transaction Envelope," Ethereum Improvement Proposals, no. 2718, June 2020. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-2718.
Loading