Skip to content

Commit a53c05d

Browse files
D4ryl00jefft0zivkovicmilos
authored
feat: refactor r/gnoland/valopers to remove r/sys/validators dependency (#3830)
fixes #3567 Objectives: - [x] The `/r/gnoland/valopers` should not have the dependency on `/r/sys/validators`. So a new realm will do the glue between the `valopers` realm and the `validators` valset. - [x] remove dependency - [x] write glue contract - [x] write glue contract tests - [x] As an admin, I can edit the instructions to register a new valoper, espacially for what to put in the description field. So a public function is needed to update the instructions and an administration mechanism to restrict calls. - [x] Change the API to be able to call valopers' functions directly with a JS frontend (Connect, Adena), in one call. So we have to only use primitive types on parameters and remove objects. We also have to create new functions to update valopers for the desired fields. - [x] Make functions more robust by implementing parameter validation. - [x] Add protection on update functions so only the original caller can update its valoper. - [x] Prevent SPAM by the need of sending coins when you want to register as a valoper. - [x] Enhance the Render function with a pagination feature. Process to be a validator: 1) Register your validator node as a `Valoper` with the `r/gnolang/valopers.Register` function. Follow the instructions set in the `Instructions` global variable (to be done). 2) When you think your valoper is ready, make a GovDao proposal to add it to the validator valset with `/r/gnoland/valopers_proposal.MakeProposal`. In local environment, the two steps can be done by: ``` gnokey maketx call \ -pkgpath "gno.land/r/gnoland/valopers" \ -func "Register" \ -gas-fee 1000000ugnot \ -gas-wanted 30000000 \ -send "20000000ugnot" \ -broadcast \ -chainid "dev" \ -args "berty" \ -args "Berty's validator description" \ -args "g1ut590acnamvhkrh4qz6dz9zt9e3hyu499u0gvl" \ -args "gpub1pgfj7ard9eg82cjtv4u4xetrwqer2dntxyfzxz3pq0skzdkmzu0r9h6gny6eg8c9dc303xrrudee6z4he4y7cs5rnjwmyf40yaj" \ -remote "tcp://127.0.0.1:26657" \ test1 gnokey maketx call \ -pkgpath "gno.land/r/gnoland/valopers_proposal" \ -func "ProposeNewValidator" \ -gas-fee 1000000ugnot \ -gas-wanted 20000000 \ -send "100000000ugnot" \ -broadcast \ -chainid "dev" \ -args "g1ut590acnamvhkrh4qz6dz9zt9e3hyu499u0gvl" \ -remote "tcp://127.0.0.1:26657" \ test1 ``` --------- Signed-off-by: D4ryl00 <[email protected]> Signed-off-by: Jeff Thompson <[email protected]> Co-authored-by: Jeff Thompson <[email protected]> Co-authored-by: Miloš Živković <[email protected]>
1 parent b6c5524 commit a53c05d

19 files changed

+1594
-347
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package valopers
2+
3+
import (
4+
"std"
5+
6+
"gno.land/p/demo/dao"
7+
"gno.land/p/moul/authz"
8+
"gno.land/r/gov/dao/bridge"
9+
)
10+
11+
var auth *authz.Authorizer
12+
13+
func Auth() *authz.Authorizer {
14+
return auth
15+
}
16+
17+
func updateInstructions(newInstructions string) {
18+
err := auth.Do("update-instructions", func() error {
19+
instructions = newInstructions
20+
return nil
21+
})
22+
23+
if err != nil {
24+
panic(err)
25+
}
26+
}
27+
28+
func updateMinFee(newMinFee int64) {
29+
err := auth.Do("update-min-fee", func() error {
30+
minFee = std.NewCoin("ugnot", newMinFee)
31+
return nil
32+
})
33+
34+
if err != nil {
35+
panic(err)
36+
}
37+
}
38+
39+
func NewInstructionsExecutor(newInstructions string) dao.Executor {
40+
cb := func() error {
41+
updateInstructions(newInstructions)
42+
return nil
43+
}
44+
45+
return bridge.GovDAO().NewGovDAOExecutor(cb)
46+
}
47+
48+
func NewMinFeeExecutor(newMinFee int64) dao.Executor {
49+
cb := func() error {
50+
updateMinFee(newMinFee)
51+
return nil
52+
}
53+
54+
return bridge.GovDAO().NewGovDAOExecutor(cb)
55+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package valopers
2+
3+
import (
4+
"std"
5+
"testing"
6+
7+
"gno.land/p/demo/uassert"
8+
"gno.land/p/moul/authz"
9+
)
10+
11+
func TestUpdateInstructions(t *testing.T) {
12+
auth = authz.NewWithAuthority(
13+
authz.NewContractAuthority(
14+
"gno.land/r/gov/dao/v2",
15+
func(title string, action authz.PrivilegedAction) error {
16+
return action()
17+
},
18+
),
19+
)
20+
21+
newInstructions := "new instructions"
22+
23+
uassert.PanicsWithMessage(t, "action can only be executed by the contract", func() {
24+
updateInstructions(newInstructions)
25+
})
26+
27+
std.TestSetOriginCaller(std.DerivePkgAddr("gno.land/r/gov/dao/v2"))
28+
29+
uassert.NotPanics(t, func() {
30+
updateInstructions(newInstructions)
31+
})
32+
33+
uassert.Equal(t, newInstructions, instructions)
34+
}
35+
36+
func TestUpdateMinFee(t *testing.T) {
37+
auth = authz.NewWithAuthority(
38+
authz.NewContractAuthority(
39+
"gno.land/r/gov/dao/v2",
40+
func(title string, action authz.PrivilegedAction) error {
41+
return action()
42+
},
43+
),
44+
)
45+
46+
newMinFee := int64(100)
47+
48+
uassert.PanicsWithMessage(t, "action can only be executed by the contract", func() {
49+
updateMinFee(newMinFee)
50+
})
51+
52+
std.TestSetOriginCaller(std.DerivePkgAddr("gno.land/r/gov/dao/v2"))
53+
54+
uassert.NotPanics(t, func() {
55+
updateMinFee(newMinFee)
56+
})
57+
58+
uassert.Equal(t, newMinFee, minFee.Amount)
59+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module gno.land/r/gnoland/valopers
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package valopers
2+
3+
import (
4+
"gno.land/p/demo/avl"
5+
"gno.land/p/moul/authz"
6+
)
7+
8+
func init() {
9+
valopers = avl.NewTree()
10+
11+
auth = authz.NewWithAuthority(
12+
authz.NewContractAuthority(
13+
"gno.land/r/gov/dao/v2",
14+
func(title string, action authz.PrivilegedAction) error {
15+
return action()
16+
},
17+
),
18+
)
19+
20+
instructions = `
21+
# Welcome to the **Valopers** realm
22+
23+
## 📌 Purpose of this Contract
24+
25+
The **Valopers** contract is designed to maintain a registry of **validator profiles**. This registry provides essential information to **GovDAO members**, enabling them to make informed decisions when voting on the inclusion of new validators into the **valset**.
26+
27+
By registering your validator profile, you contribute to a transparent and well-informed governance process within **gno.land**.
28+
29+
---
30+
31+
## 📝 How to Register Your Validator Node
32+
33+
To add your validator node to the registry, use the **Register** function with the following parameters:
34+
35+
- **Moniker** (Validator Name)
36+
- Must be **human-readable**
37+
- **Max length**: **32 characters**
38+
- **Allowed characters**: Letters, numbers, spaces, hyphens (**-**), and underscores (**_**)
39+
- **No special characters** at the beginning or end
40+
41+
- **Description** (Introduction & Validator Details)
42+
- **Max length**: **2048 characters**
43+
- Must include answers to the questions listed below
44+
45+
- **Validator Address**
46+
- Your validator node’s address
47+
48+
- **Validator Public Key**
49+
- Your validator node’s public key
50+
51+
### ✍️ Required Information for the Description
52+
53+
Please provide detailed answers to the following questions to ensure transparency and improve your chances of being accepted:
54+
55+
1. The name of your validator
56+
2. Networks you are currently validating and your total AuM (assets under management)
57+
3. Links to your **digital presence** (website, social media, etc.).
58+
4. Contact details
59+
5. Why are you interested in validating on **gno.land**?
60+
6. What contributions have you made or are willing to make to **gno.land**?
61+
62+
---
63+
64+
## 🔄 Updating Your Validator Information
65+
66+
After registration, you can update your validator details using the **update functions** provided by the contract.
67+
68+
---
69+
70+
## 📢 Submitting a Proposal to Join the Validator Set
71+
72+
Once you're satisfied with your **valoper** profile, you can propose your inclusion into the validator set. To do so, execute the following function: **r/gnoland/valopers_proposal.MakeProposal**
73+
74+
This will initiate a governance process where **GovDAO** members will vote on your proposal.
75+
76+
---
77+
78+
🚀 **Register now and become a part of gno.land’s validator ecosystem!**
79+
80+
---
81+
82+
`
83+
}

examples/gno.land/r/gnoland/valopers/v2/gno.mod

-1
This file was deleted.

examples/gno.land/r/gnoland/valopers/v2/init.gno

-7
This file was deleted.

0 commit comments

Comments
 (0)