Skip to content

Commit

Permalink
Merge pull request #156 from terra-project/develop
Browse files Browse the repository at this point in the history
Columbus-2 update
  • Loading branch information
yun-yeo authored Jun 4, 2019
2 parents d6341ad + 1e1be9c commit 1caee38
Show file tree
Hide file tree
Showing 153 changed files with 10,006 additions and 1,822 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2.1
defaults: &linux_defaults
working_directory: /go/src/core
docker:
- image: circleci/golang:1.11.5
- image: circleci/golang:1.12.3
environment:
GOBIN: /tmp/workspace/bin

Expand Down
109 changes: 109 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
## 0.2.0

### Bug Fixes

* [\#140](https://github.com/terra-project/core/pull/140) Fix export bug.

* [\#140](https://github.com/terra-project/core/pull/140) Client querier bug fix (distr outstanding rewards)

* [\#140](https://github.com/terra-project/core/pull/140) Fix budget module to delete all votes when submitter withdraws the program and to use DeleteVotesForProgram to delete all votes for a program.

### Improvements
#### [\#140](https://github.com/terra-project/core/pull/140) Msg Types

```
cosmos-sdk/MsgSend => pay/MsgSend
cosmos-sdk/MsgMultiSend => pay/MsgMultiSend
cosmos-sdk/MsgCreateValidator => staking/MsgCreateValidator
cosmos-sdk/MsgEditValidator => staking/MsgEditValidator
cosmos-sdk/MsgDelegate => staking/MsgDelegate
cosmos-sdk/MsgUndelegate => staking/MsgUndelegate
cosmos-sdk/MsgBeginRedelegate => staking/MsgBeginRedelegate
cosmos-sdk/MsgWithdrawDelegationReward => distribution/MsgWithdrawDelegationReward
cosmos-sdk/MsgWithdrawValidatorCommission => distribution/MsgWithdrawValidatorCommission
cosmos-sdk/MsgModifyWithdrawAddress => distribution/MsgModifyWithdrawAddress
cosmos-sdk/MsgUnjail => slashing/MsgUnjail
```

#### [\#140](https://github.com/terra-project/core/pull/140) Oracle updates prevoting/voting
MsgPriceFeed is split into ```MsgPricePrevote``` and ```MsgPriceVote```
```
Period | P1 | P2 | P3 | ... |
Prevote | O | O | O | ... |
|-----\-----\-----\----- |
Vote | | O | O | ... |
```
In prevote stage, a validator should submit the hash of the part of real vote msg to prove the validator is not just copying other validators price vote. In vote phrase, the validator should reveal the real price by submitting MsgPriceVote with ```salt```.

The submission order has to be kept in (vote -> prevote) order. If an prevote comes early, it will replace previous prevote so next vote, which reveals the proof for previous prevote, will be failed.

#### [\#148](https://github.com/terra-project/core/pull/148) Oracle voting right delegation
By using the oracle/MsgDelegateFeederPermission a validator can assign the right to vote to another account at any time. The validator account will preserve its right to vote at any time.

#### [\#140](https://github.com/terra-project/core/pull/140) & [\#148](https://github.com/terra-project/core/pull/148) Rest Interface Update
##### Change rest interface url
```
"/distribution/parameters" => "/distribution/params"
"/staking/parameters" => "/staking/params"
```

##### New rest interfaces
```
(GET/POST) "/oracle/denoms/{%s}/votes"
(GET/POST) "/oracle/denoms/{%s}/prevotes"
(GET/POST) "/oracle/voters/{%s}/feeder"
```

#### [\#140](https://github.com/terra-project/core/pull/140) Add transaction logs for tax and swap amount
##### Send Tx
Add **tax** log to send transaction for recording real amount which a transaction pay.
Ex) txs/B515331BF9EA9A92AD59A85D593E5A2B170E3D297C59E85DDA9FA6FF33790E9B
```
{
"logs": [
{
"msg_index": 0,
"success": true,
"log": "{\"tax\":\"400uluna\"}"
}
]
}
```

##### Swap Tx
Add **swap_coin** log to swap transaction for recording the amount of swapped coin along with offered coin
```
{
"logs": [
{
"msg_index": 0,
"success": true,
"log": "{\"swap_coin\":\"400ukrw\"}"
}
]
}
```

#### [\#150](https://github.com/terra-project/core/pull/150) Market Swap protections

##### Add bidirectional Luna supply change cap on market swaps.
A daily trading cap (luna supply change cap) protects excessive luna volatility. Capping Luna deflation prevents divesting attacks (attacker swaps large amount into terra to avoid slippage) and consensus attacks by limiting access to staking tokens. Early parameters are 2% - 10% on both sides of the trade.

##### Add bidirectional Luna spread fees on market swaps
To protect against short term price deviations between the open market and the on-chain oracle, we now charge a 2-10% spread on swaps that involve luna.

##### Change oracle reward scheme from monthly seigniorage to validators to minute distribution
Swap spreads are distributed to oracle ballot winners on the oracle VotePeriod; this vastly shortens distribution periods. Also, all stakeholders receive oracle rewards (includes delegators).

##### Swaps halt immediately after an illiquid oracle vote
Previously we facilitated swaps for 10 VotePeriods after the last valid oracle ballot. We now stop swaps immediately to prevent arbitrage attacks from price drift.


### Parameter Changes

#### [\#150](https://github.com/terra-project/core/pull/150) Change MiningRewardWeight.Max from 20% to 90%. This is to reduce volatility in fees at network infancy.

#### Changed BlocksPerMinute from 12 to 5 to more accurately reflect Columbus block times.
23 changes: 18 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

**Key features:**

- A family of stable-coins pegged to major currencies, at genesis SDR, USD, KRW, JPY, EUR, and CNY.
- A family of stable-coins pegged to major currencies, e.g. SDR, USD, KRW, JPY, EUR, and CNY.
- Stability achieved by creating mining incentives that are countercyclical to Terra demand
- Delegated Proof-of-Stake (Tendermint) consensus formed over the mining token Luna
- Zero-spread atomic swap amongst Terra currencies.
Expand All @@ -26,9 +26,21 @@ Terra Core builds on [Tendermint](https://github.com/tendermint/tendermint) cons

### Network

Public testnet Soju-0007 is online. Currently the Columbus public mainnet is being prepared for launch.
- Mainnet Columbus-1 is online. [The launch repo](https://github.com/terra-project/launch) contains snapshot of the launch as well as network launch updates.

[Testnets](https://github.com/terra-project/networks) contains latest updates to the testnet.
- Public testnet Soju-0007 is online. [Our networks repo](https://github.com/terra-project/networks) contains latest configuration files for the testnet. [The Faucet](https://faucet.terra.money) can be used to get free tokens for the testnet.


### Ecosystem

- Block Explorers
- [Terra Finder](https://finder.terra.money)
- [Figment Hubble](https://hubble.figment.network/terra/chains/columbus-1)
- [Stake ID by StakingFund](https://terra.stake.id)
- [Big Dipper by Forbole](https://terra.bigdipper.live/)

- Wallet
- [Terra Station](https://terra.money): Available for download on the Terra website


### Terra Alliance
Expand All @@ -40,12 +52,13 @@ The current state of the Terra Alliance (businesses gearing to adopt Terra upon

Community channels actively being managed are here:
- [Website](https://terra.money/)
- [Discord](https://discord.gg/vutpqa)
- [Telegram](https://t.me/terra_announcements)
- [Twitter](https://twitter.com/terra_money)
- [YouTube](https://goo.gl/3G4T1z)

We are currently finalizing contribution standards and guidelines. In the meanwhile, if you are interested in contributing to the Terra Project, please contact our [admin](mailto:general@terra.money).
We are currently finalizing contribution standards and guidelines. In the meanwhile, if you are interested in contributing to the Terra Project, please contact our [admin](mailto:core@terra.money).

## Documentation

See the [docs](./docs/guide/README.md) and the [white paper](https://terra.money/static/Terra_White_Paper.pdf).
See the [docs](https://docs.terra.money) and the [white paper](https://terra.money/static/Terra_White_Paper.pdf). Read the [Changelog](./CHANGELOG.md) for major release updates.
58 changes: 40 additions & 18 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ import (
"github.com/terra-project/core/x/pay"
"github.com/terra-project/core/x/treasury"

"github.com/terra-project/core/types/assets"

tdistr "github.com/terra-project/core/x/distribution"
tslashing "github.com/terra-project/core/x/slashing"
tstaking "github.com/terra-project/core/x/staking"

bam "github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -25,6 +31,10 @@ import (
"github.com/cosmos/cosmos-sdk/x/params"
"github.com/cosmos/cosmos-sdk/x/slashing"
"github.com/cosmos/cosmos-sdk/x/staking"

distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

abci "github.com/tendermint/tendermint/abci/types"
cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tendermint/libs/db"
Expand Down Expand Up @@ -158,20 +168,25 @@ func NewTerraApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest,
app.bankKeeper,
app.feeCollectionKeeper,
)
app.oracleKeeper = oracle.NewKeeper(
app.cdc,
app.keyOracle,
stakingKeeper.GetValidatorSet(),
app.paramsKeeper.Subspace(oracle.DefaultParamspace),
)
app.mintKeeper = mint.NewKeeper(
app.cdc,
app.keyMint,
stakingKeeper,
app.bankKeeper,
app.accountKeeper,
)
app.oracleKeeper = oracle.NewKeeper(
app.cdc,
app.keyOracle,
app.mintKeeper,
app.distrKeeper,
app.feeCollectionKeeper,
stakingKeeper.GetValidatorSet(),
app.paramsKeeper.Subspace(oracle.DefaultParamspace),
)
app.marketKeeper = market.NewKeeper(
app.cdc,
app.keyMarket,
app.oracleKeeper,
app.mintKeeper,
app.paramsKeeper.Subspace(market.DefaultParamspace),
Expand All @@ -187,7 +202,9 @@ func NewTerraApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest,
app.budgetKeeper = budget.NewKeeper(
app.cdc,
app.keyBudget,
app.marketKeeper,
app.mintKeeper,
app.treasuryKeeper,
stakingKeeper.GetValidatorSet(),
app.paramsKeeper.Subspace(budget.DefaultParamspace),
)
Expand Down Expand Up @@ -262,10 +279,12 @@ func (app *TerraApp) Query(req abci.RequestQuery) (res abci.ResponseQuery) {
// MakeCodec builds a custom tx codec
func MakeCodec() *codec.Codec {
var cdc = codec.New()
bank.RegisterCodec(cdc)
staking.RegisterCodec(cdc)
distr.RegisterCodec(cdc)
slashing.RegisterCodec(cdc)

// left codec for backward compatibility
pay.RegisterCodec(cdc)
tstaking.RegisterCodec(cdc)
tdistr.RegisterCodec(cdc)
tslashing.RegisterCodec(cdc)
auth.RegisterCodec(cdc)
types.RegisterCodec(cdc)
oracle.RegisterCodec(cdc)
Expand All @@ -275,6 +294,12 @@ func MakeCodec() *codec.Codec {
crisis.RegisterCodec(cdc)
sdk.RegisterCodec(cdc)
codec.RegisterCrypto(cdc)

stakingtypes.SetMsgCodec(cdc)
distrtypes.SetMsgCodec(cdc)
bank.SetMsgCodec(cdc)
slashing.SetMsgCodec(cdc)

return cdc
}

Expand All @@ -300,17 +325,11 @@ func (app *TerraApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) a
func (app *TerraApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
validatorUpdates, tags := staking.EndBlocker(ctx, app.stakingKeeper)

oracleClaims, oracleTags := oracle.EndBlocker(ctx, app.oracleKeeper)
oracleTags := oracle.EndBlocker(ctx, app.oracleKeeper)
tags = append(tags, oracleTags...)
for _, oracleClaim := range oracleClaims {
app.treasuryKeeper.AddClaim(ctx, oracleClaim)
}

budgetClaims, budgetTags := budget.EndBlocker(ctx, app.budgetKeeper)
budgetTags := budget.EndBlocker(ctx, app.budgetKeeper)
tags = append(tags, budgetTags...)
for _, budgetClaim := range budgetClaims {
app.treasuryKeeper.AddClaim(ctx, budgetClaim)
}

treasuryTags := treasury.EndBlocker(ctx, app.treasuryKeeper)
tags = append(tags, treasuryTags...)
Expand Down Expand Up @@ -409,6 +428,9 @@ func (app *TerraApp) initChainer(ctx sdk.Context, req abci.RequestInitChain) abc
}
}

// GetIssuance needs to be called once to read account balances to the store
app.mintKeeper.GetIssuance(ctx, assets.MicroLunaDenom, sdk.ZeroInt())

// assert runtime invariants
app.assertRuntimeInvariants()

Expand Down
19 changes: 17 additions & 2 deletions app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ func (app *TerraApp) prepForZeroHeightGenesis(ctx sdk.Context, jailWhiteList []s

// withdraw all validator commission
app.stakingKeeper.IterateValidators(ctx, func(_ int64, val sdk.Validator) (stop bool) {
_ = app.distrKeeper.WithdrawValidatorCommission(ctx, val.GetOperator())
_, _ = app.distrKeeper.WithdrawValidatorCommission(ctx, val.GetOperator())
return false
})

// withdraw all delegator rewards
dels := app.stakingKeeper.GetAllDelegations(ctx)
for _, delegation := range dels {
_ = app.distrKeeper.WithdrawDelegationRewards(ctx, delegation.DelegatorAddress, delegation.ValidatorAddress)
_, _ = app.distrKeeper.WithdrawDelegationRewards(ctx, delegation.DelegatorAddress, delegation.ValidatorAddress)
}

// clear validator slash events
Expand All @@ -110,13 +110,21 @@ func (app *TerraApp) prepForZeroHeightGenesis(ctx sdk.Context, jailWhiteList []s

// reinitialize all validators
app.stakingKeeper.IterateValidators(ctx, func(_ int64, val sdk.Validator) (stop bool) {

// donate any unwithdrawn outstanding reward fraction tokens to the community pool
scraps := app.distrKeeper.GetValidatorOutstandingRewards(ctx, val.GetOperator())
feePool := app.distrKeeper.GetFeePool(ctx)
feePool.CommunityPool = feePool.CommunityPool.Add(scraps)
app.distrKeeper.SetFeePool(ctx, feePool)

app.distrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator())
return false
})

// reinitialize all delegations
for _, del := range dels {
app.distrKeeper.Hooks().BeforeDelegationCreated(ctx, del.DelegatorAddress, del.ValidatorAddress)
app.distrKeeper.Hooks().AfterDelegationModified(ctx, del.DelegatorAddress, del.ValidatorAddress)
}

// reset context height
Expand Down Expand Up @@ -179,4 +187,11 @@ func (app *TerraApp) prepForZeroHeightGenesis(ctx sdk.Context, jailWhiteList []s
return false
},
)

// reset submit height on program infos
app.budgetKeeper.IteratePrograms(ctx, false, func(program budget.Program) (stop bool) {
program.SubmitBlock = 0
app.budgetKeeper.StoreProgram(ctx, program)
return false
})
}
19 changes: 11 additions & 8 deletions app/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,17 @@ func NewGenesisAccountI(acc auth.Account) GenesisAccount {
Sequence: acc.GetSequence(),
}

vacc, ok := acc.(types.GradedVestingAccount)
vacc, ok := acc.(auth.VestingAccount)
if ok {
gacc.OriginalVesting = vacc.GetOriginalVesting()
gacc.DelegatedFree = vacc.GetDelegatedFree()
gacc.DelegatedVesting = vacc.GetDelegatedVesting()
gacc.StartTime = vacc.GetStartTime()
gacc.EndTime = vacc.GetEndTime()
gacc.VestingSchedules = vacc.GetVestingSchedules()
gvacc, ok := vacc.(types.GradedVestingAccount)
if ok {
gacc.OriginalVesting = gvacc.GetOriginalVesting()
gacc.DelegatedFree = gvacc.GetDelegatedFree()
gacc.DelegatedVesting = gvacc.GetDelegatedVesting()
gacc.StartTime = gvacc.GetStartTime()
gacc.EndTime = gvacc.GetEndTime()
gacc.VestingSchedules = gvacc.GetVestingSchedules()
}
}

return gacc
Expand Down Expand Up @@ -161,7 +164,7 @@ func (ga *GenesisAccount) ToAccount() auth.Account {
BaseVestingAccount: baseVestingAcc,
}
} else {
return &types.GradedVestingAccount{
return &types.BaseGradedVestingAccount{
BaseVestingAccount: baseVestingAcc,
VestingSchedules: ga.VestingSchedules,
}
Expand Down
2 changes: 1 addition & 1 deletion app/invariants.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (app *TerraApp) assertRuntimeInvariantsOnContext(ctx sdk.Context) {
if err := ir.Invar(ctx); err != nil {
panic(fmt.Errorf("invariant broken: %s\n"+
"\tCRITICAL please submit the following transaction:\n"+
"\t\t gaiacli tx crisis invariant-broken %v %v", err, ir.ModuleName, ir.Route))
"\t\t terracli tx crisis invariant-broken %v %v", err, ir.ModuleName, ir.Route))
}
}
end := time.Now()
Expand Down
Loading

0 comments on commit 1caee38

Please sign in to comment.