Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix claim pre execution #1786

Merged
merged 4 commits into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aggregator/mocks/mock_dbtx.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion aggregator/mocks/mock_etherman.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion aggregator/mocks/mock_ethtxmanager.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion aggregator/mocks/mock_profitabilitychecker.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion aggregator/mocks/mock_prover.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion aggregator/mocks/mock_state.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion etherman/mock_etherscan.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion etherman/mock_ethgasstation.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ethtxmanager/mock_etherman_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ethtxmanager/mock_state_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gasprice/mock_etherman.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gasprice/mock_pool.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion jsonrpc/mock_dbtx_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion jsonrpc/mock_pool_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion jsonrpc/mock_state_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion jsonrpc/mock_storage_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 9 additions & 26 deletions pool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"math/big"
"time"

"github.com/0xPolygonHermez/zkevm-node/log"
"github.com/0xPolygonHermez/zkevm-node/state"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math"
Expand Down Expand Up @@ -68,28 +67,11 @@ func (p *Pool) AddTx(ctx context.Context, tx types.Transaction) error {
return err
}

poolTx := Transaction{
Transaction: tx,
Status: TxStatusPending,
IsClaims: false,
ReceivedAt: time.Now(),
IsWIP: false,
}

poolTx.IsClaims = poolTx.IsClaimTx(p.l2BridgeAddr, p.cfg.FreeClaimGasLimit)

// Execute transaction to calculate its zkCounters
zkCounters, err := p.PreExecuteTx(ctx, tx)
if err != nil {
return err
}

poolTx.ZKCounters = zkCounters
return p.storage.AddTx(ctx, poolTx)
return p.StoreTx(ctx, tx)
}

// ReorgTx adds a reorged transaction to the pool with the pending state
func (p *Pool) ReorgTx(ctx context.Context, tx types.Transaction) error {
// StoreTx adds a transaction to the pool with the pending state
func (p *Pool) StoreTx(ctx context.Context, tx types.Transaction) error {
poolTx := Transaction{
Transaction: tx,
Status: TxStatusPending,
Expand All @@ -100,13 +82,14 @@ func (p *Pool) ReorgTx(ctx context.Context, tx types.Transaction) error {

poolTx.IsClaims = poolTx.IsClaimTx(p.l2BridgeAddr, p.cfg.FreeClaimGasLimit)

// Execute transaction to calculate its zkCounters
zkCounters, err := p.PreExecuteTx(ctx, tx)
if err != nil {
log.Warnf("ignoring error while preexecuting tx: %+v", poolTx)
if !poolTx.IsClaims {
// Execute transaction to calculate its zkCounters
zkCounters, err := p.PreExecuteTx(ctx, tx)
if err != nil {
poolTx.ZKCounters = zkCounters
}
}

poolTx.ZKCounters = zkCounters
return p.storage.AddTx(ctx, poolTx)
}

Expand Down
2 changes: 1 addition & 1 deletion sequencer/broadcast/mocks/mock_state.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sequencer/mock_db_manager.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sequencer/mock_dbtx.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sequencer/mock_pool.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sequencer/mock_state.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sequencer/mock_worker.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions state/runtime/executor/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,11 @@ func IsExecutorOutOfCountersError(error pb.ExecutorError) bool {
return int32(error) >= EXECUTOR_ERROR_COUNTERS_OVERFLOW_KECCAK && int32(error) <= ROM_ERROR_OUT_OF_COUNTERS_POSEIDON
}

// IsExecutorUnespecifiedError indicates an unespecified error in the executor
func IsExecutorUnespecifiedError(error pb.ExecutorError) bool {
return int32(error) == EXECUTOR_ERROR_UNSPECIFIED
}

// IsIntrinsicError indicates if the error is due to a intrinsic check
func IsIntrinsicError(error pb.RomError) bool {
return int32(error) >= ROM_ERROR_INTRINSIC_INVALID_SIGNATURE && int32(error) <= ROM_ERROR_INTRINSIC_TX_GAS_OVERFLOW
Expand Down
2 changes: 1 addition & 1 deletion synchronizer/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ type ethTxManager interface {

type poolInterface interface {
DeleteReorgedTransactions(ctx context.Context, txs []*types.Transaction) error
ReorgTx(ctx context.Context, tx types.Transaction) error
StoreTx(ctx context.Context, tx types.Transaction) error
}
2 changes: 1 addition & 1 deletion synchronizer/mock_dbtx.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion synchronizer/mock_etherman.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion synchronizer/mock_ethtxmanager.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions synchronizer/mock_pool.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion synchronizer/mock_state.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion synchronizer/synchronizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ func (s *ClientSynchronizer) reorgPool(dbTx pgx.Tx) error {

// Add txs to the pool
for _, tx := range txs {
err = s.pool.ReorgTx(s.ctx, *tx)
err = s.pool.StoreTx(s.ctx, *tx)
if err != nil {
log.Errorf("error storing tx into the pool again. TxHash: %s. BatchNumber: %d, error: %v", tx.Hash().String(), batchNumber, err)
return err
Expand Down
2 changes: 1 addition & 1 deletion synchronizer/synchronizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func TestTrustedStateReorg(t *testing.T) {
Once()

m.Pool.
On("ReorgTx", ctx, *txs[0]).
On("StoreTx", ctx, *txs[0]).
Return(nil).
Once()

Expand Down