Skip to content

sui_v1.27.0_1717217141_ci

@stefan-mysten stefan-mysten tagged this 01 Jun 01:17
## Description 

This PR fixes the APY for a validator and ensures that historical APYs
can be computed. It also reverts some changes in the `governance_api`,
particularly moves `exchange_rates` as a free function that can be
called from the GraphQL crate.

At system start, the task to trigger the exchange rates cache is
executed, thus until the next trigger on epoch change, the apys can be
fetched pretty fast (~2-3s for the standard 5 items per page).

## Test plan 
Updated test. Manual tests and queries.

Response time: ~1s
```graphql
{
  epoch {
    epochId
    referenceGasPrice
    validatorSet {
      totalStake
      inactivePoolsSize
      activeValidators(first: 5) {
        nodes {
          name
          apy
        }
      }
    }
  }
}
```

```json
{
  "data": {
    "epoch": {
      "epochId": 405,
      "referenceGasPrice": "751",
      "validatorSet": {
        "totalStake": "8163113083622628156",
        "inactivePoolsSize": 4,
        "activeValidators": {
          "nodes": [
            {
              "name": "ComingChat",
              "apy": 310
            },
            {
              "name": "InfStones",
              "apy": 302
            },
            {
              "name": "Gaucho",
              "apy": 310
            },
            {
              "name": "Astro-Stakers",
              "apy": 310
            },
            {
              "name": "H2O Nodes",
              "apy": 310
            }
          ]
        }
      }
    }
  }
}
```

Response time for this query: ~2s
```graphql 
{
  epoch(id: 127){
    epochId
    referenceGasPrice
    validatorSet {
      totalStake
      inactivePoolsSize
      activeValidators {
        nodes {
          name
          apy
        }
      }
    }
  }
}
```

```json
{
  "data": {
    "epoch": {
      "epochId": 127,
      "referenceGasPrice": "765",
      "validatorSet": {
        "totalStake": "7437800674887300328",
        "inactivePoolsSize": 2,
        "activeValidators": {
          "nodes": [
            {
              "name": "ComingChat",
              "apy": 480
            },
            {
              "name": "InfStones",
              "apy": 471
            },
            {
              "name": "Gaucho",
              "apy": 471
            },
            {
              "name": "Astro-Stakers",
              "apy": 485
            },
            {
              "name": "H2O Nodes",
              "apy": 471
            }
          ]
        }
      }
    }
  }
}
```

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
Assets 2
Loading