Skip to content

Commit

Permalink
handle error from semaphore.Aquire (#12417)
Browse files Browse the repository at this point in the history
```
panic: semaphore: released more than held

goroutine 10342 [running]:
golang.org/x/sync/semaphore.(*Weighted).Release(0xc002e8cdc0, 0x1114288c0?)
	golang.org/x/sync@v0.8.0/semaphore/semaphore.go:127 +0xb8
github.com/erigontech/erigon/turbo/execution/eth1.(*EthereumExecutionModule).Start(0xc003766780, {0x10fef16f8, 0xc001901d60})
	github.com/erigontech/erigon/turbo/execution/eth1/ethereum_execution.go:349 +0x167
created by github.com/erigontech/erigon/eth.(*Ethereum).Start in goroutine 1
	github.com/erigontech/erigon/eth/backend.go:1516 +0xddf
exit status 2
```
  • Loading branch information
AskAlexSharov authored Oct 23, 2024
1 parent cc28d26 commit 3137718
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions turbo/execution/eth1/ethereum_execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (e *EthereumExecutionModule) getHeader(ctx context.Context, tx kv.Tx, block
return e.blockReader.Header(ctx, tx, blockHash, blockNumber)
}

func (e *EthereumExecutionModule) getTD(ctx context.Context, tx kv.Tx, blockHash libcommon.Hash, blockNumber uint64) (*big.Int, error) {
func (e *EthereumExecutionModule) getTD(_ context.Context, tx kv.Tx, blockHash libcommon.Hash, blockNumber uint64) (*big.Int, error) {
return rawdb.ReadTd(tx, blockHash, blockNumber)

}
Expand Down Expand Up @@ -338,7 +338,12 @@ func (e *EthereumExecutionModule) purgeBadChain(ctx context.Context, tx kv.RwTx,
}

func (e *EthereumExecutionModule) Start(ctx context.Context) {
e.semaphore.Acquire(ctx, 1)
if err := e.semaphore.Acquire(ctx, 1); err != nil {
if !errors.Is(err, context.Canceled) {
e.logger.Error("Could not start execution service", "err", err)
}
return
}
defer e.semaphore.Release(1)

if err := stages.ProcessFrozenBlocks(ctx, e.db, e.blockReader, e.executionPipeline, nil); err != nil {
Expand Down
6 changes: 3 additions & 3 deletions turbo/execution/eth1/inserters.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ import (
"github.com/erigontech/erigon/turbo/execution/eth1/eth1_utils"
)

func (s *EthereumExecutionModule) validatePayloadBlobs(expectedBlobHashes []libcommon.Hash, transactions []types.Transaction, blobGasUsed uint64) error {
func (e *EthereumExecutionModule) validatePayloadBlobs(expectedBlobHashes []libcommon.Hash, transactions []types.Transaction, blobGasUsed uint64) error {
if expectedBlobHashes == nil {
return &rpc.InvalidParamsError{Message: "nil blob hashes array"}
}
actualBlobHashes := []libcommon.Hash{}
for _, txn := range transactions {
actualBlobHashes = append(actualBlobHashes, txn.GetBlobHashes()...)
}
if len(actualBlobHashes) > int(s.config.GetMaxBlobsPerBlock()) || blobGasUsed > s.config.GetMaxBlobGasPerBlock() {
if len(actualBlobHashes) > int(e.config.GetMaxBlobsPerBlock()) || blobGasUsed > e.config.GetMaxBlobGasPerBlock() {
return nil
}
if !reflect.DeepEqual(actualBlobHashes, expectedBlobHashes) {
s.logger.Warn("[NewPayload] mismatch in blob hashes",
e.logger.Warn("[NewPayload] mismatch in blob hashes",
"expectedBlobHashes", expectedBlobHashes, "actualBlobHashes", actualBlobHashes)
return nil
}
Expand Down

0 comments on commit 3137718

Please sign in to comment.