Skip to content

Commit 65f16cd

Browse files
authored
Revert "core: 4844 opcode and precompile (ethereum#27356)"
This reverts commit 4590721.
1 parent b6b6d79 commit 65f16cd

File tree

15 files changed

+13
-199
lines changed

15 files changed

+13
-199
lines changed

cmd/evm/runner.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ func runCmd(ctx *cli.Context) error {
128128
receiver = common.BytesToAddress([]byte("receiver"))
129129
genesisConfig *core.Genesis
130130
preimages = ctx.Bool(DumpFlag.Name)
131-
blobHashes []common.Hash // TODO (MariusVanDerWijden) implement blob hashes in state tests
132131
)
133132
if ctx.Bool(MachineFlag.Name) {
134133
tracer = logger.NewJSONLogger(logconfig, os.Stdout)
@@ -218,7 +217,6 @@ func runCmd(ctx *cli.Context) error {
218217
Time: genesisConfig.Timestamp,
219218
Coinbase: genesisConfig.Coinbase,
220219
BlockNumber: new(big.Int).SetUint64(genesisConfig.Number),
221-
BlobHashes: blobHashes,
222220
EVMConfig: vm.Config{
223221
Tracer: tracer,
224222
},

core/evm.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@ func NewEVMBlockContext(header *types.Header, chain ChainContext, author *common
7272
// NewEVMTxContext creates a new transaction context for a single transaction.
7373
func NewEVMTxContext(msg *Message) vm.TxContext {
7474
return vm.TxContext{
75-
Origin: msg.From,
76-
GasPrice: new(big.Int).Set(msg.GasPrice),
77-
BlobHashes: msg.BlobHashes,
75+
Origin: msg.From,
76+
GasPrice: new(big.Int).Set(msg.GasPrice),
7877
}
7978
}
8079

core/state_transition.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ type Message struct {
135135
GasTipCap *big.Int
136136
Data []byte
137137
AccessList types.AccessList
138-
BlobHashes []common.Hash
139138

140139
// When SkipAccountChecks is true, the message nonce is not checked against the
141140
// account nonce in state. It also disables checking that the sender is an EOA.
@@ -156,7 +155,6 @@ func TransactionToMessage(tx *types.Transaction, s types.Signer, baseFee *big.In
156155
Data: tx.Data(),
157156
AccessList: tx.AccessList(),
158157
SkipAccountChecks: false,
159-
BlobHashes: tx.BlobHashes(),
160158
}
161159
// If baseFee provided, set gasPrice to effectiveGasPrice.
162160
if baseFee != nil {

core/vm/contracts.go

Lines changed: 0 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"crypto/sha256"
2121
"encoding/binary"
2222
"errors"
23-
"fmt"
2423
"math/big"
2524

2625
"github.com/ethereum/go-ethereum/common"
@@ -29,7 +28,6 @@ import (
2928
"github.com/ethereum/go-ethereum/crypto/blake2b"
3029
"github.com/ethereum/go-ethereum/crypto/bls12381"
3130
"github.com/ethereum/go-ethereum/crypto/bn256"
32-
"github.com/ethereum/go-ethereum/crypto/kzg4844"
3331
"github.com/ethereum/go-ethereum/params"
3432
"golang.org/x/crypto/ripemd160"
3533
)
@@ -92,21 +90,6 @@ var PrecompiledContractsBerlin = map[common.Address]PrecompiledContract{
9290
common.BytesToAddress([]byte{9}): &blake2F{},
9391
}
9492

95-
// PrecompiledContractsCancun contains the default set of pre-compiled Ethereum
96-
// contracts used in the Cancun release.
97-
var PrecompiledContractsCancun = map[common.Address]PrecompiledContract{
98-
common.BytesToAddress([]byte{1}): &ecrecover{},
99-
common.BytesToAddress([]byte{2}): &sha256hash{},
100-
common.BytesToAddress([]byte{3}): &ripemd160hash{},
101-
common.BytesToAddress([]byte{4}): &dataCopy{},
102-
common.BytesToAddress([]byte{5}): &bigModExp{eip2565: true},
103-
common.BytesToAddress([]byte{6}): &bn256AddIstanbul{},
104-
common.BytesToAddress([]byte{7}): &bn256ScalarMulIstanbul{},
105-
common.BytesToAddress([]byte{8}): &bn256PairingIstanbul{},
106-
common.BytesToAddress([]byte{9}): &blake2F{},
107-
common.BytesToAddress([]byte{20}): &kzgPointEvaluation{},
108-
}
109-
11093
// PrecompiledContractsBLS contains the set of pre-compiled Ethereum
11194
// contracts specified in EIP-2537. These are exported for testing purposes.
11295
var PrecompiledContractsBLS = map[common.Address]PrecompiledContract{
@@ -122,7 +105,6 @@ var PrecompiledContractsBLS = map[common.Address]PrecompiledContract{
122105
}
123106

124107
var (
125-
PrecompiledAddressesCancun []common.Address
126108
PrecompiledAddressesBerlin []common.Address
127109
PrecompiledAddressesIstanbul []common.Address
128110
PrecompiledAddressesByzantium []common.Address
@@ -142,16 +124,11 @@ func init() {
142124
for k := range PrecompiledContractsBerlin {
143125
PrecompiledAddressesBerlin = append(PrecompiledAddressesBerlin, k)
144126
}
145-
for k := range PrecompiledContractsCancun {
146-
PrecompiledAddressesCancun = append(PrecompiledAddressesCancun, k)
147-
}
148127
}
149128

150129
// ActivePrecompiles returns the precompiles enabled with the current configuration.
151130
func ActivePrecompiles(rules params.Rules) []common.Address {
152131
switch {
153-
case rules.IsCancun:
154-
return PrecompiledAddressesCancun
155132
case rules.IsBerlin:
156133
return PrecompiledAddressesBerlin
157134
case rules.IsIstanbul:
@@ -1071,67 +1048,3 @@ func (c *bls12381MapG2) Run(input []byte) ([]byte, error) {
10711048
// Encode the G2 point to 256 bytes
10721049
return g.EncodePoint(r), nil
10731050
}
1074-
1075-
// kzgPointEvaluation implements the EIP-4844 point evaluation precompile.
1076-
type kzgPointEvaluation struct{}
1077-
1078-
// RequiredGas estimates the gas required for running the point evaluation precompile.
1079-
func (b *kzgPointEvaluation) RequiredGas(input []byte) uint64 {
1080-
return params.BlobTxPointEvaluationPrecompileGas
1081-
}
1082-
1083-
const (
1084-
blobVerifyInputLength = 192 // Max input length for the point evaluation precompile.
1085-
blobCommitmentVersionKZG uint8 = 0x01 // Version byte for the point evaluation precompile.
1086-
blobPrecompileReturnValue = "000000000000000000000000000000000000000000000000000000000000100073eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001"
1087-
)
1088-
1089-
var (
1090-
errBlobVerifyInvalidInputLength = errors.New("invalid input length")
1091-
errBlobVerifyMismatchedVersion = errors.New("mismatched versioned hash")
1092-
errBlobVerifyKZGProof = errors.New("error verifying kzg proof")
1093-
)
1094-
1095-
// Run executes the point evaluation precompile.
1096-
func (b *kzgPointEvaluation) Run(input []byte) ([]byte, error) {
1097-
if len(input) != blobVerifyInputLength {
1098-
return nil, errBlobVerifyInvalidInputLength
1099-
}
1100-
// versioned hash: first 32 bytes
1101-
var versionedHash common.Hash
1102-
copy(versionedHash[:], input[:])
1103-
1104-
var (
1105-
point kzg4844.Point
1106-
claim kzg4844.Claim
1107-
)
1108-
// Evaluation point: next 32 bytes
1109-
copy(point[:], input[32:])
1110-
// Expected output: next 32 bytes
1111-
copy(claim[:], input[64:])
1112-
1113-
// input kzg point: next 48 bytes
1114-
var commitment kzg4844.Commitment
1115-
copy(commitment[:], input[96:])
1116-
if kZGToVersionedHash(commitment) != versionedHash {
1117-
return nil, errBlobVerifyMismatchedVersion
1118-
}
1119-
1120-
// Proof: next 48 bytes
1121-
var proof kzg4844.Proof
1122-
copy(proof[:], input[144:])
1123-
1124-
if err := kzg4844.VerifyProof(commitment, point, claim, proof); err != nil {
1125-
return nil, fmt.Errorf("%w: %v", errBlobVerifyKZGProof, err)
1126-
}
1127-
1128-
return common.Hex2Bytes(blobPrecompileReturnValue), nil
1129-
}
1130-
1131-
// kZGToVersionedHash implements kzg_to_versioned_hash from EIP-4844
1132-
func kZGToVersionedHash(kzg kzg4844.Commitment) common.Hash {
1133-
h := sha256.Sum256(kzg[:])
1134-
h[0] = blobCommitmentVersionKZG
1135-
1136-
return h
1137-
}

core/vm/contracts_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ var allPrecompiles = map[common.Address]PrecompiledContract{
6565
common.BytesToAddress([]byte{16}): &bls12381Pairing{},
6666
common.BytesToAddress([]byte{17}): &bls12381MapG1{},
6767
common.BytesToAddress([]byte{18}): &bls12381MapG2{},
68-
common.BytesToAddress([]byte{20}): &kzgPointEvaluation{},
6968
}
7069

7170
// EIP-152 test vectors
@@ -312,7 +311,6 @@ func TestPrecompiledBLS12381G2MultiExp(t *testing.T) { testJson("blsG2MultiExp",
312311
func TestPrecompiledBLS12381Pairing(t *testing.T) { testJson("blsPairing", "10", t) }
313312
func TestPrecompiledBLS12381MapG1(t *testing.T) { testJson("blsMapG1", "11", t) }
314313
func TestPrecompiledBLS12381MapG2(t *testing.T) { testJson("blsMapG2", "12", t) }
315-
func TestPrecompiledPointEvaluation(t *testing.T) { testJson("pointEvaluation", "14", t) }
316314

317315
func BenchmarkPrecompiledBLS12381G1Add(b *testing.B) { benchJson("blsG1Add", "0a", b) }
318316
func BenchmarkPrecompiledBLS12381G1Mul(b *testing.B) { benchJson("blsG1Mul", "0b", b) }

core/vm/eips.go

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -235,32 +235,9 @@ func opPush0(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]by
235235
return nil, nil
236236
}
237237

238-
// enable3860 enables "EIP-3860: Limit and meter initcode"
238+
// ebnable3860 enables "EIP-3860: Limit and meter initcode"
239239
// https://eips.ethereum.org/EIPS/eip-3860
240240
func enable3860(jt *JumpTable) {
241241
jt[CREATE].dynamicGas = gasCreateEip3860
242242
jt[CREATE2].dynamicGas = gasCreate2Eip3860
243243
}
244-
245-
// opBlobHash implements the BLOBHASH opcode
246-
func opBlobHash(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
247-
index := scope.Stack.peek()
248-
if index.LtUint64(uint64(len(interpreter.evm.TxContext.BlobHashes))) {
249-
blobHash := interpreter.evm.TxContext.BlobHashes[index.Uint64()]
250-
index.SetBytes32(blobHash[:])
251-
} else {
252-
index.Clear()
253-
}
254-
return nil, nil
255-
}
256-
257-
// enable4844 applies EIP-4844 (DATAHASH opcode)
258-
func enable4844(jt *JumpTable) {
259-
// New opcode
260-
jt[BLOBHASH] = &operation{
261-
execute: opBlobHash,
262-
constantGas: GasFastestStep,
263-
minStack: minStack(1, 1),
264-
maxStack: maxStack(1, 1),
265-
}
266-
}

core/vm/evm.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ type (
4343
func (evm *EVM) precompile(addr common.Address) (PrecompiledContract, bool) {
4444
var precompiles map[common.Address]PrecompiledContract
4545
switch {
46-
case evm.chainRules.IsCancun:
47-
precompiles = PrecompiledContractsCancun
4846
case evm.chainRules.IsBerlin:
4947
precompiles = PrecompiledContractsBerlin
5048
case evm.chainRules.IsIstanbul:
@@ -83,9 +81,8 @@ type BlockContext struct {
8381
// All fields can change between transactions.
8482
type TxContext struct {
8583
// Message information
86-
Origin common.Address // Provides information for ORIGIN
87-
GasPrice *big.Int // Provides information for GASPRICE
88-
BlobHashes []common.Hash // Provides information for BLOBHASH
84+
Origin common.Address // Provides information for ORIGIN
85+
GasPrice *big.Int // Provides information for GASPRICE
8986
}
9087

9188
// EVM is the Ethereum Virtual Machine base object and provides

core/vm/instructions_test.go

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -746,45 +746,3 @@ func TestRandom(t *testing.T) {
746746
}
747747
}
748748
}
749-
750-
func TestBlobHash(t *testing.T) {
751-
type testcase struct {
752-
name string
753-
idx uint64
754-
expect common.Hash
755-
hashes []common.Hash
756-
}
757-
var (
758-
zero = common.Hash{0}
759-
one = common.Hash{1}
760-
two = common.Hash{2}
761-
three = common.Hash{3}
762-
)
763-
for _, tt := range []testcase{
764-
{name: "[{1}]", idx: 0, expect: one, hashes: []common.Hash{one}},
765-
{name: "[1,{2},3]", idx: 2, expect: three, hashes: []common.Hash{one, two, three}},
766-
{name: "out-of-bounds (empty)", idx: 10, expect: zero, hashes: []common.Hash{}},
767-
{name: "out-of-bounds", idx: 25, expect: zero, hashes: []common.Hash{one, two, three}},
768-
{name: "out-of-bounds (nil)", idx: 25, expect: zero, hashes: nil},
769-
} {
770-
var (
771-
env = NewEVM(BlockContext{}, TxContext{BlobHashes: tt.hashes}, nil, params.TestChainConfig, Config{})
772-
stack = newstack()
773-
pc = uint64(0)
774-
evmInterpreter = env.interpreter
775-
)
776-
stack.push(uint256.NewInt(tt.idx))
777-
opBlobHash(&pc, evmInterpreter, &ScopeContext{nil, stack, nil})
778-
if len(stack.data) != 1 {
779-
t.Errorf("Expected one item on stack after %v, got %d: ", tt.name, len(stack.data))
780-
}
781-
actual := stack.pop()
782-
expected, overflow := uint256.FromBig(new(big.Int).SetBytes(tt.expect.Bytes()))
783-
if overflow {
784-
t.Errorf("Testcase %v: invalid overflow", tt.name)
785-
}
786-
if actual.Cmp(expected) != 0 {
787-
t.Errorf("Testcase %v: expected %x, got %x", tt.name, expected, actual)
788-
}
789-
}
790-
}

core/vm/interpreter.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ func NewEVMInterpreter(evm *EVM) *EVMInterpreter {
5656
// If jump table was not initialised we set the default one.
5757
var table *JumpTable
5858
switch {
59-
case evm.chainRules.IsCancun:
60-
table = &cancunInstructionSet
6159
case evm.chainRules.IsShanghai:
6260
table = &shanghaiInstructionSet
6361
case evm.chainRules.IsMerge:

core/vm/jump_table.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ var (
5656
londonInstructionSet = newLondonInstructionSet()
5757
mergeInstructionSet = newMergeInstructionSet()
5858
shanghaiInstructionSet = newShanghaiInstructionSet()
59-
cancunInstructionSet = newCancunInstructionSet()
6059
)
6160

6261
// JumpTable contains the EVM opcodes supported at a given fork.
@@ -80,12 +79,6 @@ func validate(jt JumpTable) JumpTable {
8079
return jt
8180
}
8281

83-
func newCancunInstructionSet() JumpTable {
84-
instructionSet := newShanghaiInstructionSet()
85-
enable4844(&instructionSet) // BLOBHASH opcode
86-
return validate(instructionSet)
87-
}
88-
8982
func newShanghaiInstructionSet() JumpTable {
9083
instructionSet := newMergeInstructionSet()
9184
enable3855(&instructionSet) // PUSH0 instruction

0 commit comments

Comments
 (0)