Skip to content

Commit 34a13ff

Browse files
committed
move TSTORE,TLOAD to correct opcode nums and enable 1153
1 parent b669b48 commit 34a13ff

File tree

6 files changed

+14
-18
lines changed

6 files changed

+14
-18
lines changed

core/blockchain_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3612,6 +3612,7 @@ func TestEIP3651(t *testing.T) {
36123612
// between transactions.
36133613
func TestTransientStorageReset(t *testing.T) {
36143614
var (
3615+
db = rawdb.NewMemoryDatabase()
36153616
engine = ethash.NewFaker()
36163617
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
36173618
address = crypto.PubkeyToAddress(key.PublicKey)
@@ -3654,9 +3655,10 @@ func TestTransientStorageReset(t *testing.T) {
36543655
address: {Balance: funds},
36553656
},
36563657
}
3658+
genesis := gspec.MustCommit(db)
36573659
nonce := uint64(0)
36583660
signer := types.HomesteadSigner{}
3659-
_, blocks, _ := GenerateChainWithGenesis(gspec, engine, 1, func(i int, b *BlockGen) {
3661+
blocks, _ := GenerateChain(params.AllCliqueProtocolChanges, genesis, engine, db, 1, func(i int, b *BlockGen) {
36603662
fee := big.NewInt(1)
36613663
if b.header.BaseFee != nil {
36623664
fee = b.header.BaseFee
@@ -3682,7 +3684,7 @@ func TestTransientStorageReset(t *testing.T) {
36823684
})
36833685

36843686
// Initialize the blockchain with 1153 enabled.
3685-
chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), nil, gspec, nil, engine, vmConfig, nil, nil)
3687+
chain, err := NewBlockChain(db, nil, params.AllCliqueProtocolChanges, engine, vmConfig, nil, nil)
36863688
if err != nil {
36873689
t.Fatalf("failed to create tester chain: %v", err)
36883690
}

core/state/transient_storage.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package state
1818

1919
import (
20-
"github.com/ethereum/go-ethereum/common"
20+
"github.com/scroll-tech/go-ethereum/common"
2121
)
2222

2323
// transientStorage is a representation of EIP-1153 "Transient Storage".

core/vm/jump_table.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ type JumpTable [256]*operation
7070
// contantinople, istanbul, petersburg, berlin, london, shanghai, curie, and descartes instructions.
7171
func newDescartesInstructionSet() JumpTable {
7272
instructionSet := newCurieInstructionSet()
73-
73+
enable1153(&instructionSet)
7474
return instructionSet
7575
}
7676

core/vm/opcodes.go

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ const (
120120
MSIZE OpCode = 0x59
121121
GAS OpCode = 0x5a
122122
JUMPDEST OpCode = 0x5b
123+
TLOAD OpCode = 0x5c
124+
TSTORE OpCode = 0x5d
123125
PUSH0 OpCode = 0x5f
124126
)
125127

@@ -223,12 +225,6 @@ const (
223225
SELFDESTRUCT OpCode = 0xff
224226
)
225227

226-
// 0xb0 range.
227-
const (
228-
TLOAD OpCode = 0xb3
229-
TSTORE OpCode = 0xb4
230-
)
231-
232228
// Since the opcodes aren't all in order we can't use a regular slice.
233229
var opCodeToString = map[OpCode]string{
234230
// 0x0 range - arithmetic ops.
@@ -308,6 +304,8 @@ var opCodeToString = map[OpCode]string{
308304
MSIZE: "MSIZE",
309305
GAS: "GAS",
310306
JUMPDEST: "JUMPDEST",
307+
TLOAD: "TLOAD",
308+
TSTORE: "TSTORE",
311309
PUSH0: "PUSH0",
312310

313311
// 0x60 range - push.
@@ -383,10 +381,6 @@ var opCodeToString = map[OpCode]string{
383381
LOG3: "LOG3",
384382
LOG4: "LOG4",
385383

386-
// 0xb0 range.
387-
TLOAD: "TLOAD",
388-
TSTORE: "TSTORE",
389-
390384
// 0xf0 range.
391385
CREATE: "CREATE",
392386
CALL: "CALL",
@@ -476,9 +470,9 @@ var stringToOp = map[string]OpCode{
476470
"MSIZE": MSIZE,
477471
"GAS": GAS,
478472
"JUMPDEST": JUMPDEST,
479-
"PUSH0": PUSH0,
480473
"TLOAD": TLOAD,
481474
"TSTORE": TSTORE,
475+
"PUSH0": PUSH0,
482476
"PUSH1": PUSH1,
483477
"PUSH2": PUSH2,
484478
"PUSH3": PUSH3,

eth/catalyst/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func (api *consensusAPI) AssembleBlock(params assembleBlockParams) (*executableD
179179
from, _ := types.Sender(signer, tx)
180180

181181
// Execute the transaction
182-
env.state.Prepare(tx.Hash(), env.tcount)
182+
env.state.SetTxContext(tx.Hash(), env.tcount)
183183
err = env.commitTransaction(tx, coinbase)
184184
switch err {
185185
case core.ErrGasLimitReached:

rollup/tracing/tracing.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ func (env *TraceEnv) GetBlockTrace(block *types.Block) (*types.BlockTrace, error
210210

211211
// Generate the next state snapshot fast without tracing
212212
msg, _ := tx.AsMessage(env.signer, block.BaseFee())
213-
env.state.Prepare(tx.Hash(), i)
213+
env.state.SetTxContext(tx.Hash(), i)
214214
vmenv := vm.NewEVM(env.blockCtx, core.NewEVMTxContext(msg), env.state, env.chainConfig, vm.Config{})
215215
l1DataFee, err := fees.CalculateL1DataFee(tx, env.state)
216216
if err != nil {
@@ -312,7 +312,7 @@ func (env *TraceEnv) getTxResult(state *state.StateDB, index int, block *types.B
312312
vmenv := vm.NewEVM(env.blockCtx, txContext, state, env.chainConfig, vm.Config{Debug: true, Tracer: tracer, NoBaseFee: true})
313313

314314
// Call Prepare to clear out the statedb access list
315-
state.Prepare(txctx.TxHash, txctx.TxIndex)
315+
state.SetTxContext(txctx.TxHash, txctx.TxIndex)
316316

317317
// Computes the new state by applying the given message.
318318
l1DataFee, err := fees.CalculateL1DataFee(tx, state)

0 commit comments

Comments
 (0)