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 Etchash cache at Mordor #499

Conversation

meowsbits
Copy link
Member

@meowsbits meowsbits commented Aug 30, 2022

Fixes #439 and #493.

Please read commit messages for more context, but here's an overview:

  • the bug was because of a bad future item in the in-memory lru cache
    • the post-ECIP1099 epochs caught up to pre-ECIP1099 epoch numbers and caused a bad cache hit
  • cache files were named with seed hashes, which are hard to identify when epochs are not continuous
    • so I introduce a new filename scheme which includes epoch values and allows a scanner to identify and remove them as needed (avoiding a potential other bad-cache-hit scenario when seed hashes collide between pre- and post-ECIP1099 epochs)

This PR (and branch) uses #496 as a base.

Here's Mordor passing 4_980_000 without issue:

INFO [08-30|09:17:28.928|core/headerchain.go:407]              Imported new block headers               count=256  elapsed=6.923ms     number=4,963,200 hash=581a33..ec7fda age=10mo1w3d                 
INFO [08-30|09:17:29.053|core/headerchain.go:407]              Imported new block headers               count=576  elapsed=124.596ms   number=4,963,776 hash=3aebf0..8eae21 age=10mo1w3d                 
INFO [08-30|09:17:29.246|core/blockchain.go:1214]              Imported new block receipts              count=190  elapsed=294.043ms   number=4,954,942 hash=489fd5..847757 age=10mo1w5d   size=63.34KiB 
INFO [08-30|09:17:29.534|core/blockchain.go:1214]              Imported new block receipts              count=2048 elapsed=281.566ms   number=4,956,990 hash=5d3baa..490a1f age=10mo1w4d   size=681.45KiB
INFO [08-30|09:17:29.826|core/blockchain.go:1214]              Imported new block receipts              count=2048 elapsed=286.437ms   number=4,959,038 hash=ff6d35..acb684 age=10mo1w4d   size=679.64KiB           
INFO [08-30|09:17:30.092|core/blockchain.go:1214]              Imported new block receipts              count=2048 elapsed=260.763ms   number=4,961,086 hash=9580f2..c100ae age=10mo1w4d   size=680.47KiB
INFO [08-30|09:17:30.364|core/blockchain.go:1214]              Imported new block receipts              count=2048 elapsed=265.470ms   number=4,963,134 hash=5bc83c..76c6e2 age=10mo1w3d   size=680.05KiB
INFO [08-30|09:17:30.614|core/blockchain.go:1214]              Imported new block receipts              count=642  elapsed=248.286ms   number=4,963,776 hash=3aebf0..8eae21 age=10mo1w3d   size=213.64KiB
INFO [08-30|09:17:30.872|core/headerchain.go:407]              Imported new block headers               count=576  elapsed=10.723ms    number=4,964,352 hash=e9a550..3151f5 age=10mo1w3d                 
INFO [08-30|09:17:31.144|core/blockchain.go:1214]              Imported new block receipts              count=61   elapsed=269.739ms   number=4,963,837 hash=96fa97..dbc97d age=10mo1w3d   size=20.24KiB
INFO [08-30|09:17:31.409|core/blockchain.go:1214]              Imported new block receipts              count=515  elapsed=263.677ms   number=4,964,352 hash=e9a550..3151f5 age=10mo1w3d   size=170.94KiB
INFO [08-30|09:17:31.495|core/headerchain.go:407]              Imported new block headers               count=192  elapsed=5.957ms     number=4,964,544 hash=1f3ff3..982112 age=10mo1w3d                 
INFO [08-30|09:17:31.756|core/blockchain.go:1214]              Imported new block receipts              count=192  elapsed=260.431ms   number=4,964,544 hash=1f3ff3..982112 age=10mo1w3d   size=63.62KiB 
INFO [08-30|09:17:34.519|core/headerchain.go:407]              Imported new block headers               count=2048 elapsed=79.619ms    number=4,966,592 hash=0d0324..14930c age=10mo1w3d                 
INFO [08-30|09:17:34.595|core/headerchain.go:407]              Imported new block headers               count=2048 elapsed=75.533ms    number=4,968,640 hash=cd1be2..1c9e07 age=10mo1w3d                 
INFO [08-30|09:17:34.670|core/headerchain.go:407]              Imported new block headers               count=2048 elapsed=73.257ms    number=4,970,688 hash=448753..9a8e81 age=10mo1w2d                 
INFO [08-30|09:17:34.756|core/headerchain.go:407]              Imported new block headers               count=2048 elapsed=86.058ms    number=4,972,736 hash=55a87e..45b1f4 age=10mo1w2d 
INFO [08-30|09:17:34.837|core/headerchain.go:407]              Imported new block headers               count=2048 elapsed=79.494ms    number=4,974,784 hash=9ffeef..a981dc age=10mo1w2d                 
INFO [08-30|09:17:34.900|core/headerchain.go:407]              Imported new block headers               count=2048 elapsed=62.553ms    number=4,976,832 hash=d38358..70604e age=10mo1w1d                 
INFO [08-30|09:17:34.955|core/headerchain.go:407]              Imported new block headers               count=2048 elapsed=54.026ms    number=4,978,880 hash=f4bac1..2c628f age=10mo1w1d                 
INFO [08-30|09:17:35.000|core/headerchain.go:407]              Imported new block headers               count=448  elapsed=44.670ms    number=4,979,328 hash=181f9d..e06a3c age=10mo1w1d                 
TRACE[08-30|09:17:35.009|consensus/ethash/ethash.go:217]       Evicted ethash cache                     epoch=81-60000                                                                                   
TRACE[08-30|09:17:35.009|consensus/ethash/ethash.go:257]       Requiring new future ethash cache        epoch=84                                                                         
DEBUG[08-30|09:17:35.010|consensus/ethash/ethash.go:368]       Failed to load old ethash cache          epoch=84       epochLength=60000 err="open /home/ia/.myethash-cache/cache-R23-84-a8784097a4d03c2d: no such file or directory"
INFO [08-30|09:17:35.042|core/headerchain.go:407]              Imported new block headers               count=768  elapsed=40.908ms    number=4,980,096 hash=07fb15..40f606 age=10mo1w1d                 
INFO [08-30|09:17:35.318|core/blockchain.go:1214]              Imported new block receipts              count=133  elapsed=264.958ms   number=4,964,677 hash=b17bcb..4807de age=10mo1w3d   size=44.12KiB 
INFO [08-30|09:17:35.593|core/blockchain.go:1214]              Imported new block receipts              count=2048 elapsed=269.068ms   number=4,966,725 hash=a3fdb5..6c8663 age=10mo1w3d   size=681.19KiB
INFO [08-30|09:17:35.877|core/blockchain.go:1214]              Imported new block receipts              count=2048 elapsed=276.736ms   number=4,968,773 hash=877640..3f5902 age=10mo1w3d   size=680.50KiB
DEBUG[08-30|09:17:35.929|consensus/ethash/algorithm.go:176]    Generated ethash verification cache      epoch=84       epochLength=60000 elapsed=915.834ms                                               
DEBUG[08-30|09:17:35.931|consensus/ethash/ethash.go:402]       Deleted ethash cache file                epoch=84       epochLength=60000 target.epoch=81 file=/home/ia/.myethash-cache/cache-R23-81-a92afa474bb50595
INFO [08-30|09:17:36.217|core/blockchain.go:1214]              Imported new block receipts              count=2048 elapsed=332.756ms   number=4,970,821 hash=62f824..981d8d age=10mo1w2d   size=683.95KiB
INFO [08-30|09:17:36.551|core/blockchain.go:1214]              Imported new block receipts              count=2048 elapsed=327.462ms   number=4,972,869 hash=98b78b..9cb63a age=10mo1w2d   size=680.60KiB
INFO [08-30|09:17:36.843|core/blockchain.go:1214]              Imported new block receipts              count=2048 elapsed=285.500ms   number=4,974,917 hash=b8060c..aae609 age=10mo1w2d   size=681.48KiB
INFO [08-30|09:17:37.198|core/blockchain.go:1214]              Imported new block receipts              count=2048 elapsed=347.532ms   number=4,976,965 hash=9bf489..ccf302 age=10mo1w1d   size=682.86KiB
INFO [08-30|09:17:37.502|core/headerchain.go:407]              Imported new block headers               count=2048 elapsed=190.267ms   number=4,982,144 hash=4a3de1..24b18d age=10mo1w1d
INFO [08-30|09:17:37.547|core/blockchain.go:1214]              Imported new block receipts              count=2048 elapsed=339.889ms   number=4,979,013 hash=61dbe4..b02121 age=10mo1w1d   size=680.57KiB
INFO [08-30|09:17:37.705|core/headerchain.go:407]              Imported new block headers               count=2048 elapsed=202.039ms   number=4,984,192 hash=66175c..b94432 age=10mo1w18h
INFO [08-30|09:17:37.907|core/headerchain.go:407]              Imported new block headers               count=2048 elapsed=201.292ms   number=4,986,240 hash=0132ca..c574f0 age=10mo1w11h
INFO [08-30|09:17:37.915|core/blockchain.go:1214]              Imported new block receipts              count=1083 elapsed=364.230ms   number=4,980,096 hash=07fb15..40f606 age=10mo1w1d   size=359.65KiB
INFO [08-30|09:17:38.225|core/headerchain.go:407]              Imported new block headers               count=2048 elapsed=317.752ms   number=4,988,288 hash=c34faa..ccab35 age=10mo1w4h
INFO [08-30|09:17:38.246|core/blockchain.go:1214]              Imported new block receipts              count=2048 elapsed=322.386ms   number=4,982,144 hash=4a3de1..24b18d age=10mo1w1d   size=676.31KiB
INFO [08-30|09:17:38.312|core/headerchain.go:407]              Imported new block headers               count=640  elapsed=86.325ms    number=4,988,928 hash=391503..500c35 age=10mo1w2h
INFO [08-30|09:17:38.521|core/blockchain.go:1214]              Imported new block receipts              count=2048 elapsed=265.879ms   number=4,984,192 hash=66175c..b94432 age=10mo1w18h  size=675.95KiB
INFO [08-30|09:17:38.896|core/blockchain.go:1214]              Imported new block receipts              count=2048 elapsed=366.782ms   number=4,986,240 hash=0132ca..c574f0 age=10mo1w11h  size=675.63KiB
INFO [08-30|09:17:39.201|core/blockchain.go:1214]              Imported new block receipts              count=2048 elapsed=298.374ms   number=4,988,288 hash=c34faa..ccab35 age=10mo1w4h   size=679.56KiB
INFO [08-30|09:17:39.504|core/headerchain.go:407]              Imported new block headers               count=2048 elapsed=133.771ms   number=4,990,976 hash=b371fd..c30a7d age=10mo6d18h
INFO [08-30|09:17:39.517|core/blockchain.go:1214]              Imported new block receipts              count=640  elapsed=313.894ms   number=4,988,928 hash=391503..500c35 age=10mo1w2h   size=211.31KiB
INFO [08-30|09:17:39.572|core/headerchain.go:407]              Imported new block headers               count=2048 elapsed=67.025ms    number=4,993,024 hash=61c843..9c49c7 age=10mo6d11h

Here's --vmodule=consensus/*=6 logs during the same time context:

> tail -F geth.out |grep --line-buffered -E 'consensus' 
[...]
TRACE[08-30|09:16:52.950|consensus/ethash/ethash.go:257]       Requiring new future ethash cache        epoch=81                                                                                                                                                                                                                                 [0/15]
DEBUG[08-30|09:16:52.950|consensus/ethash/ethash.go:368]       Failed to load old ethash cache          epoch=81       epochLength=60000 err="open /home/ia/.myethash-cache/cache-R23-81-a92afa474bb50595: no such file or directory"
DEBUG[08-30|09:16:53.870|consensus/ethash/algorithm.go:176]    Generated ethash verification cache      epoch=81       epochLength=60000 elapsed=918.574ms
DEBUG[08-30|09:16:53.872|consensus/ethash/ethash.go:402]       Deleted ethash cache file                epoch=81       epochLength=60000 target.epoch=78 file=/home/ia/.myethash-cache/cache-R23-78-7b1e42ac7d205c8d
TRACE[08-30|09:17:04.349|consensus/ethash/ethash.go:217]       Evicted ethash cache                     epoch=79-60000
TRACE[08-30|09:17:04.350|consensus/ethash/ethash.go:257]       Requiring new future ethash cache        epoch=82
DEBUG[08-30|09:17:04.351|consensus/ethash/ethash.go:368]       Failed to load old ethash cache          epoch=82       epochLength=60000 err="open /home/ia/.myethash-cache/cache-R23-82-d5d85ca518675140: no such file or directory"
DEBUG[08-30|09:17:05.271|consensus/ethash/algorithm.go:176]    Generated ethash verification cache      epoch=82       epochLength=60000 elapsed=918.033ms
DEBUG[08-30|09:17:05.272|consensus/ethash/ethash.go:402]       Deleted ethash cache file                epoch=82       epochLength=60000 target.epoch=79 file=/home/ia/.myethash-cache/cache-R23-79-9d2e3fc27256471a
TRACE[08-30|09:17:17.520|consensus/ethash/ethash.go:217]       Evicted ethash cache                     epoch=80-60000
TRACE[08-30|09:17:17.520|consensus/ethash/ethash.go:257]       Requiring new future ethash cache        epoch=83
DEBUG[08-30|09:17:17.525|consensus/ethash/ethash.go:368]       Failed to load old ethash cache          epoch=83       epochLength=60000 err="open /home/ia/.myethash-cache/cache-R23-83-3aa8f28cac16bdd8: no such file or directory"
DEBUG[08-30|09:17:18.443|consensus/ethash/algorithm.go:176]    Generated ethash verification cache      epoch=83       epochLength=60000 elapsed=916.915ms
DEBUG[08-30|09:17:18.444|consensus/ethash/ethash.go:402]       Deleted ethash cache file                epoch=83       epochLength=60000 target.epoch=80 file=/home/ia/.myethash-cache/cache-R23-80-10fc9a2e5b65ea3f
TRACE[08-30|09:17:35.009|consensus/ethash/ethash.go:217]       Evicted ethash cache                     epoch=81-60000
TRACE[08-30|09:17:35.009|consensus/ethash/ethash.go:257]       Requiring new future ethash cache        epoch=84
DEBUG[08-30|09:17:35.010|consensus/ethash/ethash.go:368]       Failed to load old ethash cache          epoch=84       epochLength=60000 err="open /home/ia/.myethash-cache/cache-R23-84-a8784097a4d03c2d: no such file or directory"
DEBUG[08-30|09:17:35.929|consensus/ethash/algorithm.go:176]    Generated ethash verification cache      epoch=84       epochLength=60000 elapsed=915.834ms
DEBUG[08-30|09:17:35.931|consensus/ethash/ethash.go:402]       Deleted ethash cache file                epoch=84       epochLength=60000 target.epoch=81 file=/home/ia/.myethash-cache/cache-R23-81-a92afa474bb50595
TRACE[08-30|09:17:51.206|consensus/ethash/ethash.go:217]       Evicted ethash cache                     epoch=82-60000
TRACE[08-30|09:17:51.206|consensus/ethash/ethash.go:257]       Requiring new future ethash cache        epoch=85
DEBUG[08-30|09:17:51.206|consensus/ethash/ethash.go:368]       Failed to load old ethash cache          epoch=85       epochLength=60000 err="open /home/ia/.myethash-cache/cache-R23-85-4e99a30e99712c8c: no such file or directory"
DEBUG[08-30|09:17:52.130|consensus/ethash/algorithm.go:176]    Generated ethash verification cache      epoch=85       epochLength=60000 elapsed=922.632ms
DEBUG[08-30|09:17:52.131|consensus/ethash/ethash.go:402]       Deleted ethash cache file                epoch=85       epochLength=60000 target.epoch=82 file=/home/ia/.myethash-cache/cache-R23-82-d5d85ca518675140

This test reproduces an error encountered on
the Mordor testnet and reported here
#439

Ethash returns a cache value with epoch
length of 30k, where it should return one
appropriate for the ECIP1099-era with
an epoch length of 60k.

This caused header verification to fail
because the mix digest was incorrect.

This issue only occurred while syncing the Mordor
network because the cache was in-memory and
because the original-era epoch was matched
later by the ECIP1099-era epoch and the LRU
future item was anachronistic.

Date: 2022-08-30 08:35:32-07:00
Signed-off-by: meows <b5c6@protonmail.com>
The ECIP1099 transition causes the epoch numbers to halve,
causing the lru.future value to be ahead of (greater than)
the current epoch, making this conditional (quietly) fail.

After a while (eg. syncing on Mordor), the lru.future
value becomes spuriously available again because
the epoch heights eventually match up again,
but when they do, the lru.future value references
the pre-ECIP1099 era.

Date: 2022-08-30 08:41:28-07:00
Signed-off-by: meows <b5c6@protonmail.com>
This handles potential cache collisions due to ECIP1099.
epoch/epochLength is sufficiently unique, where epoch
alone could be duplicated by post-ECIP1099 epochs.

Date: 2022-08-30 08:44:22-07:00
Signed-off-by: meows <b5c6@protonmail.com>
Prior to this patch, the code assumed that ECIP1099 would
(must) be activated on an epoch transition block value,
ie. a multiple of 30_000.
This patch removes this assumption.

Date: 2022-08-30 08:46:28-07:00
Signed-off-by: meows <b5c6@protonmail.com>
Prior to this patch, existing cache files
could only be identified unidirectionally,
by matching a seedhash generated for some epoch.

This is problematic for ECIP1099 because epoch
numbers are no longer continuous, so there were
dangling cache files (since the iterator removing
them had to use the contemporary cache epoch, which
may have recently been halved).

This patch allows cache files to be iterated
and identified by the epoch they represent using
scanned values from their filename.

This avoids spurious cache file hits using only
seed hash alone that could have been caused
by dangling cache files.

Legacy cache files (by matching legacy naming scheme)
will be removed.

Date: 2022-08-30 08:53:57-07:00
Signed-off-by: meows <b5c6@protonmail.com>
This function generates the dataset,
not the cache.

Date: 2022-08-30 08:55:11-07:00
Signed-off-by: meows <b5c6@protonmail.com>
Date: 2022-08-30 09:02:40-07:00
Signed-off-by: meows <b5c6@protonmail.com>
Date: 2022-08-30 09:03:00-07:00
Signed-off-by: meows <b5c6@protonmail.com>
consensus/ethash/ethash.go Outdated Show resolved Hide resolved
This gets called by runtime.SetFinalizer
within the cache.generate method.

Date: 2022-08-31 06:59:59-07:00
Signed-off-by: meows <b5c6@protonmail.com>
With a generous activation (>=), 1099 can be activated
but until the next epoch rolls around it won't actually
be activated, eg. ecip1099Block=3_000_042 wont activate
until 3_030_000... which is unpredictable.

Better to conform to and enforce stricter expectations.

Date: 2022-08-31 07:06:27-07:00
Signed-off-by: meows <b5c6@protonmail.com>
https://github.com/ethereumclassic/ECIPs/blob/master/_specs/ecip-1099.md#specification
tells us that seed hashes wont overlap.

This tests shows that indeed, for the range tested,
they don't collide.

Date: 2022-08-31 07:26:14-07:00
Signed-off-by: meows <b5c6@protonmail.com>
@ziogaschr
Copy link
Member

Fresh syncing with Mordor finished just fine. Once you make the small changes in comments, I will approve this PR.
Nice work man, once more.

…sted

Date: 2022-08-31 08:52:28-07:00
Signed-off-by: meows <b5c6@protonmail.com>
@meowsbits
Copy link
Member Author

meowsbits commented Aug 31, 2022

Review comments are addressed and resolved (links to associated commits in review comments).
I added a few more tests in latest commits as well.

…rates as expected

Date: 2022-08-31 08:53:17-07:00
Signed-off-by: meows <b5c6@protonmail.com>
@meowsbits meowsbits force-pushed the merge/foundation-release/1.10.21-tests-generate-etchash-mordor-pr-2 branch from 0cb5927 to 836792f Compare August 31, 2022 15:58
meowsbits added a commit to etclabscore/go-etchash that referenced this pull request Aug 31, 2022
This fix echoes the fix originally made
here etclabscore/core-geth#499

Date: 2022-08-31 09:46:26-07:00
Signed-off-by: meows <b5c6@protonmail.com>
@meowsbits
Copy link
Member Author

meowsbits commented Sep 1, 2022

@ziogaschr PTAL 69f5300

This proposes keeping the file naming scheme identical between the cache and full dataset.
The logic for both automatically removes "legacy" files, meaning that this upgrade will cause all DAG files to be regenerated, using the new naming pattern.

  • Does the new naming pattern LGTY?
  • Should this be considered an API-breaking change?
  • Should we add logic to move existing files to the new name scheme? (Instead of plainly recreating new and rming old.)

…s too

Date: 2022-08-31 19:55:29-07:00
Signed-off-by: meows <b5c6@protonmail.com>
@meowsbits meowsbits force-pushed the merge/foundation-release/1.10.21-tests-generate-etchash-mordor-pr-2 branch from 69f5300 to 310ca59 Compare September 1, 2022 13:18
@ziogaschr
Copy link
Member

During the ECIP-1099 transition we handled the renaming of existing DAGs, from what I recall it has been done for smoother transition times, so as not all miners had to wait for DAG generation for the next block.
At this time, I consider it's not needed to handle this case, as probably each miner will upgrade the node at different time.

API-breaking change: I don't think it is, my only worry is, if any GPU mining software, is using/sharing the same DAG files. I don't think so.

Once the above checked, I vote on just removing all old files and recreating from scratch.

@meowsbits
Copy link
Member Author

meowsbits commented Sep 5, 2022

Yea, the GPU miners I've used seem to generate their own DAGs (which makes sense because a user could configure --ethash.dagdir to be somewhere unexpected and I've never seen a GPU miner with a flag for it).

I too am OK with regenerating and rming the old DAGs. Let's do it. KISS.

@ziogaschr ziogaschr self-requested a review September 5, 2022 16:16
Base automatically changed from merge/foundation-release/1.10.21-tests-generate to master September 5, 2022 17:31
@meowsbits meowsbits merged commit 0b2ba69 into master Sep 5, 2022
@meowsbits meowsbits deleted the merge/foundation-release/1.10.21-tests-generate-etchash-mordor-pr-2 branch September 5, 2022 17:31
@blackmennewstyle
Copy link

blackmennewstyle commented Apr 18, 2023

During the ECIP-1099 transition we handled the renaming of existing DAGs, from what I recall it has been done for smoother transition times, so as not all miners had to wait for DAG generation for the next block. At this time, I consider it's not needed to handle this case, as probably each miner will upgrade the node at different time.

API-breaking change: I don't think it is, my only worry is, if any GPU mining software, is using/sharing the same DAG files. I don't think so.

Once the above checked, I vote on just removing all old files and recreating from scratch.

Well that decision actually kinda breaks the implementation of ETC inside miningcore (stratum mining pool software) since it allows to share that .etchash folder and the C++ ethash library uses the old naming format. It was handy to be able to use the DAG files directly generated by core-geth but now unfortunately that feature will no longer work unless we go back to core-geth 1.12.8 lol

@ziogaschr
Copy link
Member

@blackmennewstyle good to know that you use DAG files this way, we couldn't find any use-cases like this one.
I wonder if it's easy for you to handle the new pattern in your code?

We will also discuss with @meowsbits, what would mean for us to provide the old naming.
Will keep you posted.

@ziogaschr
Copy link
Member

@blackmennewstyle can you please create a new issue and add a link to this one?

@blackmennewstyle
Copy link

@ziogaschr The naming we use is exactly the one which has been deleted in this commit: https://github.com/etclabscore/core-geth/pull/499/files#diff-81dd4f9d1a46a485d74affabbf00bcc61fd98a44bcf785a57d59d87ce50ddb93L432

@ziogaschr
Copy link
Member

@blackmennewstyle yes I understood this. Was just checking with you if you could have a different pattern (our new one) in your code under certain circumstances.

@blackmennewstyle
Copy link

blackmennewstyle commented Apr 18, 2023

@ziogaschr I believe we can since the C++ etchash library which is used inside miningcore was based on this one: https://github.com/etclabscore/cpp-etchash

We probably need to find out the functions which are used to handle and generate the DAG file and adjust the naming scheme to the new one. While still allowing the deleted naming scheme since previous core-geth releases are based on it lol

@meowsbits
Copy link
Member Author

meowsbits commented Apr 18, 2023

Hey @blackmennewstyle. Thanks for your report, I'm getting caught up here.

breaks the implementation of ETC inside miningcore (stratum mining pool software) since it allows to share that .etchash folder and the C++ ethash library uses the old naming format.

I don't see any reference to geth's DAG cache files in there yet. And the actual source used by miningcore is closed, or?

actually kinda breaks the implementation of ETC inside miningcore

Can you provide logs or some more further detail on what "kinda breaks" looks like?
Are we expecting (or hoping) to resolve this by basically adding a \-%d to some regex at miningcore or cpp-etchash?

PS. Bummer that the change broke the dep, but IMO a cache file footprint should not be considered a stable API surface for mining pools...

@blackmennewstyle
Copy link

blackmennewstyle commented Apr 19, 2023

Hey @blackmennewstyle. Thanks for your report, I'm getting caught up here.

breaks the implementation of ETC inside miningcore (stratum mining pool software) since it allows to share that .etchash folder and the C++ ethash library uses the old naming format.

I don't see any reference to geth's DAG cache files in there yet. And the actual source used by miningcore is closed, or?

* https://github.com/search?q=repo%3Aetclabscore%2Fcpp-etchash+etchash&type=code

* https://github.com/search?q=repo%3Aetclabscore%2Fcpp-etchash+ethash&type=code

actually kinda breaks the implementation of ETC inside miningcore

Can you provide logs or some more further detail on what "kinda breaks" looks like? Are we expecting (or hoping) to resolve this by basically adding a \-%d to some regex at miningcore or cpp-etchash?

PS. Bummer that the change broke the dep, but IMO a cache file footprint should not be considered a stable API surface for mining pools...

miningcore is totally open-source. The reason, you don't see the code on the main branch is because now it's only available on the dev branch - https://github.com/oliverw/miningcore/tree/dev/src/Native/libetchash - Also, there is currently a discussion and evolution about using the full DAG or light DAG - oliverw/miningcore#1608 - Long story short some people hate using the FULL DAG because the generation takes too long, one trickery was to take advantage of core-geth since it was generating them just like the C++ etchash library expects them. But not everyone can enjoy that scenario since server configurations come in many flavors, some people don't run their stratum mining pool and core-geth on the same machine. So they were using the light DAG implementation. But reports suggest light DAG increases pool latency in some scenarios.

The break is not critical since miningcore will generate the DAG file with the legacy naming if it does not find them, however your code seems to delete these legacy files if they are present inside the .etchash folder - https://github.com/etclabscore/core-geth/pull/499/files#diff-81dd4f9d1a46a485d74affabbf00bcc61fd98a44bcf785a57d59d87ce50ddb93R512

@meowsbits
Copy link
Member Author

So maybe miningcore can just use its own data dir? To my knowledge, neither core-geth nor go-ethereum expose that path or its data as a stable API.

@blackmennewstyle
Copy link

So maybe miningcore can just use its own data dir? To my knowledge, neither core-geth nor go-ethereum expose that path or its data as a stable API.

No worry,miningcore offers the possibility to set manually the path where the DAG file should be generated.

I actually found the mechanism in our etchash implementation - Default directory: https://github.com/oliverw/miningcore/blob/dev/src/Native/libetchash/io_posix.c#L91 an the legacy naming: https://github.com/oliverw/miningcore/blob/dev/src/Native/libetchash/io.h#L207

It does not seem to be an easy modification to support your new naming, it will require lot of code changes through multiple functions.

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.

mordor fails to sync with invalid mix digest at block 4_980_000
3 participants