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

v1.7.1804 Inflation-Based Staking #11

Merged
merged 8 commits into from
May 23, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
103 changes: 11 additions & 92 deletions avalanchego/scripts/test_deploy_validators.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ sleep 5
printf "\nCreating new validator: NodeID-MFrZFVCXPv5iCn6M9K6XduxGTYp891xXZ "

CURR_TIME=$(date +%s)
START_TIME=$(($CURR_TIME+300))
END_TIME=$(($START_TIME+86400))
START_TIME=$(($CURR_TIME+1123200))
END_TIME=$(($START_TIME+1209600))

curl -s --location --request POST 'http://localhost:9650/ext/bc/P' \
--header 'Content-Type: application/json' \
Expand All @@ -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"
},
Expand All @@ -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"
},
Expand All @@ -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"
},
Expand All @@ -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"
},
Expand All @@ -138,36 +138,19 @@ curl -s --location --request POST 'http://localhost:9650/ext/bc/P' \

sleep 5

printf "\nGet pending validators:\n"
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.getPendingValidators",
"method": "platform.addDelegator",
"params": {
"subnetID": null,
"nodeIDs": []
},
"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",
"nodeId":"NodeID-MFrZFVCXPv5iCn6M9K6XduxGTYp891xXZ",
"startTime":'$START_TIME',
"endTime":'$END_TIME',
"stakeAmount": 10000000000000,
"stakeAmount":1000000000000,
"rewardAddress": "P-localflare1pz6dhzxvfmztknw35ukl8fav6gzjt9xwmkngua",
"delegationFeeRate":10,
"username": "user1234",
"password": "b39d642078d2ca0517cafe008ddc9326fa1c4d71248078c67bf0d508993720e4"
},
Expand All @@ -176,70 +159,6 @@ curl -s --location --request POST 'http://localhost:9650/ext/bc/P' \

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' \
Expand All @@ -252,6 +171,6 @@ curl -s --location --request POST 'http://localhost:9650/ext/bc/P' \
"nodeIDs": []
},
"id": 1
}' | jq .result
}' | jq .

printf "\nNew validators will start in $(($START_TIME-$(date +%s))) seconds\n"
86 changes: 0 additions & 86 deletions avalanchego/utils/constants/validator_config.go

This file was deleted.

11 changes: 0 additions & 11 deletions avalanchego/utils/hashing/hashing.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package hashing

import (
"crypto/sha256"
"encoding/hex"
"fmt"
"io"

Expand Down Expand Up @@ -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[:])
}
40 changes: 0 additions & 40 deletions avalanchego/utils/hashing/hashing_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion avalanchego/version/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var (
Current = &Semantic{
Major: 1,
Minor: 7,
Patch: 1803,
Patch: 1804,
}
CurrentApp = &Application{
Major: Current.Major,
Expand Down
4 changes: 0 additions & 4 deletions avalanchego/vms/platformvm/fx/fx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down