Skip to content
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

DAC voting, base fee proposal #269

Merged
merged 3 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions config/camino.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ import (
)

const (
DaoProposalBondAmountKey = "dao-proposal-bond-amount"
DACProposalBondAmountKey = "dac-proposal-bond-amount"
)

func addCaminoFlags(fs *flag.FlagSet) {
// Bond amount required to place a DAO proposal on the Primary Network
fs.Uint64(DaoProposalBondAmountKey, genesis.LocalParams.CaminoConfig.DaoProposalBondAmount, "Amount, in nAVAX, required to place a DAO proposal")
// Bond amount required to place a DAC proposal on the Primary Network
fs.Uint64(DACProposalBondAmountKey, genesis.LocalParams.CaminoConfig.DACProposalBondAmount, "Amount, in nAVAX, required to place a DAC proposal")
}

func getCaminoPlatformConfig(v *viper.Viper) caminoconfig.Config {
conf := caminoconfig.Config{
DaoProposalBondAmount: v.GetUint64(DaoProposalBondAmountKey),
DACProposalBondAmount: v.GetUint64(DACProposalBondAmountKey),
}
return conf
}
170 changes: 170 additions & 0 deletions database/linkeddb/mock_linkeddb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion genesis/genesis_camino.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var (
SupplyCap: 1000 * units.MegaAvax,
},
CaminoConfig: caminoconfig.Config{
DaoProposalBondAmount: 1 * units.KiloAvax,
DACProposalBondAmount: 1 * units.KiloAvax,
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion genesis/genesis_columbus.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var (
SupplyCap: 1000 * units.MegaAvax,
},
CaminoConfig: caminoconfig.Config{
DaoProposalBondAmount: 100 * units.Avax,
DACProposalBondAmount: 100 * units.Avax,
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion genesis/genesis_kopernikus.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var (
SupplyCap: 1000 * units.MegaAvax,
},
CaminoConfig: caminoconfig.Config{
DaoProposalBondAmount: 100 * units.Avax,
DACProposalBondAmount: 100 * units.Avax,
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion genesis/genesis_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ var (
SupplyCap: 720 * units.MegaAvax,
},
CaminoConfig: caminoconfig.Config{
DaoProposalBondAmount: 100 * units.Avax,
DACProposalBondAmount: 100 * units.Avax,
},
},
}
Expand Down
14 changes: 14 additions & 0 deletions version/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ var (
}
AthensPhaseDefaultTime = time.Date(2023, time.July, 1, 8, 0, 0, 0, time.UTC)

BerlinPhaseTimes = map[uint32]time.Time{
constants.KopernikusID: time.Date(2023, time.July, 4, 13, 0, 0, 0, time.UTC),
constants.ColumbusID: time.Date(2023, time.July, 7, 8, 0, 0, 0, time.UTC),
constants.CaminoID: time.Date(2023, time.July, 17, 8, 0, 0, 0, time.UTC),
}
BerlinPhaseDefaultTime = time.Date(2023, time.July, 1, 8, 0, 0, 0, time.UTC)

// TODO: update this before release
CortinaTimes = map[uint32]time.Time{
constants.MainnetID: time.Date(10000, time.December, 1, 0, 0, 0, 0, time.UTC),
Expand Down Expand Up @@ -204,6 +211,13 @@ func GetAthensPhaseTime(networkID uint32) time.Time {
return AthensPhaseDefaultTime
}

func GetBerlinPhaseTime(networkID uint32) time.Time {
if upgradeTime, exists := BerlinPhaseTimes[networkID]; exists {
return upgradeTime
}
return BerlinPhaseDefaultTime
}

func GetCortinaTime(networkID uint32) time.Time {
if upgradeTime, exists := CortinaTimes[networkID]; exists {
return upgradeTime
Expand Down
48 changes: 48 additions & 0 deletions vms/platformvm/blocks/builder/camino_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func caminoBuildBlock(
return nil, nil
}

// Ulocking expired deposits
depositsTxIDs, shouldUnlock, err := getNextDepositsToUnlock(parentState, timestamp)
if err != nil {
return nil, fmt.Errorf("could not find next deposits to unlock: %w", err)
Expand All @@ -90,6 +91,31 @@ func caminoBuildBlock(
)
}

// Finishing expired and early finished proposals
expiredProposalIDs, err := getExpiredProposals(parentState, timestamp)
if err != nil {
return nil, fmt.Errorf("could not find expired proposals: %w", err)
}
earlyFinishedProposalIDs, err := parentState.GetProposalIDsToFinish()
if err != nil {
return nil, fmt.Errorf("could not find successful proposals: %w", err)
}
if len(expiredProposalIDs) > 0 || len(earlyFinishedProposalIDs) > 0 {
finishProposalsTx, err := txBuilder.FinishProposalsTx(parentState, earlyFinishedProposalIDs, expiredProposalIDs)
if err != nil {
return nil, fmt.Errorf("could not build tx to finish proposals: %w", err)
}

// FinishProposalsTx should never be in block with addVoteTx,
// because it can affect state of proposals.
return blocks.NewBanffStandardBlock(
timestamp,
parentID,
height,
[]*txs.Tx{finishProposalsTx},
)
}

return nil, nil
}

Expand Down Expand Up @@ -133,3 +159,25 @@ func getNextDepositsToUnlock(

return nextDeposits, nextDepositsEndtime.Equal(chainTime), nil
}

func getExpiredProposals(
preferredState state.Chain,
chainTime time.Time,
) ([]ids.ID, error) {
if !chainTime.Before(mockable.MaxTime) {
return nil, errEndOfTime
}

nextProposals, nextProposalsEndtime, err := preferredState.GetNextToExpireProposalIDsAndTime(nil)
if err == database.ErrNotFound {
return nil, nil
} else if err != nil {
return nil, err
}

if nextProposalsEndtime.Equal(chainTime) {
return nextProposals, nil
}

return nil, nil
}
3 changes: 2 additions & 1 deletion vms/platformvm/blocks/executor/proposal_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ func TestBanffProposalBlockTimeVerification(t *testing.T) {
onParentAccept.EXPECT().GetDeferredStakerIterator().Return(deferredStakersIt, nil).AnyTimes()

onParentAccept.EXPECT().GetNextToUnlockDepositTime(nil).Return(time.Time{}, database.ErrNotFound).AnyTimes()
onParentAccept.EXPECT().GetNextToUnlockDepositIDsAndTime(nil).Return(nil, time.Time{}, database.ErrNotFound).AnyTimes()
onParentAccept.EXPECT().GetNextProposalExpirationTime(nil).Return(time.Time{}, database.ErrNotFound).AnyTimes()
onParentAccept.EXPECT().GetProposalIDsToFinish().Return(nil, nil).AnyTimes()

env.mockedState.EXPECT().GetUptime(gomock.Any(), gomock.Any()).Return(
time.Duration(1000), /*upDuration*/
Expand Down
3 changes: 2 additions & 1 deletion vms/platformvm/blocks/executor/standard_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ func TestBanffStandardBlockTimeVerification(t *testing.T) {
onParentAccept.EXPECT().GetDeferredStakerIterator().Return(deferredStakersIt, nil).AnyTimes()

onParentAccept.EXPECT().GetNextToUnlockDepositTime(nil).Return(time.Time{}, database.ErrNotFound).AnyTimes()
onParentAccept.EXPECT().GetNextToUnlockDepositIDsAndTime(nil).Return(nil, time.Time{}, database.ErrNotFound).AnyTimes()
onParentAccept.EXPECT().GetNextProposalExpirationTime(nil).Return(time.Time{}, database.ErrNotFound).AnyTimes()
onParentAccept.EXPECT().GetProposalIDsToFinish().Return(nil, nil).AnyTimes()

onParentAccept.EXPECT().GetTimestamp().Return(chainTime).AnyTimes()

Expand Down
Loading
Loading