mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 01:43:47 +00:00
core: create official prague instruction set, name eof set
This commit is contained in:
parent
034f897b40
commit
857641d8f5
6 changed files with 33 additions and 27 deletions
|
|
@ -36,7 +36,7 @@ var jt vm.JumpTable
|
||||||
const initcode = "INITCODE"
|
const initcode = "INITCODE"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
jt = vm.NewPragueEOFInstructionSetForTesting()
|
jt = vm.NewEOFInstructionSetForTesting()
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ func FuzzEofParsing(f *testing.F) {
|
||||||
// And do the fuzzing
|
// And do the fuzzing
|
||||||
f.Fuzz(func(t *testing.T, data []byte) {
|
f.Fuzz(func(t *testing.T, data []byte) {
|
||||||
var (
|
var (
|
||||||
jt = vm.NewPragueEOFInstructionSetForTesting()
|
jt = vm.NewEOFInstructionSetForTesting()
|
||||||
c vm.Container
|
c vm.Container
|
||||||
)
|
)
|
||||||
cpy := common.CopyBytes(data)
|
cpy := common.CopyBytes(data)
|
||||||
|
|
|
||||||
20
cmd/evm/testdata/33/exp.json
vendored
20
cmd/evm/testdata/33/exp.json
vendored
|
|
@ -9,7 +9,7 @@
|
||||||
"balance": "0x29a2241af62c0000"
|
"balance": "0x29a2241af62c0000"
|
||||||
},
|
},
|
||||||
"0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba": {
|
"0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba": {
|
||||||
"balance": "0x2bf52"
|
"balance": "0x2ab02"
|
||||||
},
|
},
|
||||||
"0x703c4b2bd70c169f5717101caee543299fc946c7": {
|
"0x703c4b2bd70c169f5717101caee543299fc946c7": {
|
||||||
"code": "0xef0100000000000000000000000000000000000000bbbb",
|
"code": "0xef0100000000000000000000000000000000000000bbbb",
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
},
|
},
|
||||||
"0x71562b71999873db5b286df957af199ec94617f7": {
|
"0x71562b71999873db5b286df957af199ec94617f7": {
|
||||||
"code": "0xef0100000000000000000000000000000000000000aaaa",
|
"code": "0xef0100000000000000000000000000000000000000aaaa",
|
||||||
"balance": "0x6124fee993afa30e",
|
"balance": "0x6124fee993affe76",
|
||||||
"nonce": "0x2"
|
"nonce": "0x2"
|
||||||
},
|
},
|
||||||
"0x8a0a19589531694250d570040a0c4b74576919b8": {
|
"0x8a0a19589531694250d570040a0c4b74576919b8": {
|
||||||
|
|
@ -35,29 +35,27 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"result": {
|
"result": {
|
||||||
"stateRoot": "0x9fdcacd4510e93c4488e537dc51578b5c6d505771db64a2610036eeb4be7b26f",
|
"stateRoot": "0x90e868da38bc6aff256832d72710207a04fa5ecfd86b0fc326e73d8fcb09dc1c",
|
||||||
"txRoot": "0x5d13a0b074e80388dc754da92b22922313a63417b3e25a10f324935e09697a53",
|
"txRoot": "0x5d13a0b074e80388dc754da92b22922313a63417b3e25a10f324935e09697a53",
|
||||||
"receiptsRoot": "0x504c5d86c34391f70d210e6c482615b391db4bdb9f43479366399d9c5599850a",
|
"receiptsRoot": "0xdd64f30ac99db69f75893bb4b7bb10a76c86cf192ca48c4bfe724d7fe96c469a",
|
||||||
"logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
|
"logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
|
||||||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","receipts": [
|
||||||
"receipts": [
|
|
||||||
{
|
{
|
||||||
"type": "0x4",
|
"type": "0x4",
|
||||||
"root": "0x",
|
"root": "0x",
|
||||||
"status": "0x1",
|
"status": "0x1",
|
||||||
"cumulativeGasUsed": "0x15fa9",
|
"cumulativeGasUsed": "0x15581",
|
||||||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","logs": null,
|
||||||
"logs": null,
|
|
||||||
"transactionHash": "0x0417aab7c1d8a3989190c3167c132876ce9b8afd99262c5a0f9d06802de3d7ef",
|
"transactionHash": "0x0417aab7c1d8a3989190c3167c132876ce9b8afd99262c5a0f9d06802de3d7ef",
|
||||||
"contractAddress": "0x0000000000000000000000000000000000000000",
|
"contractAddress": "0x0000000000000000000000000000000000000000",
|
||||||
"gasUsed": "0x15fa9",
|
"gasUsed": "0x15581",
|
||||||
"effectiveGasPrice": null,
|
"effectiveGasPrice": null,
|
||||||
"blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
"blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||||
"transactionIndex": "0x0"
|
"transactionIndex": "0x0"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"currentDifficulty": null,
|
"currentDifficulty": null,
|
||||||
"gasUsed": "0x15fa9",
|
"gasUsed": "0x15581",
|
||||||
"currentBaseFee": "0x7",
|
"currentBaseFee": "0x7",
|
||||||
"withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
|
"withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
|
||||||
"requestsHash": "0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
"requestsHash": "0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||||
|
|
|
||||||
|
|
@ -251,7 +251,7 @@ func TestValidateCode(t *testing.T) {
|
||||||
data: make([]byte, 0),
|
data: make([]byte, 0),
|
||||||
subContainers: make([]*Container, 0),
|
subContainers: make([]*Container, 0),
|
||||||
}
|
}
|
||||||
_, err := validateCode(test.code, test.section, container, &pragueEOFInstructionSet, false)
|
_, err := validateCode(test.code, test.section, container, &eofInstructionSet, false)
|
||||||
if !errors.Is(err, test.err) {
|
if !errors.Is(err, test.err) {
|
||||||
t.Errorf("test %d (%s): unexpected error (want: %v, got: %v)", i, common.Bytes2Hex(test.code), test.err, err)
|
t.Errorf("test %d (%s): unexpected error (want: %v, got: %v)", i, common.Bytes2Hex(test.code), test.err, err)
|
||||||
}
|
}
|
||||||
|
|
@ -277,7 +277,7 @@ func BenchmarkRJUMPI(b *testing.B) {
|
||||||
}
|
}
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
_, err := validateCode(code, 0, container, &pragueEOFInstructionSet, false)
|
_, err := validateCode(code, 0, container, &eofInstructionSet, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatal(err)
|
b.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
@ -309,7 +309,7 @@ func BenchmarkRJUMPV(b *testing.B) {
|
||||||
}
|
}
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
_, err := validateCode(code, 0, container, &pragueEOFInstructionSet, false)
|
_, err := validateCode(code, 0, container, &pragueInstructionSet, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatal(err)
|
b.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
@ -357,7 +357,7 @@ func BenchmarkEOFValidation(b *testing.B) {
|
||||||
if err := container2.UnmarshalBinary(bin, true); err != nil {
|
if err := container2.UnmarshalBinary(bin, true); err != nil {
|
||||||
b.Fatal(err)
|
b.Fatal(err)
|
||||||
}
|
}
|
||||||
if err := container2.ValidateCode(&pragueEOFInstructionSet, false); err != nil {
|
if err := container2.ValidateCode(&pragueInstructionSet, false); err != nil {
|
||||||
b.Fatal(err)
|
b.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -412,7 +412,7 @@ func BenchmarkEOFValidation2(b *testing.B) {
|
||||||
if err := container2.UnmarshalBinary(bin, true); err != nil {
|
if err := container2.UnmarshalBinary(bin, true); err != nil {
|
||||||
b.Fatal(err)
|
b.Fatal(err)
|
||||||
}
|
}
|
||||||
if err := container2.ValidateCode(&pragueEOFInstructionSet, false); err != nil {
|
if err := container2.ValidateCode(&pragueInstructionSet, false); err != nil {
|
||||||
b.Fatal(err)
|
b.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -468,7 +468,7 @@ func BenchmarkEOFValidation3(b *testing.B) {
|
||||||
if err := container2.UnmarshalBinary(bin, true); err != nil {
|
if err := container2.UnmarshalBinary(bin, true); err != nil {
|
||||||
b.Fatal(err)
|
b.Fatal(err)
|
||||||
}
|
}
|
||||||
if err := container2.ValidateCode(&pragueEOFInstructionSet, false); err != nil {
|
if err := container2.ValidateCode(&pragueInstructionSet, false); err != nil {
|
||||||
b.Fatal(err)
|
b.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -494,7 +494,7 @@ func BenchmarkRJUMPI_2(b *testing.B) {
|
||||||
}
|
}
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
_, err := validateCode(code, 0, container, &pragueEOFInstructionSet, false)
|
_, err := validateCode(code, 0, container, &pragueInstructionSet, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatal(err)
|
b.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
@ -512,6 +512,6 @@ func FuzzValidate(f *testing.F) {
|
||||||
f.Fuzz(func(_ *testing.T, code []byte, maxStack uint16) {
|
f.Fuzz(func(_ *testing.T, code []byte, maxStack uint16) {
|
||||||
var container Container
|
var container Container
|
||||||
container.types = append(container.types, &functionMetadata{inputs: 0, outputs: 0x80, maxStackHeight: maxStack})
|
container.types = append(container.types, &functionMetadata{inputs: 0, outputs: 0x80, maxStackHeight: maxStack})
|
||||||
validateCode(code, 0, &container, &pragueEOFInstructionSet, true)
|
validateCode(code, 0, &container, &pragueInstructionSet, true)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,8 @@ func NewEVMInterpreter(evm *EVM) *EVMInterpreter {
|
||||||
case evm.chainRules.IsVerkle:
|
case evm.chainRules.IsVerkle:
|
||||||
// TODO replace with proper instruction set when fork is specified
|
// TODO replace with proper instruction set when fork is specified
|
||||||
table = &verkleInstructionSet
|
table = &verkleInstructionSet
|
||||||
|
case evm.chainRules.IsPrague:
|
||||||
|
table = &pragueInstructionSet
|
||||||
case evm.chainRules.IsCancun:
|
case evm.chainRules.IsCancun:
|
||||||
table = &cancunInstructionSet
|
table = &cancunInstructionSet
|
||||||
case evm.chainRules.IsShanghai:
|
case evm.chainRules.IsShanghai:
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,8 @@ var (
|
||||||
shanghaiInstructionSet = newShanghaiInstructionSet()
|
shanghaiInstructionSet = newShanghaiInstructionSet()
|
||||||
cancunInstructionSet = newCancunInstructionSet()
|
cancunInstructionSet = newCancunInstructionSet()
|
||||||
verkleInstructionSet = newVerkleInstructionSet()
|
verkleInstructionSet = newVerkleInstructionSet()
|
||||||
pragueEOFInstructionSet = newPragueEOFInstructionSet()
|
pragueInstructionSet = newPragueInstructionSet()
|
||||||
|
eofInstructionSet = newEOFInstructionSetForTesting()
|
||||||
)
|
)
|
||||||
|
|
||||||
// JumpTable contains the EVM opcodes supported at a given fork.
|
// JumpTable contains the EVM opcodes supported at a given fork.
|
||||||
|
|
@ -91,16 +92,22 @@ func newVerkleInstructionSet() JumpTable {
|
||||||
return validate(instructionSet)
|
return validate(instructionSet)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPragueEOFInstructionSetForTesting() JumpTable {
|
func NewEOFInstructionSetForTesting() JumpTable {
|
||||||
return newPragueEOFInstructionSet()
|
return newEOFInstructionSetForTesting()
|
||||||
}
|
}
|
||||||
|
|
||||||
func newPragueEOFInstructionSet() JumpTable {
|
func newEOFInstructionSetForTesting() JumpTable {
|
||||||
instructionSet := newCancunInstructionSet()
|
instructionSet := newPragueInstructionSet()
|
||||||
enableEOF(&instructionSet)
|
enableEOF(&instructionSet)
|
||||||
return validate(instructionSet)
|
return validate(instructionSet)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func newPragueInstructionSet() JumpTable {
|
||||||
|
instructionSet := newCancunInstructionSet()
|
||||||
|
enable7702(&instructionSet) // EIP-7702 Setcode transaction type
|
||||||
|
return validate(instructionSet)
|
||||||
|
}
|
||||||
|
|
||||||
func newCancunInstructionSet() JumpTable {
|
func newCancunInstructionSet() JumpTable {
|
||||||
instructionSet := newShanghaiInstructionSet()
|
instructionSet := newShanghaiInstructionSet()
|
||||||
enable4844(&instructionSet) // EIP-4844 (BLOBHASH opcode)
|
enable4844(&instructionSet) // EIP-4844 (BLOBHASH opcode)
|
||||||
|
|
@ -108,7 +115,6 @@ func newCancunInstructionSet() JumpTable {
|
||||||
enable1153(&instructionSet) // EIP-1153 "Transient Storage"
|
enable1153(&instructionSet) // EIP-1153 "Transient Storage"
|
||||||
enable5656(&instructionSet) // EIP-5656 (MCOPY opcode)
|
enable5656(&instructionSet) // EIP-5656 (MCOPY opcode)
|
||||||
enable6780(&instructionSet) // EIP-6780 SELFDESTRUCT only in same transaction
|
enable6780(&instructionSet) // EIP-6780 SELFDESTRUCT only in same transaction
|
||||||
enable7702(&instructionSet)
|
|
||||||
return validate(instructionSet)
|
return validate(instructionSet)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue