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

Many miner and oracle improvements #985

Merged
merged 22 commits into from
Oct 12, 2021
Merged

Conversation

area
Copy link
Member

@area area commented Sep 3, 2021

There's a lot of medium sized things in this PR, but they're all around the reputation miner/oracle.

More performant version of SQLite

Migrated to Better SQLite which does a much better job of showing off why it's good on the linked GitHub page than I do.

More performant use of SQLite

We now use only one connection to the database which is left open, rather than opening and closing the file for every request, and also use prepared queries for improved performance. By not repeatedly opening and closing the file we remove the possibility of collisions, which we were starting to see as more people use the app.

Cache relevant responses

Requested reputation proofs corresponding to a particular user / reputation / state combination are now cached for an hour. This duration was chosen to match the mining cycle length - the majority of requests are for a particular reputation in the current state, which only lasts for an hour, and so caching for longer seems only very occasionally relevant (e.g. caching a reputation proof involved in a vote would be useful).

New oracle endpoints

I've added an oracle endpoint to return all reputations that a user has in a colony. It's at :reputationRootHash/:colonyAddress/all/:userAddress, intended to align with the endpoint used for a reputation proof for a specific reputation. It is required to implement this GUI element in a sensible way (i.e. without querying the oracle for every reputation a user could possibly have):

FireShot_Capture_431_-Colony_Simplified_Figma-_www figma com

There is also now an endpoint for a single user's reputation in a state that ends with /noProof, which in the case where only the value is not required, should be much faster (as the entire reputation state doesn't have to be loaded).

Improve oracle and miner reliability with unreliable endpoints

The ability to use multiple endpoints through Ether's Fallback Provider. We're using a wrapped version of it, that in the event of a failed request will retry it up to ten times (the default of the exponential-backoff npm package.

This version of the miner is current running on QA. There may be further tweaks/improvements/adjustments as I see it fail in new and more interesting ways, but there's enough here to start getting feedback on. By creating a branch/PR it also means the frontend team can use it, and continue development using the new oracle endpoint.

packages/reputation-miner/ReputationMiner.js Outdated Show resolved Hide resolved
packages/reputation-miner/ReputationMiner.js Show resolved Hide resolved
packages/reputation-miner/ReputationMiner.js Show resolved Hide resolved
packages/reputation-miner/ReputationMiner.js Show resolved Hide resolved
packages/reputation-miner/ReputationMinerClient.js Outdated Show resolved Hide resolved
packages/reputation-miner/bin/index.js Outdated Show resolved Hide resolved
test/reputation-system/client-calculations.js Show resolved Hide resolved
packages/reputation-miner/bin/index.js Outdated Show resolved Hide resolved
packages/reputation-miner/bin/index.js Outdated Show resolved Hide resolved
@kronosapiens
Copy link
Member

Take this off draft whenever you're ready and I'll give it another read-through.

@area area marked this pull request as ready for review September 16, 2021 09:13
@area area force-pushed the maint/real-world-oracle branch 2 times, most recently from c69565b to 7657238 Compare September 24, 2021 13:40
@kronosapiens kronosapiens changed the title Many miner and oracle improvments Many miner and oracle improvements Sep 27, 2021
kronosapiens
kronosapiens previously approved these changes Oct 1, 2021
packages/reputation-miner/ReputationMiner.js Outdated Show resolved Hide resolved
kronosapiens
kronosapiens previously approved these changes Oct 1, 2021
kronosapiens
kronosapiens previously approved these changes Oct 3, 2021
kronosapiens
kronosapiens previously approved these changes Oct 3, 2021
kronosapiens
kronosapiens previously approved these changes Oct 10, 2021
packages/reputation-miner/ReputationMiner.js Show resolved Hide resolved
@@ -74,7 +74,6 @@ process.env.SOLIDITY_COVERAGE
});

beforeEach(async () => {
await goodClient.resetDB();
await goodClient.initialise(colonyNetwork.address);

Copy link
Member

Choose a reason for hiding this comment

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

No resetDB here?

Copy link
Member

Choose a reason for hiding this comment

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

@kronosapiens kronosapiens merged commit 05ffecb into develop Oct 12, 2021
@kronosapiens kronosapiens deleted the maint/real-world-oracle branch October 12, 2021 09:31
@area area restored the maint/real-world-oracle branch December 11, 2021 15:38
@kronosapiens kronosapiens deleted the maint/real-world-oracle branch February 2, 2023 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants