From c31c46f33fbd888c8c2b915a041e6733c0b29d21 Mon Sep 17 00:00:00 2001 From: Sean Rowan <sprwn@protonmail.com> Date: Tue, 25 Apr 2023 14:47:11 -0400 Subject: [PATCH 1/8] Removed hash-based validator config mechanism, made staking parameters mutable over time depending on inflation --- avalanchego/scripts/test_deploy_validators.sh | 112 +---------------- .../utils/constants/validator_config.go | 86 ------------- avalanchego/utils/hashing/hashing.go | 11 -- avalanchego/utils/hashing/hashing_test.go | 40 ------ avalanchego/vms/platformvm/fx/fx.go | 4 - .../txs/executor/proposal_tx_executor.go | 117 ++++++++---------- avalanchego/vms/platformvm/utxo/handler.go | 15 --- avalanchego/vms/platformvm/vm_test.go | 8 +- avalanchego/vms/secp256k1fx/fx.go | 21 ---- 9 files changed, 58 insertions(+), 356 deletions(-) delete mode 100644 avalanchego/utils/constants/validator_config.go delete mode 100644 avalanchego/utils/hashing/hashing_test.go diff --git a/avalanchego/scripts/test_deploy_validators.sh b/avalanchego/scripts/test_deploy_validators.sh index 88a5ce78..132f912c 100755 --- a/avalanchego/scripts/test_deploy_validators.sh +++ b/avalanchego/scripts/test_deploy_validators.sh @@ -50,7 +50,7 @@ printf "\nCreating new validator: NodeID-MFrZFVCXPv5iCn6M9K6XduxGTYp891xXZ " CURR_TIME=$(date +%s) START_TIME=$(($CURR_TIME+300)) -END_TIME=$(($START_TIME+86400)) +END_TIME=$(($START_TIME+1209600)) curl -s --location --request POST 'http://localhost:9650/ext/bc/P' \ --header 'Content-Type: application/json' \ @@ -63,7 +63,7 @@ curl -s --location --request POST 'http://localhost:9650/ext/bc/P' \ "endTime":'$END_TIME', "stakeAmount": 10000000000000, "rewardAddress": "P-localflare1pz6dhzxvfmztknw35ukl8fav6gzjt9xwmkngua", - "delegationFeeRate":10, + "delegationFeeRate":0, "username": "user1234", "password": "b39d642078d2ca0517cafe008ddc9326fa1c4d71248078c67bf0d508993720e4" }, @@ -85,7 +85,7 @@ curl -s --location --request POST 'http://localhost:9650/ext/bc/P' \ "endTime":'$END_TIME', "stakeAmount": 10000000000000, "rewardAddress": "P-localflare1pz6dhzxvfmztknw35ukl8fav6gzjt9xwmkngua", - "delegationFeeRate":10, + "delegationFeeRate":0, "username": "user1234", "password": "b39d642078d2ca0517cafe008ddc9326fa1c4d71248078c67bf0d508993720e4" }, @@ -107,7 +107,7 @@ curl -s --location --request POST 'http://localhost:9650/ext/bc/P' \ "endTime":'$END_TIME', "stakeAmount": 10000000000000, "rewardAddress": "P-localflare1pz6dhzxvfmztknw35ukl8fav6gzjt9xwmkngua", - "delegationFeeRate":10, + "delegationFeeRate":0, "username": "user1234", "password": "b39d642078d2ca0517cafe008ddc9326fa1c4d71248078c67bf0d508993720e4" }, @@ -129,7 +129,7 @@ curl -s --location --request POST 'http://localhost:9650/ext/bc/P' \ "endTime":'$END_TIME', "stakeAmount": 10000000000000, "rewardAddress": "P-localflare1pz6dhzxvfmztknw35ukl8fav6gzjt9xwmkngua", - "delegationFeeRate":10, + "delegationFeeRate":0, "username": "user1234", "password": "b39d642078d2ca0517cafe008ddc9326fa1c4d71248078c67bf0d508993720e4" }, @@ -152,106 +152,4 @@ curl -s --location --request POST 'http://localhost:9650/ext/bc/P' \ "id": 1 }' | jq . -sleep 5 -printf "\nTesting validator creation with non-permitted NodeID's:" -printf "\nAttempting to create invalid validator : NodeID-4XZ7a7fGCzw6xqMFNQHy46JjUXnnq51Y1 " - -curl -s --location --request POST 'http://localhost:9650/ext/bc/P' \ ---header 'Content-Type: application/json' \ ---data-raw '{ - "jsonrpc": "2.0", - "method": "platform.addValidator", - "params": { - "nodeID":"NodeID-4XZ7a7fGCzw6xqMFNQHy46JjUXnnq51Y1", - "startTime":'$START_TIME', - "endTime":'$END_TIME', - "stakeAmount": 10000000000000, - "rewardAddress": "P-localflare1pz6dhzxvfmztknw35ukl8fav6gzjt9xwmkngua", - "delegationFeeRate":10, - "username": "user1234", - "password": "b39d642078d2ca0517cafe008ddc9326fa1c4d71248078c67bf0d508993720e4" - }, - "id": 1 -}' | jq . - -sleep 5 - -printf "\nAttempting to create invalid validator : NodeID-DMAS3hKKWMydmWGmGd265EYCoV7zFWEHK " - -curl -s --location --request POST 'http://localhost:9650/ext/bc/P' \ ---header 'Content-Type: application/json' \ ---data-raw '{ - "jsonrpc": "2.0", - "method": "platform.addValidator", - "params": { - "nodeID":"NodeID-DMAS3hKKWMydmWGmGd265EYCoV7zFWEHK", - "startTime":'$START_TIME', - "endTime":'$END_TIME', - "stakeAmount": 10000000000000, - "rewardAddress": "P-localflare1pz6dhzxvfmztknw35ukl8fav6gzjt9xwmkngua", - "delegationFeeRate":10, - "username": "user1234", - "password": "b39d642078d2ca0517cafe008ddc9326fa1c4d71248078c67bf0d508993720e4" - }, - "id": 1 -}' | jq . - -sleep 5 - -printf "\nAttempting to create invalid validator : NodeID-Lx7BqRD3LQuqZbpJzkc5UDTZb66cpez95 " - -curl -s --location --request POST 'http://localhost:9650/ext/bc/P' \ ---header 'Content-Type: application/json' \ ---data-raw '{ - "jsonrpc": "2.0", - "method": "platform.addValidator", - "params": { - "nodeID":"NodeID-Lx7BqRD3LQuqZbpJzkc5UDTZb66cpez95", - "startTime":'$START_TIME', - "endTime":'$END_TIME', - "stakeAmount": 10000000000000, - "rewardAddress": "P-localflare1pz6dhzxvfmztknw35ukl8fav6gzjt9xwmkngua", - "delegationFeeRate":10, - "username": "user1234", - "password": "b39d642078d2ca0517cafe008ddc9326fa1c4d71248078c67bf0d508993720e4" - }, - "id": 1 -}' | jq . - -sleep 5 - -printf "\nAttempting to create invalid validator : NodeID-2oZa4x84qqpdNqxKSL3PW28iex3VS1NQT " - -curl -s --location --request POST 'http://localhost:9650/ext/bc/P' \ ---header 'Content-Type: application/json' \ ---data-raw '{ - "jsonrpc": "2.0", - "method": "platform.addValidator", - "params": { - "nodeID":"NodeID-2oZa4x84qqpdNqxKSL3PW28iex3VS1NQT", - "startTime":'$START_TIME', - "endTime":'$END_TIME', - "stakeAmount": 10000000000000, - "rewardAddress": "P-localflare1pz6dhzxvfmztknw35ukl8fav6gzjt9xwmkngua", - "delegationFeeRate":10, - "username": "user1234", - "password": "b39d642078d2ca0517cafe008ddc9326fa1c4d71248078c67bf0d508993720e4" - }, - "id": 1 -}' | jq . - -printf "\nGet pending validators:\n" - -curl -s --location --request POST 'http://localhost:9650/ext/bc/P' \ ---header 'Content-Type: application/json' \ ---data-raw '{ - "jsonrpc": "2.0", - "method": "platform.getPendingValidators", - "params": { - "subnetID": null, - "nodeIDs": [] - }, - "id": 1 -}' | jq .result - printf "\nNew validators will start in $(($START_TIME-$(date +%s))) seconds\n" \ No newline at end of file diff --git a/avalanchego/utils/constants/validator_config.go b/avalanchego/utils/constants/validator_config.go deleted file mode 100644 index 2b5a6471..00000000 --- a/avalanchego/utils/constants/validator_config.go +++ /dev/null @@ -1,86 +0,0 @@ -package constants - -import ( - "time" -) - -var ( - flareValidatorActivationTime = time.Date(10000, time.January, 1, 0, 0, 0, 0, time.UTC) - costwoValidatorActivationTime = time.Date(10000, time.January, 1, 0, 0, 0, 0, time.UTC) - stagingValidatorActivationTime = time.Date(10000, time.January, 1, 0, 0, 0, 0, time.UTC) - localFlareValidatorActivationTime = time.Date(2022, time.January, 1, 0, 0, 0, 0, time.UTC) -) - -func CompareValidatorConfigs( - validatorConfigHash string, - validatorConfigs []string, -) bool { - for _, vdr := range validatorConfigs { - if validatorConfigHash == vdr { - return true - } - } - return false -} - -func VerifyValidatorConfigHash(networkID uint32, currentTimestamp time.Time, validatorConfigHash string) bool { - switch networkID { - case FlareID: - if currentTimestamp.After(flareValidatorActivationTime) { - return VerifyFlare(currentTimestamp, validatorConfigHash) - } - case CostwoID: - if currentTimestamp.After(costwoValidatorActivationTime) { - return VerifyCostwo(currentTimestamp, validatorConfigHash) - } - case StagingID: - if currentTimestamp.After(stagingValidatorActivationTime) { - return VerifyStaging(currentTimestamp, validatorConfigHash) - } - case LocalFlareID: - if currentTimestamp.After(localFlareValidatorActivationTime) { - return VerifyLocalFlare(currentTimestamp, validatorConfigHash) - } - case UnitTestID: - return UnitTestID == 10 - } - return false -} - -func VerifyFlare(currentTimestamp time.Time, validatorConfigHash string) bool { - switch { - default: - return false - } -} - -func VerifyCostwo(currentTimestamp time.Time, validatorConfigHash string) bool { - switch { - default: - return false - } -} - -func VerifyStaging(currentTimestamp time.Time, validatorConfigHash string) bool { - switch { - default: - return false - } -} - -func VerifyLocalFlare(currentTimestamp time.Time, validatorConfigHash string) bool { - switch { - case currentTimestamp.Before(time.Date(10000, time.June, 1, 0, 0, 0, 0, time.UTC)): - return CompareValidatorConfigs( - validatorConfigHash, - []string{ - "3b66ad21620fe6d0dd1665b89b7c5f7a3b18e34d7d18ca56b732f833b8259108", - "0f750b09f2702ecea445657120e7dcb0cdb46a8c87d1eae9a508fa4e3bfa5a32", - "39e596bdd2e00f5cb7fd86069c94159b98bdd79a4ed8684a88c0faf49f63bfab", - "aa43e6ef2d60823406e7e3cb6fcdb148fdd3ffcd137a261457f9ee6d541f9ca9", - }, - ) - default: - return false - } -} diff --git a/avalanchego/utils/hashing/hashing.go b/avalanchego/utils/hashing/hashing.go index 8402bc42..950ad2a9 100644 --- a/avalanchego/utils/hashing/hashing.go +++ b/avalanchego/utils/hashing/hashing.go @@ -5,7 +5,6 @@ package hashing import ( "crypto/sha256" - "encoding/hex" "fmt" "io" @@ -102,13 +101,3 @@ func ToHash160(bytes []byte) (Hash160, error) { func PubkeyBytesToAddress(key []byte) []byte { return ComputeHash160(ComputeHash256(key)) } - -func ToValidatorConfigHash(networkID string, pChainPublicKey string, nodeID string, weight string, duration string) string { - salt := "flare" + networkID + "-" - pChainPublicKeyHash := sha256.Sum256([]byte(salt + pChainPublicKey)) - nodeIDHash := sha256.Sum256([]byte(salt + nodeID)) - nodeWeightHash := sha256.Sum256([]byte(salt + weight)) - nodeDurationHash := sha256.Sum256([]byte(salt + duration)) - validatorConfigHash := sha256.Sum256(append(append(append(pChainPublicKeyHash[:], nodeIDHash[:]...)[:], nodeWeightHash[:]...)[:], nodeDurationHash[:]...)) - return hex.EncodeToString(validatorConfigHash[:]) -} diff --git a/avalanchego/utils/hashing/hashing_test.go b/avalanchego/utils/hashing/hashing_test.go deleted file mode 100644 index be3efbbb..00000000 --- a/avalanchego/utils/hashing/hashing_test.go +++ /dev/null @@ -1,40 +0,0 @@ -package hashing - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func TestToValidatorConfigHash(t *testing.T) { - require := require.New(t) - networkId := "162" - duration := "86400" - weight := "10000000000000" - - // pChainPkReadable := "P-localflare18jma8ppw3nhx5r4ap8clazz0dps7rv5uj3gy4v" - // pChainPk, err := address.ParseToID(pChainPkReadable) - // require.NoError(err) - pChainPk := "6Y3kysjF9jnHnYkdS9yGAuoHyae2eNmeV" - - nodeId1 := "NodeID-MFrZFVCXPv5iCn6M9K6XduxGTYp891xXZ" - nodeId2 := "NodeID-NFBbbJ4qCmNaCzeW7sxErhvWqvEQMnYcN" - nodeId3 := "NodeID-GWPcbFJZFfZreETSoWjPimr846mXEKCtu" - nodeId4 := "NodeID-P7oB2McjBGgW2NXXWVYjV8JEDFoW9xDE5" - - result1 := ToValidatorConfigHash(networkId, pChainPk, nodeId1, weight, duration) - t.Logf("Result: %v", result1) - require.True(result1 == "3b66ad21620fe6d0dd1665b89b7c5f7a3b18e34d7d18ca56b732f833b8259108") - - result2 := ToValidatorConfigHash(networkId, pChainPk, nodeId2, weight, duration) - t.Logf("Result: %v", result2) - require.True(result2 == "0f750b09f2702ecea445657120e7dcb0cdb46a8c87d1eae9a508fa4e3bfa5a32") - - result3 := ToValidatorConfigHash(networkId, pChainPk, nodeId3, weight, duration) - t.Logf("Result: %v", result3) - require.True(result3 == "39e596bdd2e00f5cb7fd86069c94159b98bdd79a4ed8684a88c0faf49f63bfab") - - result4 := ToValidatorConfigHash(networkId, pChainPk, nodeId4, weight, duration) - t.Logf("Result: %v", result4) - require.True(result4 == "aa43e6ef2d60823406e7e3cb6fcdb148fdd3ffcd137a261457f9ee6d541f9ca9") -} diff --git a/avalanchego/vms/platformvm/fx/fx.go b/avalanchego/vms/platformvm/fx/fx.go index 4e33ce2d..9c51211c 100644 --- a/avalanchego/vms/platformvm/fx/fx.go +++ b/avalanchego/vms/platformvm/fx/fx.go @@ -4,7 +4,6 @@ package fx import ( - "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" "github.com/ava-labs/avalanchego/vms/components/verify" "github.com/ava-labs/avalanchego/vms/secp256k1fx" @@ -38,9 +37,6 @@ type Fx interface { // CreateOutput creates a new output with the provided control group worth // the specified amount CreateOutput(amount uint64, controlGroup interface{}) (interface{}, error) - - // Returns the public key that signed an AddValidatorTx - GetPublicKeyForValidatorFilter(tx, cred interface{}) (ids.ShortID, error) } type Owner interface { diff --git a/avalanchego/vms/platformvm/txs/executor/proposal_tx_executor.go b/avalanchego/vms/platformvm/txs/executor/proposal_tx_executor.go index c660a818..f2ecebba 100644 --- a/avalanchego/vms/platformvm/txs/executor/proposal_tx_executor.go +++ b/avalanchego/vms/platformvm/txs/executor/proposal_tx_executor.go @@ -6,13 +6,12 @@ package executor import ( "errors" "fmt" - "strconv" "time" "github.com/ava-labs/avalanchego/database" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/utils/constants" - "github.com/ava-labs/avalanchego/utils/hashing" + "github.com/ava-labs/avalanchego/utils/units" "github.com/ava-labs/avalanchego/utils/math" "github.com/ava-labs/avalanchego/vms/components/avax" @@ -69,44 +68,60 @@ func (*ProposalTxExecutor) CreateSubnetTx(*txs.CreateSubnetTx) error { return er func (*ProposalTxExecutor) ImportTx(*txs.ImportTx) error { return errWrongTxType } func (*ProposalTxExecutor) ExportTx(*txs.ExportTx) error { return errWrongTxType } +// minValidatorStake, maxValidatorStake, minDelegatorStake, minDelegationFee, minStakeDuration, maxStakeDuration, minStakeStartTime +// The values in this function are not finalised and are placeholders for now +func (e *ProposalTxExecutor) getCurrentInflationSettings(currentTimestamp time.Time) (uint64, uint64, uint64, uint32, time.Duration, time.Duration, time.Time) { + switch e.Backend.Ctx.NetworkID { + case constants.FlareID: + return 50 * units.KiloAvax, 50 * units.MegaAvax, 1 * units.KiloAvax, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, time.Date(2023, time.June, 28, 15, 0, 0, 0, time.UTC) + case constants.CostwoID: + return 50 * units.KiloAvax, 50 * units.MegaAvax, 1 * units.KiloAvax, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, time.Date(2023, time.May, 17, 15, 0, 0, 0, time.UTC) + case constants.StagingID: + return 50 * units.KiloAvax, 50 * units.MegaAvax, 1 * units.KiloAvax, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, time.Date(2023, time.May, 10, 15, 0, 0, 0, time.UTC) + case constants.LocalFlareID: + return 1, 50 * units.MegaAvax, 1, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, time.Date(2023, time.April, 10, 15, 0, 0, 0, time.UTC) + default: + return e.Config.MinValidatorStake, e.Config.MaxValidatorStake, e.Config.MinDelegatorStake, e.Config.MinDelegationFee, e.Config.MinStakeDuration, e.Config.MaxStakeDuration, time.Date(1970, time.January, 1, 0, 0, 0, 0, time.UTC) + } +} + func (e *ProposalTxExecutor) AddValidatorTx(tx *txs.AddValidatorTx) error { // Verify the tx is well-formed if err := e.Tx.SyntacticVerify(e.Ctx); err != nil { return err } + parentState, ok := e.StateVersions.GetState(e.ParentID) + if !ok { + return state.ErrMissingParentState + } + currentTimestamp := parentState.GetTimestamp() + + minValidatorStake, maxValidatorStake, _, minDelegationFee, minStakeDuration, maxStakeDuration, minStakeStartTime := e.getCurrentInflationSettings(currentTimestamp) switch { - case tx.Validator.Wght < e.Config.MinValidatorStake: + case tx.Validator.Wght < minValidatorStake: // Ensure validator is staking at least the minimum amount return errWeightTooSmall - case tx.Validator.Wght > e.Config.MaxValidatorStake: + case tx.Validator.Wght > maxValidatorStake: // Ensure validator isn't staking too much return errWeightTooLarge - case tx.Shares < e.Config.MinDelegationFee: + case tx.Shares < minDelegationFee: // Ensure the validator fee is at least the minimum amount return errInsufficientDelegationFee } - duration := tx.Validator.Duration() switch { - case duration < e.Config.MinStakeDuration: + case duration < minStakeDuration: // Ensure staking length is not too short return errStakeTooShort - case duration > e.Config.MaxStakeDuration: + case duration > maxStakeDuration: // Ensure staking length is not too long return errStakeTooLong } - parentState, ok := e.StateVersions.GetState(e.ParentID) - if !ok { - return state.ErrMissingParentState - } - - currentTimestamp := parentState.GetTimestamp() - // Blueberry disallows creating a validator with the empty ID. if !currentTimestamp.Before(e.Config.BlueberryTime) { if tx.Validator.NodeID == ids.EmptyNodeID { @@ -114,45 +129,6 @@ func (e *ProposalTxExecutor) AddValidatorTx(tx *txs.AddValidatorTx) error { } } - // SECP256K1 and Bech32 public key formatting docs: https://docs.avax.network/specs/cryptographic-primitives - // Bech32 can be converted to SECP256K1 public key bytes using address.ParseToID from "github.com/ava-labs/avalanchego/utils/formatting/address" - // testAddressID, err := address.ParseToID("P-localflare18jma8ppw3nhx5r4ap8clazz0dps7rv5uj3gy4v") // "6Y3kysjF9jnHnYkdS9yGAuoHyae2eNmeV" - - // publicKey is a SECP256K1 ids.ShortID value of the form: "6Y3kysjF9jnHnYkdS9yGAuoHyae2eNmeV" - publicKey, err := e.FlowChecker.GetPublicKeyForValidatorFilter( - tx, - e.Tx.Creds, - ) - if err != nil { - return err - } - networkID := e.Backend.Ctx.NetworkID - networkIDStr := strconv.FormatUint(uint64(networkID), 10) - publicKeyStr := publicKey.String() - nodeIDStr := tx.Validator.NodeID.String() - weightStr := strconv.FormatUint(tx.Validator.Wght, 10) - durationStr := strconv.FormatFloat(duration.Seconds(), 'f', 0, 64) - - validatorConfigHash := hashing.ToValidatorConfigHash( - networkIDStr, - publicKeyStr, - nodeIDStr, - weightStr, - durationStr, - ) - if !constants.VerifyValidatorConfigHash(networkID, currentTimestamp, validatorConfigHash) { - return fmt.Errorf( - "invalid validator config. currentTimestamp: (%s), networkID: (%s), pChainPublicKey: (%s), nodeID: (%s), weight: (%s), duration: (%s), validatorConfigHash: (%s)", - currentTimestamp, - networkIDStr, - publicKeyStr, - nodeIDStr, - weightStr, - durationStr, - validatorConfigHash, - ) - } - outs := make([]*avax.TransferableOutput, len(tx.Outs)+len(tx.Stake)) copy(outs, tx.Outs) copy(outs[len(tx.Outs):], tx.Stake) @@ -167,6 +143,13 @@ func (e *ProposalTxExecutor) AddValidatorTx(tx *txs.AddValidatorTx) error { currentTimestamp, ) } + if !minStakeStartTime.Before(startTime) { + return fmt.Errorf( + "validator's start time (%s) at or before minStakeStartTime (%s)", + startTime, + minStakeStartTime, + ) + } _, err := GetValidator(parentState, constants.PrimaryNetworkID, tx.Validator.NodeID) if err == nil { @@ -402,34 +385,33 @@ func (e *ProposalTxExecutor) AddDelegatorTx(tx *txs.AddDelegatorTx) error { return err } + parentState, ok := e.StateVersions.GetState(e.ParentID) + if !ok { + return state.ErrMissingParentState + } + currentTimestamp := parentState.GetTimestamp() + + _, maxValidatorStake, minDelegatorStake, _, minStakeDuration, maxStakeDuration, _ := e.getCurrentInflationSettings(currentTimestamp) + duration := tx.Validator.Duration() switch { - case duration < e.Config.MinStakeDuration: + case duration < minStakeDuration: // Ensure staking length is not too short return errStakeTooShort - case duration > e.Config.MaxStakeDuration: + case duration > maxStakeDuration: // Ensure staking length is not too long return errStakeTooLong - case tx.Validator.Wght < e.Config.MinDelegatorStake: + case tx.Validator.Wght < minDelegatorStake: // Ensure validator is staking at least the minimum amount return errWeightTooSmall } - if e.Backend.Ctx.NetworkID == constants.FlareID || e.Backend.Ctx.NetworkID == constants.CostwoID || e.Backend.Ctx.NetworkID == constants.StagingID || e.Backend.Ctx.NetworkID == constants.LocalFlareID { - return errStakeTooLong - } - outs := make([]*avax.TransferableOutput, len(tx.Outs)+len(tx.Stake)) copy(outs, tx.Outs) copy(outs[len(tx.Outs):], tx.Stake) - parentState, ok := e.StateVersions.GetState(e.ParentID) - if !ok { - return state.ErrMissingParentState - } - txID := e.Tx.ID() newStaker := state.NewPrimaryNetworkStaker(txID, &tx.Validator) @@ -437,7 +419,6 @@ func (e *ProposalTxExecutor) AddDelegatorTx(tx *txs.AddDelegatorTx) error { newStaker.Priority = state.PrimaryNetworkDelegatorPendingPriority if e.Bootstrapped.GetValue() { - currentTimestamp := parentState.GetTimestamp() // Ensure the proposed validator starts after the current timestamp validatorStartTime := tx.StartTime() if !currentTimestamp.Before(validatorStartTime) { @@ -463,7 +444,7 @@ func (e *ProposalTxExecutor) AddDelegatorTx(tx *txs.AddDelegatorTx) error { } if !currentTimestamp.Before(e.Config.ApricotPhase3Time) { - maximumWeight = math.Min64(maximumWeight, e.Config.MaxValidatorStake) + maximumWeight = math.Min64(maximumWeight, maxValidatorStake) } canDelegate, err := canDelegate(parentState, primaryNetworkValidator, maximumWeight, newStaker) diff --git a/avalanchego/vms/platformvm/utxo/handler.go b/avalanchego/vms/platformvm/utxo/handler.go index 9f9ca9d9..391b4be7 100644 --- a/avalanchego/vms/platformvm/utxo/handler.go +++ b/avalanchego/vms/platformvm/utxo/handler.go @@ -138,11 +138,6 @@ type Verifier interface { creds []verify.Verifiable, unlockedProduced map[ids.ID]uint64, ) error - - GetPublicKeyForValidatorFilter( - tx txs.UnsignedTx, - creds []verify.Verifiable, - ) (ids.ShortID, error) } type Handler interface { @@ -688,13 +683,3 @@ func (h *handler) VerifySpendUTXOs( } return nil } - -func (h *handler) GetPublicKeyForValidatorFilter( - tx txs.UnsignedTx, - creds []verify.Verifiable, -) (ids.ShortID, error) { - if len(creds) != 1 { - return ids.ShortID{}, fmt.Errorf("invalid number of credentials, should only have one") - } - return h.fx.GetPublicKeyForValidatorFilter(tx, creds[0]) -} diff --git a/avalanchego/vms/platformvm/vm_test.go b/avalanchego/vms/platformvm/vm_test.go index b56bd6e9..f5e629da 100644 --- a/avalanchego/vms/platformvm/vm_test.go +++ b/avalanchego/vms/platformvm/vm_test.go @@ -564,7 +564,7 @@ func TestAddValidatorCommit(t *testing.T) { uint64(endTime.Unix()), nodeID, rewardAddress, - reward.PercentDenominator, + 0, []*crypto.PrivateKeySECP256K1R{keys[0]}, ids.ShortEmpty, // change addr ) @@ -623,7 +623,7 @@ func TestInvalidAddValidatorCommit(t *testing.T) { uint64(endTime.Unix()), nodeID, ids.ShortID(nodeID), - reward.PercentDenominator, + 0, []*crypto.PrivateKeySECP256K1R{keys[0]}, ids.ShortEmpty, // change addr ) @@ -682,7 +682,7 @@ func TestAddValidatorReject(t *testing.T) { uint64(endTime.Unix()), nodeID, rewardAddress, - reward.PercentDenominator, + 0, []*crypto.PrivateKeySECP256K1R{keys[0]}, ids.ShortEmpty, // change addr ) @@ -746,7 +746,7 @@ func TestAddValidatorInvalidNotReissued(t *testing.T) { uint64(endTime.Unix()), repeatNodeID, ids.ShortID(repeatNodeID), - reward.PercentDenominator, + 0, []*crypto.PrivateKeySECP256K1R{keys[0]}, ids.ShortEmpty, // change addr ) diff --git a/avalanchego/vms/secp256k1fx/fx.go b/avalanchego/vms/secp256k1fx/fx.go index 9ee0cb36..08dc41b7 100644 --- a/avalanchego/vms/secp256k1fx/fx.go +++ b/avalanchego/vms/secp256k1fx/fx.go @@ -8,7 +8,6 @@ import ( "fmt" "github.com/ava-labs/avalanchego/cache" - "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/utils/crypto" "github.com/ava-labs/avalanchego/utils/hashing" "github.com/ava-labs/avalanchego/utils/wrappers" @@ -207,26 +206,6 @@ func (fx *Fx) VerifyCredentials(utx UnsignedTx, in *Input, cred *Credential, out return nil } -func (fx *Fx) GetPublicKeyForValidatorFilter(txIntf, credIntf interface{}) (ids.ShortID, error) { - utx, ok := txIntf.(UnsignedTx) - if !ok { - return ids.ShortID{}, errWrongTxType - } - cred, ok := credIntf.(*Credential) - if !ok { - return ids.ShortID{}, errWrongCredentialType - } - if len(cred.Sigs) != 1 { - return ids.ShortID{}, fmt.Errorf("invalid number of signatures, should only have one") - } - sig := cred.Sigs[0] - pk, err := fx.SECPFactory.RecoverPublicKey(utx.Bytes(), sig[:]) - if err != nil { - return ids.ShortID{}, err - } - return pk.Address(), nil -} - // CreateOutput creates a new output with the provided control group worth // the specified amount func (fx *Fx) CreateOutput(amount uint64, ownerIntf interface{}) (interface{}, error) { From de33e10c0a28083a7988bc405c72802d39da33e9 Mon Sep 17 00:00:00 2001 From: Sean Rowan <sprwn@protonmail.com> Date: Thu, 27 Apr 2023 10:19:43 -0400 Subject: [PATCH 2/8] Updated validator deployment test --- avalanchego/scripts/test_deploy_validators.sh | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/avalanchego/scripts/test_deploy_validators.sh b/avalanchego/scripts/test_deploy_validators.sh index 132f912c..24eb8bd2 100755 --- a/avalanchego/scripts/test_deploy_validators.sh +++ b/avalanchego/scripts/test_deploy_validators.sh @@ -138,6 +138,27 @@ curl -s --location --request POST 'http://localhost:9650/ext/bc/P' \ sleep 5 +printf "\nAdding new delegator " + +curl -s --location --request POST 'http://localhost:9650/ext/bc/P' \ +--header 'Content-Type: application/json' \ +--data-raw '{ + "jsonrpc": "2.0", + "method": "platform.addDelegator", + "params": { + "nodeId":"NodeID-MFrZFVCXPv5iCn6M9K6XduxGTYp891xXZ", + "startTime":'$START_TIME', + "endTime":'$END_TIME', + "stakeAmount":1000000000000, + "rewardAddress": "P-localflare1pz6dhzxvfmztknw35ukl8fav6gzjt9xwmkngua", + "username": "user1234", + "password": "b39d642078d2ca0517cafe008ddc9326fa1c4d71248078c67bf0d508993720e4" + }, + "id": 1 +}' | jq . + +sleep 5 + printf "\nGet pending validators:\n" curl -s --location --request POST 'http://localhost:9650/ext/bc/P' \ From ef927e9c21008456e86d5fce46713cfb7d112d23 Mon Sep 17 00:00:00 2001 From: Sean Rowan <sprwn@protonmail.com> Date: Sat, 20 May 2023 13:39:56 -0400 Subject: [PATCH 3/8] Added offset to new staked validators being activated --- avalanchego/scripts/test_deploy_validators.sh | 2 +- .../txs/executor/proposal_tx_executor.go | 26 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/avalanchego/scripts/test_deploy_validators.sh b/avalanchego/scripts/test_deploy_validators.sh index 24eb8bd2..3ec42dd5 100755 --- a/avalanchego/scripts/test_deploy_validators.sh +++ b/avalanchego/scripts/test_deploy_validators.sh @@ -49,7 +49,7 @@ sleep 5 printf "\nCreating new validator: NodeID-MFrZFVCXPv5iCn6M9K6XduxGTYp891xXZ " CURR_TIME=$(date +%s) -START_TIME=$(($CURR_TIME+300)) +START_TIME=$(($CURR_TIME+1123200)) END_TIME=$(($START_TIME+1209600)) curl -s --location --request POST 'http://localhost:9650/ext/bc/P' \ diff --git a/avalanchego/vms/platformvm/txs/executor/proposal_tx_executor.go b/avalanchego/vms/platformvm/txs/executor/proposal_tx_executor.go index f2ecebba..d68c28a9 100644 --- a/avalanchego/vms/platformvm/txs/executor/proposal_tx_executor.go +++ b/avalanchego/vms/platformvm/txs/executor/proposal_tx_executor.go @@ -68,20 +68,20 @@ func (*ProposalTxExecutor) CreateSubnetTx(*txs.CreateSubnetTx) error { return er func (*ProposalTxExecutor) ImportTx(*txs.ImportTx) error { return errWrongTxType } func (*ProposalTxExecutor) ExportTx(*txs.ExportTx) error { return errWrongTxType } -// minValidatorStake, maxValidatorStake, minDelegatorStake, minDelegationFee, minStakeDuration, maxStakeDuration, minStakeStartTime +// minValidatorStake, maxValidatorStake, minDelegatorStake, minDelegationFee, minStakeDuration, maxStakeDuration, minFutureStartTimeOffset, minStakeStartTime // The values in this function are not finalised and are placeholders for now -func (e *ProposalTxExecutor) getCurrentInflationSettings(currentTimestamp time.Time) (uint64, uint64, uint64, uint32, time.Duration, time.Duration, time.Time) { +func (e *ProposalTxExecutor) getCurrentInflationSettings(currentTimestamp time.Time) (uint64, uint64, uint64, uint32, time.Duration, time.Duration, time.Duration, time.Time) { switch e.Backend.Ctx.NetworkID { case constants.FlareID: - return 50 * units.KiloAvax, 50 * units.MegaAvax, 1 * units.KiloAvax, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, time.Date(2023, time.June, 28, 15, 0, 0, 0, time.UTC) + return 50 * units.KiloAvax, 50 * units.MegaAvax, 1 * units.KiloAvax, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, 24 * time.Hour, time.Date(2023, time.June, 28, 15, 0, 0, 0, time.UTC) case constants.CostwoID: - return 50 * units.KiloAvax, 50 * units.MegaAvax, 1 * units.KiloAvax, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, time.Date(2023, time.May, 17, 15, 0, 0, 0, time.UTC) + return 50 * units.KiloAvax, 50 * units.MegaAvax, 1 * units.KiloAvax, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, 24 * time.Hour, time.Date(2023, time.May, 17, 15, 0, 0, 0, time.UTC) case constants.StagingID: - return 50 * units.KiloAvax, 50 * units.MegaAvax, 1 * units.KiloAvax, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, time.Date(2023, time.May, 10, 15, 0, 0, 0, time.UTC) + return 50 * units.KiloAvax, 50 * units.MegaAvax, 1 * units.KiloAvax, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, 24 * time.Hour, time.Date(2023, time.May, 10, 15, 0, 0, 0, time.UTC) case constants.LocalFlareID: - return 1, 50 * units.MegaAvax, 1, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, time.Date(2023, time.April, 10, 15, 0, 0, 0, time.UTC) + return 1, 50 * units.MegaAvax, 1, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, 24 * time.Hour, time.Date(2023, time.April, 10, 15, 0, 0, 0, time.UTC) default: - return e.Config.MinValidatorStake, e.Config.MaxValidatorStake, e.Config.MinDelegatorStake, e.Config.MinDelegationFee, e.Config.MinStakeDuration, e.Config.MaxStakeDuration, time.Date(1970, time.January, 1, 0, 0, 0, 0, time.UTC) + return e.Config.MinValidatorStake, e.Config.MaxValidatorStake, e.Config.MinDelegatorStake, e.Config.MinDelegationFee, e.Config.MinStakeDuration, e.Config.MaxStakeDuration, MaxFutureStartTime, time.Date(1970, time.January, 1, 0, 0, 0, 0, time.UTC) } } @@ -97,7 +97,7 @@ func (e *ProposalTxExecutor) AddValidatorTx(tx *txs.AddValidatorTx) error { } currentTimestamp := parentState.GetTimestamp() - minValidatorStake, maxValidatorStake, _, minDelegationFee, minStakeDuration, maxStakeDuration, minStakeStartTime := e.getCurrentInflationSettings(currentTimestamp) + minValidatorStake, maxValidatorStake, _, minDelegationFee, minStakeDuration, maxStakeDuration, minFutureStartTimeOffset, minStakeStartTime := e.getCurrentInflationSettings(currentTimestamp) switch { case tx.Validator.Wght < minValidatorStake: // Ensure validator is staking at least the minimum amount @@ -187,6 +187,14 @@ func (e *ProposalTxExecutor) AddValidatorTx(tx *txs.AddValidatorTx) error { if startTime.After(maxStartTime) { return errFutureStakeTime } + minStartTime := maxStartTime.Add(-minFutureStartTimeOffset) + if startTime.Before(minStartTime) { + return fmt.Errorf( + "validator's start time (%s) at or before minStartTime (%s)", + startTime, + minStartTime, + ) + } } txID := e.Tx.ID() @@ -391,7 +399,7 @@ func (e *ProposalTxExecutor) AddDelegatorTx(tx *txs.AddDelegatorTx) error { } currentTimestamp := parentState.GetTimestamp() - _, maxValidatorStake, minDelegatorStake, _, minStakeDuration, maxStakeDuration, _ := e.getCurrentInflationSettings(currentTimestamp) + _, maxValidatorStake, minDelegatorStake, _, minStakeDuration, maxStakeDuration, _, _ := e.getCurrentInflationSettings(currentTimestamp) duration := tx.Validator.Duration() switch { From fd81b01a6b4fac25f076b08e3bff140700470d94 Mon Sep 17 00:00:00 2001 From: Sean Rowan <sprwn@protonmail.com> Date: Sun, 21 May 2023 09:46:43 -0400 Subject: [PATCH 4/8] getCurrentInflationSettings() updated --- .../vms/platformvm/txs/executor/proposal_tx_executor.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/avalanchego/vms/platformvm/txs/executor/proposal_tx_executor.go b/avalanchego/vms/platformvm/txs/executor/proposal_tx_executor.go index d68c28a9..188f3439 100644 --- a/avalanchego/vms/platformvm/txs/executor/proposal_tx_executor.go +++ b/avalanchego/vms/platformvm/txs/executor/proposal_tx_executor.go @@ -73,11 +73,11 @@ func (*ProposalTxExecutor) ExportTx(*txs.ExportTx) error { return er func (e *ProposalTxExecutor) getCurrentInflationSettings(currentTimestamp time.Time) (uint64, uint64, uint64, uint32, time.Duration, time.Duration, time.Duration, time.Time) { switch e.Backend.Ctx.NetworkID { case constants.FlareID: - return 50 * units.KiloAvax, 50 * units.MegaAvax, 1 * units.KiloAvax, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, 24 * time.Hour, time.Date(2023, time.June, 28, 15, 0, 0, 0, time.UTC) + return 50 * units.KiloAvax, 50 * units.MegaAvax, 1 * units.KiloAvax, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, 24 * time.Hour, time.Date(2023, time.June, 21, 15, 0, 0, 0, time.UTC) case constants.CostwoID: - return 50 * units.KiloAvax, 50 * units.MegaAvax, 1 * units.KiloAvax, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, 24 * time.Hour, time.Date(2023, time.May, 17, 15, 0, 0, 0, time.UTC) + return 50 * units.KiloAvax, 50 * units.MegaAvax, 1 * units.KiloAvax, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, MaxFutureStartTime, time.Date(2023, time.May, 25, 15, 0, 0, 0, time.UTC) case constants.StagingID: - return 50 * units.KiloAvax, 50 * units.MegaAvax, 1 * units.KiloAvax, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, 24 * time.Hour, time.Date(2023, time.May, 10, 15, 0, 0, 0, time.UTC) + return 50 * units.KiloAvax, 50 * units.MegaAvax, 1 * units.KiloAvax, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, MaxFutureStartTime, time.Date(2023, time.May, 10, 15, 0, 0, 0, time.UTC) case constants.LocalFlareID: return 1, 50 * units.MegaAvax, 1, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, 24 * time.Hour, time.Date(2023, time.April, 10, 15, 0, 0, 0, time.UTC) default: From 8a8eb0746ab4639e631193892111caf4c3978acd Mon Sep 17 00:00:00 2001 From: Sean Rowan <sprwn@protonmail.com> Date: Sun, 21 May 2023 10:25:56 -0400 Subject: [PATCH 5/8] Updated version --- avalanchego/version/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avalanchego/version/constants.go b/avalanchego/version/constants.go index 42a935cc..8a2efa99 100644 --- a/avalanchego/version/constants.go +++ b/avalanchego/version/constants.go @@ -14,7 +14,7 @@ var ( Current = &Semantic{ Major: 1, Minor: 7, - Patch: 1803, + Patch: 1804, } CurrentApp = &Application{ Major: Current.Major, From 7bc55f731639e5c2ed0c009855d22e2bb66d8ef9 Mon Sep 17 00:00:00 2001 From: Sean Rowan <sprwn@protonmail.com> Date: Mon, 22 May 2023 08:36:41 -0400 Subject: [PATCH 6/8] getCurrentInflationSettings() updated --- avalanchego/vms/platformvm/txs/executor/proposal_tx_executor.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avalanchego/vms/platformvm/txs/executor/proposal_tx_executor.go b/avalanchego/vms/platformvm/txs/executor/proposal_tx_executor.go index 188f3439..78b32048 100644 --- a/avalanchego/vms/platformvm/txs/executor/proposal_tx_executor.go +++ b/avalanchego/vms/platformvm/txs/executor/proposal_tx_executor.go @@ -73,7 +73,7 @@ func (*ProposalTxExecutor) ExportTx(*txs.ExportTx) error { return er func (e *ProposalTxExecutor) getCurrentInflationSettings(currentTimestamp time.Time) (uint64, uint64, uint64, uint32, time.Duration, time.Duration, time.Duration, time.Time) { switch e.Backend.Ctx.NetworkID { case constants.FlareID: - return 50 * units.KiloAvax, 50 * units.MegaAvax, 1 * units.KiloAvax, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, 24 * time.Hour, time.Date(2023, time.June, 21, 15, 0, 0, 0, time.UTC) + return 50 * units.KiloAvax, 50 * units.MegaAvax, 1 * units.KiloAvax, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, 24 * time.Hour, time.Date(2023, time.July, 5, 15, 0, 0, 0, time.UTC) case constants.CostwoID: return 50 * units.KiloAvax, 50 * units.MegaAvax, 1 * units.KiloAvax, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, MaxFutureStartTime, time.Date(2023, time.May, 25, 15, 0, 0, 0, time.UTC) case constants.StagingID: From 88cbb173385328ed0bb64d235b98efad08a4b59e Mon Sep 17 00:00:00 2001 From: Sean Rowan <sprwn@protonmail.com> Date: Tue, 23 May 2023 10:33:36 -0400 Subject: [PATCH 7/8] getCurrentInflationSettings() updated --- .../vms/platformvm/txs/executor/proposal_tx_executor.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/avalanchego/vms/platformvm/txs/executor/proposal_tx_executor.go b/avalanchego/vms/platformvm/txs/executor/proposal_tx_executor.go index 78b32048..78846df3 100644 --- a/avalanchego/vms/platformvm/txs/executor/proposal_tx_executor.go +++ b/avalanchego/vms/platformvm/txs/executor/proposal_tx_executor.go @@ -73,11 +73,11 @@ func (*ProposalTxExecutor) ExportTx(*txs.ExportTx) error { return er func (e *ProposalTxExecutor) getCurrentInflationSettings(currentTimestamp time.Time) (uint64, uint64, uint64, uint32, time.Duration, time.Duration, time.Duration, time.Time) { switch e.Backend.Ctx.NetworkID { case constants.FlareID: - return 50 * units.KiloAvax, 50 * units.MegaAvax, 1 * units.KiloAvax, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, 24 * time.Hour, time.Date(2023, time.July, 5, 15, 0, 0, 0, time.UTC) + return 100 * units.KiloAvax, 50 * units.MegaAvax, 1 * units.KiloAvax, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, 24 * time.Hour, time.Date(2023, time.July, 5, 15, 0, 0, 0, time.UTC) case constants.CostwoID: - return 50 * units.KiloAvax, 50 * units.MegaAvax, 1 * units.KiloAvax, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, MaxFutureStartTime, time.Date(2023, time.May, 25, 15, 0, 0, 0, time.UTC) + return 100 * units.KiloAvax, 50 * units.MegaAvax, 1 * units.KiloAvax, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, MaxFutureStartTime, time.Date(2023, time.May, 25, 15, 0, 0, 0, time.UTC) case constants.StagingID: - return 50 * units.KiloAvax, 50 * units.MegaAvax, 1 * units.KiloAvax, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, MaxFutureStartTime, time.Date(2023, time.May, 10, 15, 0, 0, 0, time.UTC) + return 100 * units.KiloAvax, 50 * units.MegaAvax, 1 * units.KiloAvax, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, MaxFutureStartTime, time.Date(2023, time.May, 10, 15, 0, 0, 0, time.UTC) case constants.LocalFlareID: return 1, 50 * units.MegaAvax, 1, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, 24 * time.Hour, time.Date(2023, time.April, 10, 15, 0, 0, 0, time.UTC) default: From dab89fd9ff5a0c7f42fef58444e1d4551ad7c286 Mon Sep 17 00:00:00 2001 From: Sean Rowan <sprwn@protonmail.com> Date: Tue, 23 May 2023 10:48:53 -0400 Subject: [PATCH 8/8] getCurrentInflationSettings() updated --- .../txs/executor/proposal_tx_executor.go | 47 ++++++++++++++++--- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/avalanchego/vms/platformvm/txs/executor/proposal_tx_executor.go b/avalanchego/vms/platformvm/txs/executor/proposal_tx_executor.go index 78846df3..eba804bf 100644 --- a/avalanchego/vms/platformvm/txs/executor/proposal_tx_executor.go +++ b/avalanchego/vms/platformvm/txs/executor/proposal_tx_executor.go @@ -68,20 +68,53 @@ func (*ProposalTxExecutor) CreateSubnetTx(*txs.CreateSubnetTx) error { return er func (*ProposalTxExecutor) ImportTx(*txs.ImportTx) error { return errWrongTxType } func (*ProposalTxExecutor) ExportTx(*txs.ExportTx) error { return errWrongTxType } -// minValidatorStake, maxValidatorStake, minDelegatorStake, minDelegationFee, minStakeDuration, maxStakeDuration, minFutureStartTimeOffset, minStakeStartTime -// The values in this function are not finalised and are placeholders for now func (e *ProposalTxExecutor) getCurrentInflationSettings(currentTimestamp time.Time) (uint64, uint64, uint64, uint32, time.Duration, time.Duration, time.Duration, time.Time) { switch e.Backend.Ctx.NetworkID { case constants.FlareID: - return 100 * units.KiloAvax, 50 * units.MegaAvax, 1 * units.KiloAvax, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, 24 * time.Hour, time.Date(2023, time.July, 5, 15, 0, 0, 0, time.UTC) + return 100 * units.KiloAvax, // minValidatorStake + 50 * units.MegaAvax, // maxValidatorStake + 1 * units.KiloAvax, // minDelegatorStake + 0, // minDelegationFee + 2 * 7 * 24 * time.Hour, // minStakeDuration + 365 * 24 * time.Hour, // maxStakeDuration + 24 * time.Hour, // minFutureStartTimeOffset + time.Date(2023, time.July, 5, 15, 0, 0, 0, time.UTC) // minStakeStartTime case constants.CostwoID: - return 100 * units.KiloAvax, 50 * units.MegaAvax, 1 * units.KiloAvax, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, MaxFutureStartTime, time.Date(2023, time.May, 25, 15, 0, 0, 0, time.UTC) + return 100 * units.KiloAvax, + 50 * units.MegaAvax, + 1 * units.KiloAvax, + 0, + 2 * 7 * 24 * time.Hour, + 365 * 24 * time.Hour, + MaxFutureStartTime, + time.Date(2023, time.May, 25, 15, 0, 0, 0, time.UTC) case constants.StagingID: - return 100 * units.KiloAvax, 50 * units.MegaAvax, 1 * units.KiloAvax, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, MaxFutureStartTime, time.Date(2023, time.May, 10, 15, 0, 0, 0, time.UTC) + return 100 * units.KiloAvax, + 50 * units.MegaAvax, + 1 * units.KiloAvax, + 0, + 2 * 7 * 24 * time.Hour, + 365 * 24 * time.Hour, + MaxFutureStartTime, + time.Date(2023, time.May, 10, 15, 0, 0, 0, time.UTC) case constants.LocalFlareID: - return 1, 50 * units.MegaAvax, 1, 0, 2 * 7 * 24 * time.Hour, 365 * 24 * time.Hour, 24 * time.Hour, time.Date(2023, time.April, 10, 15, 0, 0, 0, time.UTC) + return 1, + 50 * units.MegaAvax, + 1, + 0, + 2 * 7 * 24 * time.Hour, + 365 * 24 * time.Hour, + 24 * time.Hour, + time.Date(2023, time.April, 10, 15, 0, 0, 0, time.UTC) default: - return e.Config.MinValidatorStake, e.Config.MaxValidatorStake, e.Config.MinDelegatorStake, e.Config.MinDelegationFee, e.Config.MinStakeDuration, e.Config.MaxStakeDuration, MaxFutureStartTime, time.Date(1970, time.January, 1, 0, 0, 0, 0, time.UTC) + return e.Config.MinValidatorStake, + e.Config.MaxValidatorStake, + e.Config.MinDelegatorStake, + e.Config.MinDelegationFee, + e.Config.MinStakeDuration, + e.Config.MaxStakeDuration, + MaxFutureStartTime, + time.Date(1970, time.January, 1, 0, 0, 0, 0, time.UTC) } }