Comments (8)
Let's make sure we can mine in parallel with everything else.
from aeternity.
I am extracting code from the the main miner in the Cuckoo Cycle code of John Tomp (https://github.com/tromp/cuckoo) and build an Erlang interface using NIFs.
from aeternity.
Cuckoo Cycle takes a string (which can be the hash of the block) and a nonce and creates a pair of siphash keys. These, together with the nonce, are used to create paths. The algorithm looks for 42-long cycles in these paths.
An attempt with a specific nonce value takes roughly 6 seconds on my laptop and it succeeds with a 2.2% chance. It results in an array of 42 integers representing the cycle found. Tromp suggested adding a difficulty by calculating the SHA265 hash of the solution and discarding the solution unless the hash is below the difficulty, just like with SHA256 PoW. (N. B. the success rate can be tuned by changing the node/edge ratio (1/2 in the suggested implementation) but this is nonlinear).
There are two methods verifying a solution:
- We can redo the calculation from the block hash and nonce. This takes about 6 seconds as it includes re-generating the original solution.
- Using the actual solution (array of 42 numbers) we can verify the solution by simple checking if it forms a cycle, this takes only 50-100 microseconds on my laptop. Though this is much faster, it requires storing the solution for aiding later verification.
from aeternity.
Do you mean storing the solution in the block header, together with the hash and nonce? @sennui
from aeternity.
I think, that storing the solution was one of the ideas behind democratizing miners and giving a slack to cheap mobile phones. (Jumping 42 pointers is way cheaper even than computing sha256)
@wagerlabs Yes, I would add it to the block and respectively include it in a header.
It would be an equivalent of current solution for, say, bitcoin: hash is a solution and its public.
If we want to make it fixed 42 numbers, we can drive the difficulty in a way mentioned by @akorosmezey (or we can assume from the very beginning that the length of the array can grow, which is fine too)
from aeternity.
from aeternity.
@sennui raised the question where the output of printf calls in the NIF goes. Unfortunately it goes to the console. I can remove most of them (the ones from my code) but there are still others from the original code. In order to remove them I need to fork the repo or just include the sources.
(A simple solution would be to redirect stdout to /dev/null for the duration of the call but this may affect other processes running parallel and in case of a crash we do not have the chance of undo the redirection.)
from aeternity.
PR #84 created that adds a call with default values to the API. @wagerlabs supported this idea.
from aeternity.
Related Issues (20)
- aeapi handling for Rosetta should handle custom forks
- Make equivalent of debug tx in mempool for external api HOT 6
- Provide extra info along "Invalid tx" error HOT 1
- Dry-run endpoint fails with 500 code if provided a signed tx HOT 1
- Update deprecated CircleCI images
- Can't build node by reference to git repo in docker-compose.yml
- Missed docs for `*-bundle` images HOT 1
- Histogram metrics are not exported as histogram StatsD type
- Allow a fraction `dev_mode.microblock_interval` HOT 2
- Reject spend tx immediately if the recipient contract is not payable HOT 5
- Change debug tx in mempool endpoint to use dry run
- Don't encode binary pointer key as string in name details HOT 6
- Breaking change in protocol files configuration HOT 1
- Devmode not producing microblocks unless `emit_mb` explicitly triggered HOT 3
- Allow of range of ports to be specified for use by SC FSMs HOT 2
- Inconsistent naming in api: `transactions/pending` vs `mempool` HOT 1
- Consider adding dry-run via GET HOT 7
- Reject claiming of revoked name immediately HOT 3
- Typo in `fiat_converstion_url` parameter HOT 1
- BRI can be overridden by config for mainnet and testnet
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aeternity.