Skip to content

Commit

Permalink
Merge pull request #14 from flare-foundation/v1.7.1805
Browse files Browse the repository at this point in the history
v1.7.1805
  • Loading branch information
sprwn authored Jun 5, 2023
2 parents 4c99e8f + 54ca1c3 commit 8eba01f
Show file tree
Hide file tree
Showing 5 changed files with 174 additions and 11 deletions.
2 changes: 1 addition & 1 deletion avalanchego/genesis/genesis_localFlare.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
]
}
],
"startTime": 1654056000,
"startTime": 1685592000,
"initialStakeDuration": 31536000,
"initialStakeDurationOffset": 5400,
"initialStakedFunds": [
Expand Down
2 changes: 1 addition & 1 deletion avalanchego/genesis/genesis_staging.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
]
}
],
"startTime": 1654056000,
"startTime": 1685592000,
"initialStakeDuration": 31536000,
"initialStakeDurationOffset": 5400,
"initialStakedFunds": [
Expand Down
160 changes: 157 additions & 3 deletions avalanchego/scripts/test_deploy_validators.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ sleep 5
printf "\nCreating new validator: NodeID-MFrZFVCXPv5iCn6M9K6XduxGTYp891xXZ "

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

curl -s --location --request POST 'http://localhost:9650/ext/bc/P' \
Expand Down Expand Up @@ -149,7 +149,161 @@ curl -s --location --request POST 'http://localhost:9650/ext/bc/P' \
"nodeId":"NodeID-MFrZFVCXPv5iCn6M9K6XduxGTYp891xXZ",
"startTime":'$START_TIME',
"endTime":'$END_TIME',
"stakeAmount":1000000000000,
"stakeAmount":10000000000000,
"rewardAddress": "P-localflare1pz6dhzxvfmztknw35ukl8fav6gzjt9xwmkngua",
"username": "user1234",
"password": "b39d642078d2ca0517cafe008ddc9326fa1c4d71248078c67bf0d508993720e4"
},
"id": 1
}' | jq .

sleep 5
printf "\nTesting validator creation with non-permitted parameters:"
printf "\nAttempting to create invalid validator (weight too low): 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": 1,
"rewardAddress": "P-localflare1pz6dhzxvfmztknw35ukl8fav6gzjt9xwmkngua",
"delegationFeeRate":10,
"username": "user1234",
"password": "b39d642078d2ca0517cafe008ddc9326fa1c4d71248078c67bf0d508993720e4"
},
"id": 1
}' | jq .

sleep 5

printf "\nAttempting to create invalid validator (weight too low): 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": 1,
"rewardAddress": "P-localflare1pz6dhzxvfmztknw35ukl8fav6gzjt9xwmkngua",
"delegationFeeRate":10,
"username": "user1234",
"password": "b39d642078d2ca0517cafe008ddc9326fa1c4d71248078c67bf0d508993720e4"
},
"id": 1
}' | jq .

sleep 5

printf "\nAttempting to create invalid validator (weight too low): 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": 1,
"rewardAddress": "P-localflare1pz6dhzxvfmztknw35ukl8fav6gzjt9xwmkngua",
"delegationFeeRate":10,
"username": "user1234",
"password": "b39d642078d2ca0517cafe008ddc9326fa1c4d71248078c67bf0d508993720e4"
},
"id": 1
}' | jq .

sleep 5

printf "\nAttempting to create invalid validator (weight too low): 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": 1,
"rewardAddress": "P-localflare1pz6dhzxvfmztknw35ukl8fav6gzjt9xwmkngua",
"delegationFeeRate":10,
"username": "user1234",
"password": "b39d642078d2ca0517cafe008ddc9326fa1c4d71248078c67bf0d508993720e4"
},
"id": 1
}' | jq .

sleep 5

printf "\nAttempting to create invalid delegation (weight too low)"

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-NFBbbJ4qCmNaCzeW7sxErhvWqvEQMnYcN",
"startTime":'$START_TIME',
"endTime":'$END_TIME',
"stakeAmount":1,
"rewardAddress": "P-localflare1pz6dhzxvfmztknw35ukl8fav6gzjt9xwmkngua",
"username": "user1234",
"password": "b39d642078d2ca0517cafe008ddc9326fa1c4d71248078c67bf0d508993720e4"
},
"id": 1
}' | jq .

sleep 5

CURR_TIME=$(date +%s)
START_TIME=$(($CURR_TIME+300))
printf "\nAttempting to create invalid validator (start time too early): 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 delegation (start time too early)"

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":10000000000000,
"rewardAddress": "P-localflare1pz6dhzxvfmztknw35ukl8fav6gzjt9xwmkngua",
"username": "user1234",
"password": "b39d642078d2ca0517cafe008ddc9326fa1c4d71248078c67bf0d508993720e4"
Expand All @@ -173,4 +327,4 @@ curl -s --location --request POST 'http://localhost:9650/ext/bc/P' \
"id": 1
}' | jq .

printf "\nNew validators will start in $(($START_TIME-$(date +%s))) seconds\n"
printf "\nNew validators will start in $(($START_TIME-$(date +%s))) seconds\n"
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: 1804,
Patch: 1805,
}
CurrentApp = &Application{
Major: Current.Major,
Expand Down
19 changes: 14 additions & 5 deletions avalanchego/vms/platformvm/txs/executor/proposal_tx_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,17 @@ func (*ProposalTxExecutor) CreateSubnetTx(*txs.CreateSubnetTx) error { return er
func (*ProposalTxExecutor) ImportTx(*txs.ImportTx) error { return errWrongTxType }
func (*ProposalTxExecutor) ExportTx(*txs.ExportTx) error { return errWrongTxType }

// The value of currentTimestamp is used to return new inflation settings over 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 100 * units.KiloAvax, // minValidatorStake
return 10 * units.MegaAvax, // 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
3 * 24 * time.Hour, // minFutureStartTimeOffset
time.Date(2023, time.July, 5, 15, 0, 0, 0, time.UTC) // minStakeStartTime
case constants.CostwoID:
return 100 * units.KiloAvax,
Expand All @@ -98,9 +99,9 @@ func (e *ProposalTxExecutor) getCurrentInflationSettings(currentTimestamp time.T
MaxFutureStartTime,
time.Date(2023, time.May, 10, 15, 0, 0, 0, time.UTC)
case constants.LocalFlareID:
return 1,
return 10 * units.KiloAvax,
50 * units.MegaAvax,
1,
10 * units.KiloAvax,
0,
2 * 7 * 24 * time.Hour,
365 * 24 * time.Hour,
Expand Down Expand Up @@ -432,7 +433,7 @@ func (e *ProposalTxExecutor) AddDelegatorTx(tx *txs.AddDelegatorTx) error {
}
currentTimestamp := parentState.GetTimestamp()

_, maxValidatorStake, minDelegatorStake, _, minStakeDuration, maxStakeDuration, _, _ := e.getCurrentInflationSettings(currentTimestamp)
_, maxValidatorStake, minDelegatorStake, _, minStakeDuration, maxStakeDuration, minFutureStartTimeOffset, _ := e.getCurrentInflationSettings(currentTimestamp)

duration := tx.Validator.Duration()
switch {
Expand Down Expand Up @@ -517,6 +518,14 @@ func (e *ProposalTxExecutor) AddDelegatorTx(tx *txs.AddDelegatorTx) error {
if validatorStartTime.After(maxStartTime) {
return errFutureStakeTime
}
minStartTime := maxStartTime.Add(-minFutureStartTimeOffset)
if validatorStartTime.Before(minStartTime) {
return fmt.Errorf(
"validator's start time (%s) at or before minStartTime (%s)",
validatorStartTime,
minStartTime,
)
}
}

// Set up the state if this tx is committed
Expand Down

0 comments on commit 8eba01f

Please sign in to comment.