[Okay, finished.]
I think the database is completely workable.
However, some concepts need to be introduced.
There are two databases that are used.
1) Blockchain: Source of all data that bitcoin uses + data on input age which is necessary to calculate demurrage fees on dead coins
2) Database of Blockchain Meta Info: Source of data for 1) lottery 2) demurrage fees reductions 3) recording of signatures
I'm not sure where to begin, so I'm just going to go through an algorithm for maintaining the database, running the lottery, and enforcing fees.
Here are the database fields that are going to be populated:
"Public Key (sorted by alphabet)" | "Linked Stake Public Key" | "Balance" | "Cumulative Balance" | "Coin-Age" | "Forgiven Coin-Age" |
Here is the data which is taken directly form the block chain:
"Total Input Value" | "Average Input Age" | "Total Mint" |
Part I Sending
1) For each txn in block t, check if the public key that signed the txn is listed in the database.
a) If yes,
i) Txn fee on send: Txn Fee >= max(Balance,total input value)*(exp(max(Coin-Age, Average Input Age)*annual demurrage rate)-1) - Balance*(exp(Forgiven Coin-Age*annual demurrage fee)-1) [Otherwise the txn is invalid.]
ii) If the txn is sent from a limited stake signing key, check: Change Returned to Root Public Key >= all coins sent to other addresses * {max(k,k*(t/coin-years on public key)} where k=9 and t=1/12. [Otherwise the txn is invalid]
iii) Set Balance_t= Balance_(t-1)-total value of inputs. [This could be less than 0. That is fine]
iv) Set Coin-age=1 and Forgiven Coin-age=0.
v) If Balance_t<1 , then delete the public key from the database together with all its associated data.
b) If no, then
i) Txn fee on send: Txn Fee >= (total input value)*(exp(average input age in years*annual demurrage rate)-1) [Otherwise the txn is invalid.]
ii) The database remains unchanged.
Part II Receiving
1) For each txn in block t, check if the receiving public key is listed in the database.
2) If yes,
a) add to the balance on the receiving address as follows: balance_t=balance_(t-1)+received coins
b) update the coin-age on the receiving address as follows: Coin_age_t = [Coin_age_(t-1)*balance_(t-1)+received coins]/balance(t)
3) If no,
a) Check if the address has received more than one coin, if so add the receiving public key to the database.
Step 1: Set the public key balance = the number of received coins. (this may be less than the true value of inputs controlled by the key)
Step 2: Set the coin-age on the public key balance = 1. (this may be less than the true age of the inputs controlled by the key)
Step 3: Leave the Linked Stake Public Key field blank.
Step 4: Set Active=1.
Part III General Changes.
1) If an address has not received coins, its Coin-Age(t)=Coin-Age(t-1)+1
Part IV Assigning Linked Stake Public Keys: Special txns record linkages between public keys and limited stake public keys.
1) Check if the public key is listed in the database. [If not, the txn is invalid.]
2) If yes,
a) check if the public key is already associated with a linked stake public key. [If yes, the txn is invalid.]
b) if the public key has not been assigned a linked stake public key, then record the linked stake public key in the database.
Part V. Txn Fee Fund
1) If the block is PoW
a) Txn Fee Fund(t)=0.9999*(Txn Fee Fund(t-1)+(1/2-Voluntary Sigs in Block/10)*Txn Fees (t))
b) Generation to PoW miner = 0.0001*(Txn Fee Fund(t-1)+(1/2+Voluntary Sigs in Block/10)*Txn Fees (t))
2) If the block is PoS
a) Txn Fee Fund(t)=0.995*((Txn Fee Fund(t-1)+(1/2-Voluntary Sigs in Block/10)*Txn Fees (t))
b) Generation to each PoS signatory and PoS block miner = 0.001*((Txn Fee Fund(t-1)+(1/2+Voluntary Sigs in Block/10)*Txn Fees (t))
[Note there are a total of 5 Signatories including PoS block miner. There is an incentive to include Voluntary Sigs in Blocks]
Part VI. Mandatory and Voluntary Signatures. [For PoS Blocks only]
1) If the key has provided a mandatory signature or voluntarily signed the previous PoS Block.
a) then forgiven coin-age (t)= coin-age(t-1). [Note that coin-age is not reset by the signature. Forgiven Coin-Age is just increased.]
2) Voluntary Signatures
a)Voluntary signatures are just special txns that are included in blocks.
b)For any voluntary Signature check if
i) Has the voluntary signature been requested since time t-6 [If a block includes an unrequested signature it is invalid.]
ii) Has the voluntary signature been provided in a block since time t-6 [If a block includes a duplicate signature, then it is invalid]
c) A maximum of 5 voluntary signatures can be included in 1 block. [If not, the block is invalid.]
3) If a key's voluntary signature is requested at time t-6 but this signature is not in any block up to time t
a) The entry for this key should be deleted from the database.
Part VII. Cumulative Balance
1) After Balance is updated, the lottery probabilities will change. Cumulative Balance needs to be repopulated to account for changes in balance. Call the sum total cumulative for the last database entry "Total Balance"
Part VIII. Lottery Draw
1) Check if PoW submission meets the difficulty target [If not draw is invalid]
2) Hash PoW submission 10 times
3) Map each hash to a draw from the uniform distribution on the interval [0, Total Mint]
4) Check if all of the hashes map to the interval [0, Total Balance] (Note that Total Balance <= Total Mint)
4a) If yes, identify the public key associated with each draw in the database. The first five draws indicate mandatory signatures. The next five draws indicate voluntary
signatures.
4b) If no, the PoW submission is invalid.
Part IX Mining Process
1) PoW miner broadcasts message0={work submission; Hash(Previous PoS Block), ,Hash (This PoW block) }
2) Message is transmitted. Receivers verify
a) work submission meets target.
b) Hash (Previous PoS Block) refers to the most recent PoS Block they have heard of.
c) work submission Lottery Draw maps to 10 addresses in the database.
d) They have not previously heard this message. [Note that it is fine if multiple PoW Blocks circulate simultaneously]
e) They have not heard an updated version of this message that includes one or more signatures.
f) If (a)-(e) are true, receivers relay the message.
3) Key holder provides his mandatory signature and transmits the new message. message1={work submission; Hash(Previous PoS Block),Hash (This PoW block); Sig 1(message 0) }
4) Receivers verify
a) work submission meets target.
b) Hash (Previous PoS Block) refers to the most recent PoS Block they have heard of.
c) work submission Lottery Draw maps to 10 addresses in the database.
d) They have not previously heard this message. [Note that it is fine if multiple PoW Blocks circulate simultaneously]
e) They have not heard an updated version of this message that includes more signatures.
f) The mandatory signatures are the correct ones as indicated by a hash of the work submission.
g) If (a)-(f) are true, receivers relay the message.
5) Go to 3 and repeat until all 5 signatures have been added {work submission; Hash(Previous PoS Block),Hash (This PoW block); Sig 1(message 0); Sig 2(message 1); Sig 3(message 2); Sig 4(message 3) ; Sig 5(message 4)}
6) PoW miner receives all 5 signatures and broadcasts block together with signatures.
7) 5th Signatory hears of broadcast PoW block. He then broadcasts his own block and signs Hash (PoS block, PoW block). The PoS block contains payments for all the mandatory PoS signatories.
Part X) Block Validation.
i) All txns in block are valid. (e.g. standard blockchain checks + additional checks as described above)
ii) Each blocks must build on the previous one. (can be done in the standard way whatever that is)
iii) The PoW submissions maps to to 10 signatures in the database. [The database needs to be constructed as the blockchain is validated.]
iv) The PoW block contains the correct Txn fee payments to the generation address.
v) The PoS block contains the correct Txn fee payments to the five mandatory signatories.
vi) The block is not over the block size limit.
Not sure what else I am missing. I am sure there is plenty.