Skip to content

Commit 3c7256e

Browse files
Merge pull request #1644 from maticnetwork/v2.2.9-candidate
v2.2.9
2 parents e792802 + fb73083 commit 3c7256e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+978
-650
lines changed

.github/matic-cli-config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ blockNumber:
2121
- '0'
2222

2323
sprintSize:
24-
- '64'
24+
- '16'
2525
sprintSizeBlockNumber:
2626
- '0'
2727

.github/workflows/ci.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -260,15 +260,7 @@ jobs:
260260
261261
- name: Run smoke tests
262262
run: |
263-
echo "Deposit 100 matic for each account to bor network"
264-
cd matic-cli/devnet/devnet
265-
SCRIPT_ADDRESS=$(jq -r '.[0].address' signer-dump.json)
266-
SCRIPT_PRIVATE_KEY=$(jq -r '.[0].priv_key' signer-dump.json)
267-
cd ../code/pos-contracts
268-
CONTRACT_ADDRESS=$(jq -r .root.tokens.MaticToken contractAddresses.json)
269-
forge script scripts/matic-cli-scripts/Deposit.s.sol:MaticDeposit --rpc-url http://localhost:9545 --private-key $SCRIPT_PRIVATE_KEY --broadcast --sig "run(address,address,uint256)" $SCRIPT_ADDRESS $CONTRACT_ADDRESS 100000000000000000000
270-
cd ../../../..
271-
timeout 60m bash bor/integration-tests/smoke_test.sh
263+
timeout 20m bash bor/integration-tests/smoke_test.sh
272264
273265
- name: Run RPC Tests
274266
run: |

accounts/abi/bind/backends/simulated.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ func (b *SimulatedBackend) callContract(ctx context.Context, call ethereum.CallM
714714
vmEnv := vm.NewEVM(evmContext, stateDB, b.config, vm.Config{NoBaseFee: true})
715715
gasPool := new(core.GasPool).AddGas(gomath.MaxUint64)
716716

717-
return core.ApplyMessage(vmEnv, msg, gasPool, context.Background())
717+
return core.ApplyMessage(vmEnv, msg, gasPool, nil)
718718
}
719719

720720
// SendTransaction updates the pending block to include the given transaction.

builder/files/config.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,13 @@ syncmode = "full"
163163
# timeout = "1h0m0s"
164164
# fdlimit = 0
165165

166-
[accounts]
166+
# [history]
167+
# transactions = 2350000
168+
# logs = 2350000
169+
# "logs.disable" = false
170+
# state = 90000
171+
172+
# [accounts]
167173
# allow-insecure-unlock = true
168174
# password = "/var/lib/bor/password.txt"
169175
# unlock = ["VALIDATOR ADDRESS"]

core/blockchain.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3029,7 +3029,14 @@ func (bc *BlockChain) reorg(oldHead *types.Header, newHead *types.Header) error
30293029
return errInvalidNewChain
30303030
}
30313031
}
3032+
30323033
// Ensure the user sees large reorgs
3034+
if len(oldChain) == 0 && len(newChain) == 0 {
3035+
// No actual reorg, same block
3036+
log.Info("No reorg needed; old and new head are identical", "number", oldHead.Number, "hash", oldHead.Hash())
3037+
return nil
3038+
}
3039+
30333040
if len(oldChain) > 0 && len(newChain) > 0 {
30343041
bc.chain2HeadFeed.Send(Chain2HeadEvent{
30353042
Type: Chain2HeadReorgEvent,

core/parallel_state_processor.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,11 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat
276276
metadata bool
277277
)
278278

279+
// Set an empty context if nil
280+
if interruptCtx == nil {
281+
interruptCtx = context.Background()
282+
}
283+
279284
// Mutate the block and state according to any hard-fork specs
280285
if p.config.DAOForkSupport && p.config.DAOForkBlock != nil && p.config.DAOForkBlock.Cmp(block.Number()) == 0 {
281286
misc.ApplyDAOHardFork(statedb)

core/state_prefetcher.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package core
1818

1919
import (
20-
"context"
2120
"sync/atomic"
2221

2322
"github.com/ethereum/go-ethereum/core/state"
@@ -71,7 +70,7 @@ func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, c
7170

7271
// We attempt to apply a transaction. The goal is not to execute
7372
// the transaction successfully, rather to warm up touched data slots.
74-
if _, err := ApplyMessage(evm, msg, gaspool, context.Background()); err != nil {
73+
if _, err := ApplyMessage(evm, msg, gaspool, nil); err != nil {
7574
return // Ugh, something went horribly wrong, bail out
7675
}
7776
// If we're pre-byzantium, pre-load trie nodes for the intermediate root

core/state_processor.go

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"context"
2121
"fmt"
2222
"math/big"
23+
"sync/atomic"
2324

2425
"github.com/ethereum/go-ethereum/common"
2526
cmath "github.com/ethereum/go-ethereum/common/math"
@@ -69,6 +70,11 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
6970
gp = new(GasPool).AddGas(block.GasLimit())
7071
)
7172

73+
// Set an empty context if nil
74+
if interruptCtx == nil {
75+
interruptCtx = context.Background()
76+
}
77+
7278
// Mutate the block and state according to any hard-fork specs
7379
if p.config.DAOForkSupport && p.config.DAOForkBlock != nil && p.config.DAOForkBlock.Cmp(block.Number()) == 0 {
7480
misc.ApplyDAOHardFork(statedb)
@@ -96,21 +102,21 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
96102

97103
// Iterate over and process the individual transactions
98104
for i, tx := range block.Transactions() {
99-
if interruptCtx != nil {
100-
select {
101-
case <-interruptCtx.Done():
102-
return nil, interruptCtx.Err()
103-
default:
104-
}
105+
// Check if execution should be cancelled or not
106+
select {
107+
case <-interruptCtx.Done():
108+
return nil, interruptCtx.Err()
109+
default:
105110
}
111+
106112
msg, err := TransactionToMessage(tx, signer, header.BaseFee)
107113
if err != nil {
108114
return nil, fmt.Errorf("could not apply tx %d [%v]: %w", i, tx.Hash().Hex(), err)
109115
}
110116

111117
statedb.SetTxContext(tx.Hash(), i)
112118

113-
receipt, err := ApplyTransactionWithEVM(msg, gp, statedb, blockNumber, blockHash, tx, usedGas, evm, interruptCtx)
119+
receipt, err := ApplyTransactionWithEVM(msg, gp, statedb, blockNumber, blockHash, tx, usedGas, evm, nil)
114120
if err != nil {
115121
return nil, fmt.Errorf("could not apply tx %d [%v]: %w", i, tx.Hash().Hex(), err)
116122
}
@@ -154,7 +160,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
154160
// ApplyTransactionWithEVM attempts to apply a transaction to the given state database
155161
// and uses the input parameters for its environment similar to ApplyTransaction. However,
156162
// this method takes an already created EVM instance as input.
157-
func ApplyTransactionWithEVM(msg *Message, gp *GasPool, statedb *state.StateDB, blockNumber *big.Int, blockHash common.Hash, tx *types.Transaction, usedGas *uint64, evm *vm.EVM, interruptCtx context.Context) (receipt *types.Receipt, err error) {
163+
func ApplyTransactionWithEVM(msg *Message, gp *GasPool, statedb *state.StateDB, blockNumber *big.Int, blockHash common.Hash, tx *types.Transaction, usedGas *uint64, evm *vm.EVM, interrupt *atomic.Bool) (receipt *types.Receipt, err error) {
158164
if hooks := evm.Config.Tracer; hooks != nil {
159165
if hooks.OnTxStart != nil {
160166
hooks.OnTxStart(evm.GetVMContext(), tx, msg.From)
@@ -180,7 +186,7 @@ func ApplyTransactionWithEVM(msg *Message, gp *GasPool, statedb *state.StateDB,
180186
// resume recording read and write
181187
statedb.SetMVHashmap(backupMVHashMap)
182188

183-
result, err = ApplyMessageNoFeeBurnOrTip(evm, *msg, gp, interruptCtx)
189+
result, err = ApplyMessageNoFeeBurnOrTip(evm, *msg, gp, interrupt)
184190
if err != nil {
185191
return nil, err
186192
}
@@ -272,13 +278,13 @@ func MakeReceipt(evm *vm.EVM, result *ExecutionResult, statedb *state.StateDB, b
272278
// and uses the input parameters for its environment. It returns the receipt
273279
// for the transaction, gas used and an error if the transaction failed,
274280
// indicating the block was invalid.
275-
func ApplyTransaction(evm *vm.EVM, gp *GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *uint64, interruptCtx context.Context) (*types.Receipt, error) {
281+
func ApplyTransaction(evm *vm.EVM, gp *GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *uint64, interrupt *atomic.Bool) (*types.Receipt, error) {
276282
msg, err := TransactionToMessage(tx, types.MakeSigner(evm.ChainConfig(), header.Number, header.Time), header.BaseFee)
277283
if err != nil {
278284
return nil, err
279285
}
280286
// Create a new context to be used in the EVM environment
281-
return ApplyTransactionWithEVM(msg, gp, statedb, header.Number, header.Hash(), tx, usedGas, evm, interruptCtx)
287+
return ApplyTransactionWithEVM(msg, gp, statedb, header.Number, header.Hash(), tx, usedGas, evm, interrupt)
282288
}
283289

284290
// ProcessBeaconBlockRoot applies the EIP-4788 system call to the beacon block root

core/state_transition.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ package core
1818

1919
import (
2020
"bytes"
21-
"context"
2221
"fmt"
2322
"math"
2423
"math/big"
24+
"sync/atomic"
2525

2626
"github.com/ethereum/go-ethereum/common"
2727
cmath "github.com/ethereum/go-ethereum/common/math"
@@ -220,16 +220,16 @@ func TransactionToMessage(tx *types.Transaction, s types.Signer, baseFee *big.In
220220
// the gas used (which includes gas refunds) and an error if it failed. An error always
221221
// indicates a core error meaning that the message would always fail for that particular
222222
// state and would never be accepted within a block.
223-
func ApplyMessage(evm *vm.EVM, msg *Message, gp *GasPool, interruptCtx context.Context) (*ExecutionResult, error) {
223+
func ApplyMessage(evm *vm.EVM, msg *Message, gp *GasPool, interrupt *atomic.Bool) (*ExecutionResult, error) {
224224
evm.SetTxContext(NewEVMTxContext(msg))
225-
return newStateTransition(evm, msg, gp).execute(interruptCtx)
225+
return newStateTransition(evm, msg, gp).execute(interrupt)
226226
}
227227

228-
func ApplyMessageNoFeeBurnOrTip(evm *vm.EVM, msg Message, gp *GasPool, interruptCtx context.Context) (*ExecutionResult, error) {
228+
func ApplyMessageNoFeeBurnOrTip(evm *vm.EVM, msg Message, gp *GasPool, interrupt *atomic.Bool) (*ExecutionResult, error) {
229229
st := newStateTransition(evm, &msg, gp)
230230
st.noFeeBurnAndTip = true
231231

232-
return st.execute(interruptCtx)
232+
return st.execute(interrupt)
233233
}
234234

235235
// stateTransition represents a state transition.
@@ -438,7 +438,7 @@ func (st *stateTransition) preCheck() error {
438438
//
439439
// However if any consensus issue encountered, return the error directly with
440440
// nil evm execution result.
441-
func (st *stateTransition) execute(interruptCtx context.Context) (*ExecutionResult, error) {
441+
func (st *stateTransition) execute(interrupt *atomic.Bool) (*ExecutionResult, error) {
442442
input1 := st.state.GetBalance(st.msg.From)
443443

444444
var input2 *uint256.Int
@@ -548,7 +548,7 @@ func (st *stateTransition) execute(interruptCtx context.Context) (*ExecutionResu
548548
}
549549

550550
// Execute the transaction's call.
551-
ret, st.gasRemaining, vmerr = st.evm.Call(msg.From, st.to(), msg.Data, st.gasRemaining, value, interruptCtx)
551+
ret, st.gasRemaining, vmerr = st.evm.Call(msg.From, st.to(), msg.Data, st.gasRemaining, value, interrupt)
552552
}
553553

554554
// Record the gas used excluding gas refunds. This value represents the actual

core/types/transaction_signing.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -600,32 +600,32 @@ func deriveChainId(v *big.Int) *big.Int {
600600
}
601601

602602
// FakeSigner implements the Signer interface and accepts unprotected transactions
603-
type FakeSigner struct{ londonSigner }
603+
type FakeSigner struct{ pragueSigner }
604604

605605
var _ Signer = FakeSigner{}
606606

607607
func NewFakeSigner(chainId *big.Int) Signer {
608-
signer := NewLondonSigner(chainId)
609-
ls, _ := signer.(londonSigner)
610-
return FakeSigner{londonSigner: ls}
608+
signer := NewPragueSigner(chainId)
609+
ps, _ := signer.(pragueSigner)
610+
return FakeSigner{pragueSigner: ps}
611611
}
612612

613613
func (f FakeSigner) Sender(tx *Transaction) (common.Address, error) {
614-
return f.londonSigner.Sender(tx)
614+
return f.pragueSigner.Sender(tx)
615615
}
616616

617617
func (f FakeSigner) SignatureValues(tx *Transaction, sig []byte) (r, s, v *big.Int, err error) {
618-
return f.londonSigner.SignatureValues(tx, sig)
618+
return f.pragueSigner.SignatureValues(tx, sig)
619619
}
620620

621621
func (f FakeSigner) ChainID() *big.Int {
622-
return f.londonSigner.ChainID()
622+
return f.pragueSigner.ChainID()
623623
}
624624

625625
// Hash returns 'signature hash', i.e. the transaction hash that is signed by the
626626
// private key. This hash does not uniquely identify the transaction.
627627
func (f FakeSigner) Hash(tx *Transaction) common.Hash {
628-
return f.londonSigner.Hash(tx)
628+
return f.pragueSigner.Hash(tx)
629629
}
630630

631631
// Equal returns true if the given signer is the same as the receiver.

0 commit comments

Comments
 (0)