Say I want to create a contract that rewards miners with an ERC20 token for discovering solutions to a certain mathematical problem where the following points apply:
- The problem is well defined and with some moderate effort, one could write some solidity code that can verify solutions to the problem
- There are many valid solutions to the problem
- The solutions are valuable to mathematicians interested in the problem
- Some solutions are bigger in terms of data size than others
- Some solutions are more interesting than others but all solutions should be kept around for research purposes
As a more concrete example, say I wanted to re-implement prime coin using a Ethereum token (I'll call it PrimeToken). (I am not interested in doing this specifically, but it serves as a good enough example):
uint256 public lastNumber = 1;
function proofOfWork(uint256 number){
if (number <= lastNumber) throw; //Always have to find a new prime number bigger than the last
if (!isPrime(number)) throw; // Verify solution is valid
//If it is valid, reward the miner and set the last solution as the submitted one
lastNumber = number;
balanceOf[msg.sender] += number - lastNumber;
}
As bigger and bigger prime numbers are discovered, the uint256 would overflow and I would have to change this to a bytes array to handle very large numbers, and implement some way of handling the byte array like a bigint. Assume I did this from the start and were competent with doing so.
My question is, how does this scale? What happens as the submitted byte array gets larger?
- Will the miners submitting prime number solutions have to pay more and more ether (in gas fees) to get their PrimeTokens as the IsPrime() function takes more processing power to verify for larger numbers?
- Is there a similar fee for the size of the data submitted?
- Is there a limit to the size of the data submitted?
- Will the blockchain become bloated with the large data storage requirements for the large numbers?
- How do mathematicians interested in prime numbers find the previously submitted solutions? Can they just use a block explorer?
- Are there any ways I could mitigate these scalability problems?