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

block may be rollback and the number of transactions reduced #72

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Changes from all commits
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
15 changes: 10 additions & 5 deletions cmd/rpcdaemon/commands/eth_innertx.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/ledgerwatch/erigon/turbo/rpchelper"
"github.com/ledgerwatch/erigon/zk/hermez_db"
zktypes "github.com/ledgerwatch/erigon/zk/types"
"github.com/ledgerwatch/log/v3"
)

// GetInternalTransactions ...
Expand Down Expand Up @@ -50,8 +51,10 @@ func (api *APIImpl) GetInternalTransactions(ctx context.Context, txnHash libcomm

hermezReader := hermez_db.NewHermezDbReader(tx)
blockInnerTxs := hermezReader.GetInnerTxs(blockNum)
if len(blockInnerTxs) != len(block.Transactions()) {
return nil, fmt.Errorf("block inner tx count %d not equal to block tx count %d", len(blockInnerTxs), len(block.Transactions()))
if len(blockInnerTxs) < len(block.Transactions()) {
return nil, fmt.Errorf("block inner tx count %d is less than block tx count %d", len(blockInnerTxs), len(block.Transactions()))
} else if len(blockInnerTxs) > len(block.Transactions()) {
log.Warn(fmt.Sprintf("block inner tx count %d is greater than block tx count %d", len(blockInnerTxs), len(block.Transactions())))
}

return blockInnerTxs[txnIndex], nil
Expand Down Expand Up @@ -100,12 +103,14 @@ func (api *APIImpl) GetBlockInternalTransactions(ctx context.Context, number rpc

hermezReader := hermez_db.NewHermezDbReader(tx)
blockInnerTxs := hermezReader.GetInnerTxs(n)
if len(blockInnerTxs) != len(block.Transactions()) {
return nil, fmt.Errorf("block inner tx count %d not equal to block tx count %d", len(blockInnerTxs), len(block.Transactions()))
if len(blockInnerTxs) < len(block.Transactions()) {
return nil, fmt.Errorf("block inner tx count %d is less than block tx count %d", len(blockInnerTxs), len(block.Transactions()))
} else if len(blockInnerTxs) > len(block.Transactions()) {
log.Warn(fmt.Sprintf("block inner tx count %d is greater than block tx count %d", len(blockInnerTxs), len(block.Transactions())))
}

res := make(map[libcommon.Hash][]*zktypes.InnerTx)
for index, innerTxs := range blockInnerTxs {
for index, innerTxs := range blockInnerTxs[:len(block.Transactions())] {
res[block.Transactions()[index].Hash()] = innerTxs
}

Expand Down
Loading