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 externalcl integration for erigon3 #12906

Merged
merged 1 commit into from
Nov 29, 2024
Merged

Fix externalcl integration for erigon3 #12906

merged 1 commit into from
Nov 29, 2024

Conversation

AlexeyAkhunov
Copy link
Contributor

Fixes #12225

@@ -37,7 +37,7 @@ func NewTemporaryMdbx(ctx context.Context, tempdir string) (kv.RwDB, error) {
return &TemporaryMdbx{}, err
}

db, err := New(kv.ChainDB, log.Root()).InMem(path).Open(ctx)
db, err := New(kv.ChainDB, log.Root()).InMem(path).GrowthStep(64 * datasize.MB).Open(ctx)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sometimes we get MDBX_MAP_FULL error if there are lots of blocks to hold temporarily, this is to fix it

@@ -58,37 +56,7 @@ func (bd *BodyDownload) UpdateFromDb(db kv.Tx) (headHeight, headTime uint64, hea
clear(bd.requests)
clear(bd.peerMap)
bd.ClearBodyCache()
headHeight = bodyProgress
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following code was removed since it computes values that are never used. Also this code was actually producing error messages canonical marker not found specified in the issue

@@ -79,9 +80,17 @@ func (e *EngineBlockDownloader) download(ctx context.Context, hashToDownload lib
memoryMutation := membatchwithdb.NewMemoryBatchWithCustomDB(tx, tmpDb, tmpTx)
defer memoryMutation.Rollback()

if block != nil {
err = rawdb.WriteCanonicalHash(memoryMutation, block.Hash(), block.NumberU64())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

downloading of headers backwards starts with the parent of the block, so the block itself did not get its canonical hash written down. This addition fixes it

@@ -235,7 +234,7 @@ func saveHeader(db kv.RwTx, header *types.Header, hash libcommon.Hash) error {
return fmt.Errorf("[saveHeader] failed to WriteTd: %w", err)
}
if err = rawdb.WriteCanonicalHash(db, hash, blockHeight); err != nil {
return fmt.Errorf("[saveHeader] failed to canonical hash: %w", err)
return fmt.Errorf("[saveHeader] failed to save canonical hash: %w", err)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo fix

startBlock, endBlock, startHash, err := e.loadDownloadedHeaders(memoryMutation)
if err != nil {
e.logger.Warn("[EngineBlockDownloader] Could load headers", "err", err)
e.logger.Warn("[EngineBlockDownloader] Could not load headers", "err", err)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo fix

@Giulio2002 Giulio2002 merged commit 2f32cd2 into main Nov 29, 2024
14 of 15 checks passed
@Giulio2002 Giulio2002 deleted the external_cl_fix branch November 29, 2024 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't sync from scratch with --externalcl
2 participants