-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
RRR4R: rational -> decimal #1819
Changes from 33 commits
abf9a65
84c7fab
c9ed668
e4e78b4
206ed8b
6cbe1ee
ee627ed
2f130bb
a2ced74
1aa00b7
9ffbf40
f8be905
a598efb
697bb2e
20486a9
173acc9
44f24ac
34a9978
6b2dab7
ee0e179
546a4ca
5015fd4
d2bf108
3f4bb2e
12e4022
d605058
0a247fd
40d49bf
73c5d9c
89dd6e4
5d939f8
e5f2faf
09e7e25
196fcce
f43bf90
16bc41e
9c954ce
9859476
348cb1d
e26a87d
1e57807
609e07d
81e96e8
fd52603
b7aaac5
e9900a3
18b4826
b77fc51
24ce274
b600f71
d81775b
af48ed2
db72022
fa57c38
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -821,7 +821,7 @@ in the case of a successful double-spend attack. | |
|
||
Building on an approach pioneered by Ripple, Stellar [\[13\]][13] refined a | ||
model of Federated Byzantine Agreement wherein the processes participating in | ||
consensus do not constitute a fixed and globally known set. Rather, each | ||
consensus do not constitute a fixed and globally known set. Decher, each | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sed gone wrong lol There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. reverted all instances (and all cases) |
||
process node curates one or more "quorum slices", each constituting a set of | ||
trusted processes. A "quorum" in Stellar is defined to be a set of nodes that | ||
contain at least one quorum slice for each node in the set, such that agreement | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -312,7 +312,7 @@ accounts. | |
We use this `Keeper` paradigm extensively in the SDK as the way to define what | ||
kind of functionality each module gets access to. In particular, we try to | ||
follow the *principle of least authority*. | ||
Rather than providing full blown access to the `KVStore` or the `AccountMapper`, | ||
Decher than providing full blown access to the `KVStore` or the `AccountMapper`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sed caught something it shouldn't have XD There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. addessed all |
||
we restrict access to a small number of functions that do very specific things. | ||
|
||
## App3 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,11 +31,11 @@ See [binary format as protobuf specification](./protobuf/queue.proto) | |
A Merkle tree (or a trie) generates a single hash that can be used to prove any element of the tree. In order to generate this hash, we first hash the leaf nodes, then hash multiple leaf nodes together to get the hash of an inner node (two or more, based on degree k of the k-ary tree), and repeat for each level of the tree until we end up with one root hash. | ||
With a known root hash (which is included in the block headers), the existence of a particular key/value in the tree can be proven by tracing the path to the value and revealing the (k-1) hashes for the paths not taken on each level ([[10](./references.md#10)]). | ||
|
||
There are a number of different implementations of this basic idea, using different hash functions, as well as prefixes to prevent second preimage attacks (differentiating leaf nodes from inner nodes). Rather than force all chains that wish to participate in IBC to use the same data store, we provide a data structure that can represent Merkle proofs from a variety of data stores, and provide for chaining proofs to allow for subtrees. While searching for a solution, we did find the chainpoint proof format[[11](./references.md#11)], which inspired this design significantly, but didn't (yet) offer the flexibility we needed. | ||
There are a number of different implementations of this basic idea, using different hash functions, as well as prefixes to prevent second preimage attacks (differentiating leaf nodes from inner nodes). Decher than force all chains that wish to participate in IBC to use the same data store, we provide a data structure that can represent Merkle proofs from a variety of data stores, and provide for chaining proofs to allow for subtrees. While searching for a solution, we did find the chainpoint proof format[[11](./references.md#11)], which inspired this design significantly, but didn't (yet) offer the flexibility we needed. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. addessed all |
||
|
||
We generalize the left/right idiom to the concatenation a (possibly empty) fixed prefix, the (just calculated) last hash, and a (possibly empty) fixed suffix. We must only define two fields on each level and can represent any type, even a 16-ary Patricia tree, with this structure. One must only translate from the store's native proof to this format, and it can be verified by any chain, providing compatibility with arbitrary data stores. | ||
|
||
The proof format also allows for chaining of trees, combining multiple Merkle stores into a "multi-store". Many applications (such as the EVM) define a data store with a large proof size for internal use. Rather than force them to change the store (impossible), or live with huge proofs (inefficient), we provide the possibility to express Merkle proofs connecting multiple subtrees. Thus, one could have one subtree for data, and a second for IBC. Each tree produces its own Merkle root, and these are then hashed together to produce the root hash that is stored in the block header. | ||
The proof format also allows for chaining of trees, combining multiple Merkle stores into a "multi-store". Many applications (such as the EVM) define a data store with a large proof size for internal use. Decher than force them to change the store (impossible), or live with huge proofs (inefficient), we provide the possibility to express Merkle proofs connecting multiple subtrees. Thus, one could have one subtree for data, and a second for IBC. Each tree produces its own Merkle root, and these are then hashed together to produce the root hash that is stored in the block header. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Decher strikes again! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. addessed all |
||
|
||
A valid Merkle proof for IBC must either consist of a proof of one tree, and prepend `ibc` to all key names as defined above, or use a subtree named `ibc` in the first section, and store the key names as above in the second tree. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ The IBC protocol creates a mechanism by which two replicated fault-tolerant stat | |
|
||
The IBC protocol assumes that multiple applications are running on their own blockchain with their own state and own logic. Communication is achieved over an ordered message queue primitive, allowing the creation of complex inter-chain processes without trusted third parties. | ||
|
||
The message packets are not signed by one psuedonymous account, or even multiple, as in multi-signature sidechain implementations. Rather, IBC assigns authorization of the packets to the source blockchain's consensus algorithm, performing light-client style verification on the destination chain. The Byzantine-fault-tolerant properties of the underlying blockchains are preserved: a user transferring assets between two chains using IBC must trust only the consensus algorithms of both chains. | ||
The message packets are not signed by one psuedonymous account, or even multiple, as in multi-signature sidechain implementations. Decher, IBC assigns authorization of the packets to the source blockchain's consensus algorithm, performing light-client style verification on the destination chain. The Byzantine-fault-tolerant properties of the underlying blockchains are preserved: a user transferring assets between two chains using IBC must trust only the consensus algorithms of both chains. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Decher strikes again! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. addessed all |
||
|
||
In this paper, we define a process of posting block headers and Merkle tree proofs to enable secure verification of individual packets. We then describe how to combine these packets into a messaging queue to guarantee ordered delivery. We then explain how to handle packet receipts (response/error) on the source chain, which enables the creation of asynchronous RPC-like protocols on top of IBC. Finally, we detail some optimizations and how to handle Byzantine blockchains. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,8 +113,8 @@ occur on an epoch basis. | |
```golang | ||
type powerChange struct { | ||
height int64 // block height at change | ||
power rational.Rat // total power at change | ||
prevpower rational.Rat // total power at previous height-1 | ||
power sdk.Dec // total power at change | ||
prevpower sdk.Dec // total power at previous height-1 | ||
feesin coins.Coin // fees in at block height | ||
prevFeePool coins.Coin // total fees in at previous block height | ||
} | ||
|
@@ -205,13 +205,13 @@ defined to be 13% per year, however the annual inflation is capped as between | |
7% and 20%. | ||
|
||
```go | ||
inflationRateChange(0) = 0 | ||
inflationDeceChange(0) = 0 | ||
Inflation(0) = 0.07 | ||
|
||
bondedRatio = Pool.BondedTokens / Pool.TotalSupplyTokens | ||
AnnualInflationRateChange = (1 - bondedRatio / 0.67) * 0.13 | ||
AnnualInflationDeceChange = (1 - bondedRatio / 0.67) * 0.13 | ||
|
||
annualInflation += AnnualInflationRateChange | ||
annualInflation += AnnualInflationDeceChange | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can these parameters be changed back? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replaced all |
||
|
||
if annualInflation > 0.20 then Inflation = 0.20 | ||
if annualInflation < 0.07 then Inflation = 0.07 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,16 +42,16 @@ processProvisions(): | |
|
||
setPool(pool) | ||
|
||
nextInflation(hrsPerYr rational.Rat): | ||
nextInflation(hrsPerYr sdk.Dec): | ||
if pool.TotalSupply > 0 | ||
bondedRatio = pool.BondedPool / pool.TotalSupply | ||
else | ||
bondedRation = 0 | ||
|
||
inflationRateChangePerYear = (1 - bondedRatio / params.GoalBonded) * params.InflationRateChange | ||
inflationRateChange = inflationRateChangePerYear / hrsPerYr | ||
inflationDeceChangePerYear = (1 - bondedRatio / params.GoalBonded) * params.InflationDeceChange | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More Find/Replace issues There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. addressed |
||
inflationDeceChange = inflationDeceChangePerYear / hrsPerYr | ||
|
||
inflation = pool.Inflation + inflationRateChange | ||
inflation = pool.Inflation + inflationDeceChange | ||
if inflation > params.InflationMax then inflation = params.InflationMax | ||
|
||
if inflation < params.InflationMin then inflation = params.InflationMin | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ type Pool struct { | |
LooseTokens int64 // tokens not associated with any bonded validator | ||
BondedTokens int64 // reserve of bonded tokens | ||
InflationLastTime int64 // block which the last inflation was processed // TODO make time | ||
Inflation sdk.Rat // current annual inflation rate | ||
Inflation sdk.Dec // current annual inflation rate | ||
|
||
DateLastCommissionReset int64 // unix timestamp for last commission accounting reset (daily) | ||
} | ||
|
@@ -29,10 +29,10 @@ overall functioning of the stake module. | |
|
||
```golang | ||
type Params struct { | ||
InflationRateChange sdk.Rat // maximum annual change in inflation rate | ||
InflationMax sdk.Rat // maximum inflation rate | ||
InflationMin sdk.Rat // minimum inflation rate | ||
GoalBonded sdk.Rat // Goal of percent bonded atoms | ||
InflationDeceChange sdk.Dec // maximum annual change in inflation rate | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looked through everything |
||
InflationMax sdk.Dec // maximum inflation rate | ||
InflationMin sdk.Dec // minimum inflation rate | ||
GoalBonded sdk.Dec // Goal of percent bonded atoms | ||
|
||
MaxValidators uint16 // maximum number of validators | ||
BondDenom string // bondable coin denomination | ||
|
@@ -75,9 +75,9 @@ type Validator struct { | |
Revoked bool // has the validator been revoked? | ||
|
||
Status sdk.BondStatus // validator status (bonded/unbonding/unbonded) | ||
Tokens sdk.Rat // delegated tokens (incl. self-delegation) | ||
DelegatorShares sdk.Rat // total shares issued to a validator's delegators | ||
SlashRatio sdk.Rat // increases each time the validator is slashed | ||
Tokens sdk.Dec // delegated tokens (incl. self-delegation) | ||
DelegatorShares sdk.Dec // total shares issued to a validator's delegators | ||
SlashRatio sdk.Dec // increases each time the validator is slashed | ||
|
||
Description Description // description terms for the validator | ||
|
||
|
@@ -90,14 +90,14 @@ type Validator struct { | |
ProposerRewardPool sdk.Coins // reward pool collected from being the proposer | ||
|
||
// TODO: maybe this belongs in distribution module ? | ||
LastBondedTokens sdk.Rat // last bonded token amount | ||
LastBondedTokens sdk.Dec // last bonded token amount | ||
} | ||
|
||
type CommissionInfo struct { | ||
Rate sdk.Rat // the commission rate of fees charged to any delegators | ||
Max sdk.Rat // maximum commission rate which this validator can ever charge | ||
ChangeRate sdk.Rat // maximum daily increase of the validator commission | ||
ChangeToday sdk.Rat // commission rate change today, reset each day (UTC time) | ||
Dece sdk.Dec // the commission rate of fees charged to any delegators | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably want a better variable name here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. was a find replace error - changed back to |
||
Max sdk.Dec // maximum commission rate which this validator can ever charge | ||
ChangeDece sdk.Dec // maximum daily increase of the validator commission | ||
ChangeToday sdk.Dec // commission rate change today, reset each day (UTC time) | ||
LastChange int64 // unix timestamp of last commission change | ||
} | ||
|
||
|
@@ -123,7 +123,7 @@ the transaction is the owner of the bond. | |
|
||
```golang | ||
type Delegation struct { | ||
Shares sdk.Rat // delegation shares recieved | ||
Shares sdk.Dec // delegation shares recieved | ||
Height int64 // last height bond updated | ||
} | ||
``` | ||
|
@@ -184,8 +184,8 @@ the original redelegation has been completed. | |
|
||
```golang | ||
type Redelegation struct { | ||
SourceShares sdk.Rat // amount of source shares redelegating | ||
DestinationShares sdk.Rat // amount of destination shares created at redelegation | ||
SourceShares sdk.Dec // amount of source shares redelegating | ||
DestinationShares sdk.Dec // amount of destination shares created at redelegation | ||
CompleteTime int64 // unix time to complete redelegation | ||
} | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could a note be added here instead of a bunch of
X
's?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my bad, this was left over from debugging