Skip to content

Commit a85a53d

Browse files
piux2zivkovicmilos
andauthored
fix: prevent false positive return for guarding dao member store (#3121)
If we want to guard the MemStore by checking the active DAO realm, m.daoPkgPath must first be assigned a realm package path; otherwise, the isCallerDAORealm() method may return a false positive, failing to protect the MemStore. <!-- please provide a detailed description of the changes made in this pull request. --> <details><summary>Contributors' checklist...</summary> - [ ] Added new tests, or not needed, or not feasible - [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [ ] Updated the official documentation or not needed - [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [ ] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests </details> --------- Co-authored-by: Miloš Živković <[email protected]>
1 parent 6f48a5b commit a85a53d

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

examples/gno.land/p/demo/membstore/membstore.gno

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,5 +205,5 @@ func (m *MembStore) TotalPower() uint64 {
205205
// the API of the member store is public and callable
206206
// by anyone who has a reference to the member store instance.
207207
func (m *MembStore) isCallerDAORealm() bool {
208-
return m.daoPkgPath == "" || std.CurrentRealm().PkgPath() == m.daoPkgPath
208+
return m.daoPkgPath != "" && std.CurrentRealm().PkgPath() == m.daoPkgPath
209209
}

examples/gno.land/r/gov/dao/v2/dao.gno

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ var (
1313
members membstore.MemberStore // the member store
1414
)
1515

16+
const daoPkgPath = "gno.land/r/gov/dao/v2"
17+
1618
func init() {
1719
// Example initial member set (just test addresses)
1820
set := []membstore.Member{
@@ -23,7 +25,7 @@ func init() {
2325
}
2426

2527
// Set the member store
26-
members = membstore.NewMembStore(membstore.WithInitialMembers(set))
28+
members = membstore.NewMembStore(membstore.WithInitialMembers(set), membstore.WithDAOPkgPath(daoPkgPath))
2729

2830
// Set the DAO implementation
2931
d = simpledao.New(members)

0 commit comments

Comments
 (0)