Commit 3d1145f
fix(pallet-tfgrid): enforce node_certification in farming policy limits (#1087)
* fix(pallet-tfgrid): enforce node_certification in farming policy limits
## Problem
The FarmingPolicyLimit.node_certification field was never enforced in
get_farming_policy(). Per the spec (docs/misc/minimal_DAO.md):
> Certification. If set, only certified nodes can get this policy.
> Non certified nodes get a default policy.
A Diy node on a farm with node_certification=true in its limits would
receive the certified-only policy instead of falling back to a default.
On mainnet, farm 2995 (GoldAndGreen) has 4 Diy nodes (2 currently
online) earning certified-level farming rewards on policy 3.
## Root Cause
Two issues:
1. No certification check in the FarmingPolicyLimit path of
get_farming_policy() — limits only checked end, cu, su, node_count.
2. get_default_farming_policy() (called when limits are exhausted)
ignored node/farm certification entirely — it just picked the
highest-ranked default policy regardless of the node's actual
certification. Per the spec, default policy selection should follow:
- First: highest farm cert + certified nodes
- Then: highest farm cert + non-certified nodes
- Then: no farm cert + certified nodes
- Last: no certification at all
## Fix
- Add node_certification check at the start of the limits path: Diy
nodes on certified-only farms fall back to a matching default.
- Replace get_default_farming_policy() with get_default_farming_policy_for()
that filters by both node_certification and farm_certification. This
affects all 4 existing fallback paths (end expired, cu exceeded, su
exceeded, node_count exhausted) plus the new certification check.
## Tests
- diy_node_gets_default_policy_when_limit_requires_certification:
Diy node on Gold farm with node_certification=true gets policy 1
(Diy+Gold default) instead of policy 3 (Certified+Gold limited)
- certified_node_gets_limited_policy_when_limit_requires_certification:
Certified node correctly receives the limited policy
- diy_node_gets_limited_policy_when_no_certification_required:
Diy node gets limited policy when node_certification=false
## Migration Note
This fix only affects future policy assignments. The 4 Diy nodes on
mainnet farm 2995 currently assigned policy 3 need a migration or
manual set_node_certification call to trigger re-evaluation.
Fixes #429
* fix(ci): use $GITHUB_WORKSPACE for git safe.directory in weights workflow (#1091)
The repository rename (tfchain -> ledger_chain) changed the runner checkout
path to /__w/ledger_chain/ledger_chain, but the safe.directory exception was
hardcoded to /__w/tfchain/tfchain, so git still rejected the repo with
"detected dubious ownership" (exit 128) at the Git config step.
Use $GITHUB_WORKSPACE so the exception always matches the real checkout path,
regardless of repository name.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 0274227 commit 3d1145f
2 files changed
Lines changed: 159 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | | - | |
| 199 | + | |
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
205 | 214 | | |
206 | 215 | | |
207 | 216 | | |
208 | 217 | | |
209 | 218 | | |
210 | | - | |
| 219 | + | |
211 | 220 | | |
212 | 221 | | |
213 | 222 | | |
| |||
217 | 226 | | |
218 | 227 | | |
219 | 228 | | |
220 | | - | |
| 229 | + | |
221 | 230 | | |
222 | 231 | | |
223 | 232 | | |
| |||
228 | 237 | | |
229 | 238 | | |
230 | 239 | | |
231 | | - | |
| 240 | + | |
232 | 241 | | |
233 | 242 | | |
234 | 243 | | |
| |||
238 | 247 | | |
239 | 248 | | |
240 | 249 | | |
241 | | - | |
| 250 | + | |
242 | 251 | | |
243 | 252 | | |
244 | 253 | | |
| |||
288 | 297 | | |
289 | 298 | | |
290 | 299 | | |
291 | | - | |
292 | | - | |
293 | | - | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
294 | 305 | | |
295 | 306 | | |
296 | 307 | | |
297 | 308 | | |
298 | 309 | | |
299 | | - | |
300 | | - | |
301 | 310 | | |
302 | 311 | | |
303 | 312 | | |
304 | 313 | | |
305 | | - | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
306 | 319 | | |
307 | 320 | | |
308 | 321 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1783 | 1783 | | |
1784 | 1784 | | |
1785 | 1785 | | |
| 1786 | + | |
| 1787 | + | |
| 1788 | + | |
| 1789 | + | |
| 1790 | + | |
| 1791 | + | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
| 1796 | + | |
| 1797 | + | |
| 1798 | + | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
| 1806 | + | |
| 1807 | + | |
| 1808 | + | |
| 1809 | + | |
| 1810 | + | |
| 1811 | + | |
| 1812 | + | |
| 1813 | + | |
| 1814 | + | |
| 1815 | + | |
| 1816 | + | |
| 1817 | + | |
| 1818 | + | |
| 1819 | + | |
| 1820 | + | |
| 1821 | + | |
| 1822 | + | |
| 1823 | + | |
| 1824 | + | |
| 1825 | + | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
| 1829 | + | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
| 1846 | + | |
| 1847 | + | |
| 1848 | + | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
| 1871 | + | |
| 1872 | + | |
| 1873 | + | |
| 1874 | + | |
| 1875 | + | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
| 1882 | + | |
| 1883 | + | |
| 1884 | + | |
| 1885 | + | |
| 1886 | + | |
| 1887 | + | |
| 1888 | + | |
| 1889 | + | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
| 1894 | + | |
| 1895 | + | |
| 1896 | + | |
| 1897 | + | |
| 1898 | + | |
| 1899 | + | |
| 1900 | + | |
| 1901 | + | |
| 1902 | + | |
| 1903 | + | |
| 1904 | + | |
| 1905 | + | |
| 1906 | + | |
| 1907 | + | |
| 1908 | + | |
| 1909 | + | |
| 1910 | + | |
| 1911 | + | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
| 1918 | + | |
| 1919 | + | |
| 1920 | + | |
1786 | 1921 | | |
1787 | 1922 | | |
1788 | 1923 | | |
| |||
0 commit comments