Skip to content

Commit 34e64b7

Browse files
jwasingerMariusVanDerWijden
authored andcommitted
add scaffolding for Osaka precompiles. Make it more explicit when 7883 is/isn't enabled in tests.
1 parent 7098d42 commit 34e64b7

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

core/vm/contracts.go

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ var PrecompiledContractsByzantium = PrecompiledContracts{
6666
common.BytesToAddress([]byte{0x2}): &sha256hash{},
6767
common.BytesToAddress([]byte{0x3}): &ripemd160hash{},
6868
common.BytesToAddress([]byte{0x4}): &dataCopy{},
69-
common.BytesToAddress([]byte{0x5}): &bigModExp{eip2565: false},
69+
common.BytesToAddress([]byte{0x5}): &bigModExp{eip2565: false, eip7883: false},
7070
common.BytesToAddress([]byte{0x6}): &bn256AddByzantium{},
7171
common.BytesToAddress([]byte{0x7}): &bn256ScalarMulByzantium{},
7272
common.BytesToAddress([]byte{0x8}): &bn256PairingByzantium{},
@@ -79,7 +79,7 @@ var PrecompiledContractsIstanbul = PrecompiledContracts{
7979
common.BytesToAddress([]byte{0x2}): &sha256hash{},
8080
common.BytesToAddress([]byte{0x3}): &ripemd160hash{},
8181
common.BytesToAddress([]byte{0x4}): &dataCopy{},
82-
common.BytesToAddress([]byte{0x5}): &bigModExp{eip2565: false},
82+
common.BytesToAddress([]byte{0x5}): &bigModExp{eip2565: false, eip7883: false},
8383
common.BytesToAddress([]byte{0x6}): &bn256AddIstanbul{},
8484
common.BytesToAddress([]byte{0x7}): &bn256ScalarMulIstanbul{},
8585
common.BytesToAddress([]byte{0x8}): &bn256PairingIstanbul{},
@@ -93,7 +93,7 @@ var PrecompiledContractsBerlin = PrecompiledContracts{
9393
common.BytesToAddress([]byte{0x2}): &sha256hash{},
9494
common.BytesToAddress([]byte{0x3}): &ripemd160hash{},
9595
common.BytesToAddress([]byte{0x4}): &dataCopy{},
96-
common.BytesToAddress([]byte{0x5}): &bigModExp{eip2565: true},
96+
common.BytesToAddress([]byte{0x5}): &bigModExp{eip2565: true, eip7883: false},
9797
common.BytesToAddress([]byte{0x6}): &bn256AddIstanbul{},
9898
common.BytesToAddress([]byte{0x7}): &bn256ScalarMulIstanbul{},
9999
common.BytesToAddress([]byte{0x8}): &bn256PairingIstanbul{},
@@ -107,7 +107,7 @@ var PrecompiledContractsCancun = PrecompiledContracts{
107107
common.BytesToAddress([]byte{0x2}): &sha256hash{},
108108
common.BytesToAddress([]byte{0x3}): &ripemd160hash{},
109109
common.BytesToAddress([]byte{0x4}): &dataCopy{},
110-
common.BytesToAddress([]byte{0x5}): &bigModExp{eip2565: true},
110+
common.BytesToAddress([]byte{0x5}): &bigModExp{eip2565: true, eip7883: false},
111111
common.BytesToAddress([]byte{0x6}): &bn256AddIstanbul{},
112112
common.BytesToAddress([]byte{0x7}): &bn256ScalarMulIstanbul{},
113113
common.BytesToAddress([]byte{0x8}): &bn256PairingIstanbul{},
@@ -122,7 +122,7 @@ var PrecompiledContractsPrague = PrecompiledContracts{
122122
common.BytesToAddress([]byte{0x02}): &sha256hash{},
123123
common.BytesToAddress([]byte{0x03}): &ripemd160hash{},
124124
common.BytesToAddress([]byte{0x04}): &dataCopy{},
125-
common.BytesToAddress([]byte{0x05}): &bigModExp{eip2565: true},
125+
common.BytesToAddress([]byte{0x05}): &bigModExp{eip2565: true, eip7883: false},
126126
common.BytesToAddress([]byte{0x06}): &bn256AddIstanbul{},
127127
common.BytesToAddress([]byte{0x07}): &bn256ScalarMulIstanbul{},
128128
common.BytesToAddress([]byte{0x08}): &bn256PairingIstanbul{},
@@ -141,6 +141,28 @@ var PrecompiledContractsBLS = PrecompiledContractsPrague
141141

142142
var PrecompiledContractsVerkle = PrecompiledContractsPrague
143143

144+
// PrecompiledContractsOsaka contains the set of pre-compiled Ethereum
145+
// contracts used in the Osaka release.
146+
var PrecompiledContractsOsaka = PrecompiledContracts{
147+
common.BytesToAddress([]byte{0x01}): &ecrecover{},
148+
common.BytesToAddress([]byte{0x02}): &sha256hash{},
149+
common.BytesToAddress([]byte{0x03}): &ripemd160hash{},
150+
common.BytesToAddress([]byte{0x04}): &dataCopy{},
151+
common.BytesToAddress([]byte{0x05}): &bigModExp{eip2565: true, eip7883: true},
152+
common.BytesToAddress([]byte{0x06}): &bn256AddIstanbul{},
153+
common.BytesToAddress([]byte{0x07}): &bn256ScalarMulIstanbul{},
154+
common.BytesToAddress([]byte{0x08}): &bn256PairingIstanbul{},
155+
common.BytesToAddress([]byte{0x09}): &blake2F{},
156+
common.BytesToAddress([]byte{0x0a}): &kzgPointEvaluation{},
157+
common.BytesToAddress([]byte{0x0b}): &bls12381G1Add{},
158+
common.BytesToAddress([]byte{0x0c}): &bls12381G1MultiExp{},
159+
common.BytesToAddress([]byte{0x0d}): &bls12381G2Add{},
160+
common.BytesToAddress([]byte{0x0e}): &bls12381G2MultiExp{},
161+
common.BytesToAddress([]byte{0x0f}): &bls12381Pairing{},
162+
common.BytesToAddress([]byte{0x10}): &bls12381MapG1{},
163+
common.BytesToAddress([]byte{0x11}): &bls12381MapG2{},
164+
}
165+
144166
var (
145167
PrecompiledAddressesPrague []common.Address
146168
PrecompiledAddressesCancun []common.Address
@@ -175,6 +197,8 @@ func activePrecompiledContracts(rules params.Rules) PrecompiledContracts {
175197
switch {
176198
case rules.IsVerkle:
177199
return PrecompiledContractsVerkle
200+
case rules.IsOsaka:
201+
return PrecompiledContractsOsaka
178202
case rules.IsPrague:
179203
return PrecompiledContractsPrague
180204
case rules.IsCancun:

core/vm/contracts_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ var allPrecompiles = map[common.Address]PrecompiledContract{
5050
common.BytesToAddress([]byte{2}): &sha256hash{},
5151
common.BytesToAddress([]byte{3}): &ripemd160hash{},
5252
common.BytesToAddress([]byte{4}): &dataCopy{},
53-
common.BytesToAddress([]byte{5}): &bigModExp{eip2565: false},
54-
common.BytesToAddress([]byte{0xf5}): &bigModExp{eip2565: true},
53+
common.BytesToAddress([]byte{5}): &bigModExp{eip2565: false, eip7883: false},
54+
common.BytesToAddress([]byte{0xf5}): &bigModExp{eip2565: true, eip7883: false},
5555
common.BytesToAddress([]byte{0xf6}): &bigModExp{eip2565: true, eip7883: true},
5656
common.BytesToAddress([]byte{6}): &bn256AddIstanbul{},
5757
common.BytesToAddress([]byte{7}): &bn256ScalarMulIstanbul{},

0 commit comments

Comments
 (0)