-
Notifications
You must be signed in to change notification settings - Fork 173
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
consensus, contract, scraper, protocol, project, beacon, rpc: Replace remaining appcache sections with native structures #2639
consensus, contract, scraper, protocol, project, beacon, rpc: Replace remaining appcache sections with native structures #2639
Conversation
0d643a3
to
f2eff10
Compare
Next up is making the changes to the ApplyContracts code to wire this in and also the cross-connect in the scraper. Done. |
9d724e6
to
e17d794
Compare
610d049
to
0059617
Compare
20d4f8b
to
e8d5309
Compare
98537dd
to
4f2a922
Compare
This allows direct traversal of contract types in a range for loop, and also provides the string representation of the contract type from the input ContractType enum without having to instantiate a contract object.
With the retirement of the legacy appcache these rpc functions are useless.
…ry key member name Also adjust scraper entry and protocol entry classes.
This commit refactors the template Initialize, using two helper methods, HandleCurrentHistoricalEntries and HandlePreviousHistoricalEntries. The HandleCurrentHistoricalEntries is specialized for the beacon db.
This commit implements the initial version of the beaconaudit rpc. This initial version is limited to detecting inconsistencies between the contract traversal in normal order and the beacon historical entries where there are multiple renewals for the same CPID in the same block.
8f914d9
to
249e269
Compare
@div72 I am finishing up the testing on this. This thing is too large I think for a traditional review, but please do look over it so that I get a second eye on it. I am doing both pre-fork and post fork (on an isolated fork) testing to ensure it works correctly. |
Ok. I have completed testing the pre block v13 fork operation of this PR and it passes. Pre-fork testing involves exercising the scraper, project, and protocol areas, including reorganizing to blocks before the transactions to ensure reversion and roll-forwards work correctly. |
@div72 and I have agreed given the testing that has already done on the pre-fork functionality, and the size of this PR, it would be best to go ahead and merge into the development branch for testing on testnet, and then do any adjustments in another PR. |
Added - contrib: add nix file for compilation environment gridcoin-community#2660 (@div72) - gui: Make main Gridcoin window geometry save unique to datadir location gridcoin-community#2661 (@jamescowens) - build: Initial CMake support gridcoin-community#2676 (@CyberTailor) - util: Add `-shutdownnotify` and `startupnotify` options from upstream gridcoin-community#2688 (@barton2526) - gui, staking: Implement facilities for mandatory sidestakes and sidestake GUI gridcoin-community#2704 (@jamescowens) - gui, voting: Implement poll result caching and poll stale indicator gridcoin-community#2709 (@jamescowens) - gui, projects: Implement greylist state for projects in GUI projects table gridcoin-community#2715 (@jamescowens) - gui, poll: Implement poll expiration reminders gridcoin-community#2716 (@jamescowens) - serialize: allow variants to be serialized gridcoin-community#2729 (@div72) - gui: Implement poll field length limiters in GUI forms gridcoin-community#2742 (@jamescowens) Changed - consensus, contract, scraper, protocol, project, beacon, rpc: Replace remaining appcache sections with native structures gridcoin-community#2639 (@jamescowens) - build: update libsecp256k1 to v0.3.0 gridcoin-community#2655 (@div72) - build: Replace $(AT) with .SILENT gridcoin-community#2674 (@barton2526) - build: allow system bdb gridcoin-community#2675 (@div72) - Resize Header Column with Additional Text gridcoin-community#2683 (@PrestackI) - rpc: use RPCErrorCode everywhere gridcoin-community#2687 (@Pythonix) - wallet: SecureString to allow null characters gridcoin-community#2690 (@barton2526) - random: port some upstream changes gridcoin-community#2696 (@div72) - depends: Bump dependencies gridcoin-community#2692 (@barton2526) - doc: Update link to Discord server gridcoin-community#2693 (@adriaanjoubert) - rpc: Change capitalization, remove whitespace of rpc keys gridcoin-community#2711 (@Pythonix) - ci: bump MacOS version to 12 gridcoin-community#2713 (@div72) - depends: no-longer nuke libc++abi.so* in native_clang package gridcoin-community#2719 (@div72) - doc: update windows `-fstack-clash-protection` doc gridcoin-community#2720 (@div72) - Silence `-Wcast-function-type` warning gridcoin-community#2721 (@div72) - build: Use newest `config.{guess,sub}` available gridcoin-community#2722 (@div72) - refactor: use the try_lock result in TryEnter gridcoin-community#2723 (@div72) - Updates for file src/qt/locale/bitcoin_en.ts in pt_PT gridcoin-community#2726 (@gridcoin-community) - ci: do not silently fail gridcoin-community#2727 (@div72) - Properly include Boost Array header gridcoin-community#2730 (@theMarix) - build: Update depends zlib to 1.3.1 gridcoin-community#2734 (@jamescowens) - util: Enhance Fraction class overflow resistance gridcoin-community#2735 (@jamescowens) - refactor: Fix compilation warnings gridcoin-community#2737 (@jamescowens) - gui, util: Improve upgrade dialog gridcoin-community#2738 (@jamescowens) - util: Improve allocation class gridcoin-community#2740 (@jamescowens) - translations: translation updates for Miss Piggy release gridcoin-community#2745 (@jamescowens) Removed - gui: Disable snapshot GUI action gridcoin-community#2700 (@jamescowens) - build, crypto, script: remove most of OpenSSL usage gridcoin-community#2705 (@div72) - util: remove WSL 1 workaround in fs gridcoin-community#2717 (@div72) Fixed - diagnostics: fix missing arg in ETTS warning gridcoin-community#2684 (@div72) - misc: fix include guard in netaddress.h gridcoin-community#2695 (@div72) - gui: Fix expired pending beacon display gridcoin-community#2698 (@jamescowens) - consensus: Fix 20230904 testnet forking issue gridcoin-community#2703 (@jamescowens) - gui: Fix filter by type in Transaction View gridcoin-community#2708 (@jamescowens) - depends: make fontconfig build under clang-16 gridcoin-community#2718 (@div72) - diag: fix researcher mode check gridcoin-community#2725 (@div72) - gui: Add missing switch cases for ALREADY_IN_MEMPOOL gridcoin-community#2728 (@jamescowens) - beacon, registry: Fix beacon history stall gridcoin-community#2731 (@jamescowens) - build: Implement comp_double comparison function in certain tests gridcoin-community#2741 (@jamescowens) - ci: change Qt path in CMake CI gridcoin-community#2743 (@div72) - net: Correct -tor argument handling gridcoin-community#2744 (@jamescowens)
This is a PR to retire the remaining legacy appcache used for scraper entries and protocol entries and replace with native structures using linked lists by key and hash with full revert capability, leveldb storage, and passivation (removal from memory) of inactive objects (the RegistryDB class template). It also retrofits the Projects class (whitelist) with the registry db. This is patterned after the work I did on beacons post Fern. The original beacon registry db implementation has been refactored to use the RegistryDB template as well with some specializations due to specific complexities with beacons.
Note that this PR itself does NOT require a mandatory, because it has been designed to be backwards compatible with legacy payloads (used by the legacy appcache class). When the V13 block version/contract version 3 is set to mark the changeover to native structures for the scraper and protocol entries, this will require a mandatory.
Essentially the design idea here is for the scraper registry to store native scraper entries, keyed by the CKeyID (essentially address) of the scraper entry. Each change in state of a scraper entry by CKeyID is recorded as a new record and the prior record(s) are maintained by the historical map and the scraper db in leveldb. This includes entries where the records are marked "deleted". In this case, a record will be injected with a status of "DELETED". This approach is necessary to maintain compatibility with the scraper code, which needs to know when a record was deleted for purposes of security. The tx hash of the prior entry will be stored in the current record, to be able to walk backwards in history for any CKeyID analogous to what is done with beacons. This allows us to revert a contract add/delete by simply removing the current entry and resurrecting the previous historical record (if there is one). Storage of the current and historical records in leveldb by a common key prefix for each registry area allows extremely fast restore when starting up the wallet by replaying from the leveldb area, rather than doing a general contract replay. The true reversion capability on a blockchain reorg allows us to dispense with the large contract replays to restore proper contract state after finishing reorganizations.
The protocol registry has been implemented similar to the scraper registry, but follows a straight key-value pair paradigm. Eventually we may want to put more structure to this and constrain what type of protocol entries we will allow, but that is unnecessary right now.
The project registry (Whitelist class) has received a backing db to remove the requirement for 180 day renewals and provide for proper reversion during reorgs. So scraper, protocol, and projects, just like beacons, will not require periodic refreshes of
their entries after this PR is merged AND the next mandatory height is reached which requires everyone to have a version of the wallet that has this PR in it. Until then, the <180 day refresh of scraper, protocol and project entries will be required to ensure those nodes not running code with this PR do not "forget" the entries.
To support multiple registries essentially using identical code, I implemented a registry db template in src/gridcoin/contract/registry_db.h which is instantiated in each registry class with the appropriate registry specific types. All four registries that have db backing use this template: beacon, scraper, protocol, and project. The first class, beacon, which was actually the original implementation of the db, has been converted over to use the new template, with some specialization to deal with beacon specifics.
The only contract type that will require significant contract replay (other than the top up check based on the db heights) during wallet initialization is the poll/vote types. No replay after a reorganization is required for these as reversion works properly for unique entries like polls/votes, but the required replay at wallet start means the poll history window is limited to 180 days currently unless we choose to lengthen the window. Given the current performance challenges with polls and voting in the GUI for people with slow disks, I do not think that is advisable right now. I am considering ways to use the backing db to eliminate this contract replay and also the 180 day window as well, but that will be in a separate PR.