Two proposals to update the `claim-rewards` wasm tx on-chain

Overview
We need to update the claim-rewards wasm tx in the Namada on-chain storage. But first, we need to also increase the max_block_gas in the protocol parameters, which restricts the maximum allowable combined gas of all txs in a block.

Why
The new new claim-rewards tx simply has the addition that it will emit an event containing the claimed token amount in the tx that can then be consumed by an indexer. Some service providers and custodians are relying on this in order to easily track reward amounts claimed. It is more difficult to change this at the protocol level and would likely require an upgrade if done so, so this is the easiest and most effective solution.

However, because the wasm code in the governance proposal is large (due to contaning the bytes of code for the new wasm to write into storage), it currently requires ~4.3M gas in order to execute the init-proposal tx to initialize the proposal. The current maximum allowed gas in a block is 3M gas, though. Thus, we must first raise the max block gas.

Proposal details

  1. Increase the max_block_gas from 3M to 5M.
  2. Initialize proposal to write the new claim-rewards tx into storage. The code that executes this step can be viewed here.

Validation
Both of these proposals have already been successfully executed and tested on Campfire and Housefire testnets.

To quickly see the changes in action, one may claim rewards with claim-rewards on either of these testnets currently, and then observe in the output logs of the tx that there are now Events provided with the claimed amount in the source-accounts and target-accounts data fields.

Here is an example workflow that I just executed on Campfire testnet:

> namadac rewards --source b0 --validator tnam1q8r4z80f8m4czksdawczf4wgvdtk8jegdg4kzh73 --node $NODE
Current rewards available for claim: 129.616768 NAM

> namadac claim-rewards --source b0 --validator tnam1q8r4z80f8m4czksdawczf4wgvdtk8jegdg4kzh73 --node $NODE
Transaction added to mempool.
Transaction hash: A4B3633CDDDC0E5C8C9A774C0DA3B82C11312AA08E6164D6D2F7FF9446C36E5E
Transaction batch A4B3633CDDDC0E5C8C9A774C0DA3B82C11312AA08E6164D6D2F7FF9446C36E5E was applied at height 648007.
Batch results:
Transaction 89AFDCFCDCD73B2D4FDC2F1F94CCD35E410A8918DE3F9397B1CCBF638B9A11E7 was successfully applied.
Events:
   - tx - token/transfer:
     - post-balances: [[["internal-address/tnam1qgqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqc8j2fp","tnam1qy440ynh9fwrx8aewjvvmu38zxqgukgc259fzp6h"],"2001145044243206"],[["internal-address/tnam1qz2yvfzgwzy52r68xm9jtjfyywqaecwpxvx8fs02","tnam1qy440ynh9fwrx8aewjvvmu38zxqgukgc259fzp6h"],"403546356900"]]
     - source-accounts: [[["internal-address/tnam1qgqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqc8j2fp","tnam1qy440ynh9fwrx8aewjvvmu38zxqgukgc259fzp6h"],"129616768"]]
     - target-accounts: [[["internal-address/tnam1qz2yvfzgwzy52r68xm9jtjfyywqaecwpxvx8fs02","tnam1qy440ynh9fwrx8aewjvvmu38zxqgukgc259fzp6h"],"129616768"]]
     - token-event-descriptor: pos-claim-rewards
The batch consumed 18573 gas units.

> namadac rewards --source b0 --validator tnam1q8r4z80f8m4czksdawczf4wgvdtk8jegdg4kzh73 --node $NODE 
Current rewards available for claim: 0.000000 NAM
7 Likes

Just put the first proposal to increase the max block gas up on-chain as Proposal #10. The code used to produce the attached wasm can be found here.

> namadac query-proposal --proposal-id 10 --node $DO_RPC 
Last committed epoch: 317
Proposal Id: 10
Type: Default with Wasm
Author: tnam1qqgll8x8rz9fvtdv8q6n985za0vjvgyu0udxh7fp
Content: {"details": "In anticipation of updating the claim-rewards tx wasm in the Namada on-chain storage, we first must increase the maximum allowed gas in a block. This must be done because the tx to initialize that proposal consumes about 4.3M gas units, whereas the current block maximum is 3M. This proposal increases the block maximum from 3M to 5M.\n\nThe code used to produce the attached WASM can be viewed here: https://github.com/anoma/namada-governance-upgrades/blob/b26aff300654a791b91d8ff40483d7d2f0bf9d5f/max_block_gas/src/lib.rs", "discussions-to": "https://forum.namada.net/t/two-proposals-to-update-the-claim-rewards-wasm-tx-on-chain/1548", "title": "Increase max block gas to 5M gas units"}
Start Epoch: 318
End Epoch: 330
Activation Epoch: 331
Status: pending
Data: Hash: DB27ADA6B1F734008E4A3AF440F0666A441FDDAF2D8FF44CBC9B6D187949ECD1
7 Likes

Hashes match for the max_block_gas proposal

sha256sum max_block_gas.wasm
db27ada6b1f734008e4a3af440f0666a441fddaf2d8ff44cbc9b6d187949ecd1  max_block_gas.wasm

Supporting the proposal.

1 Like

EmberStake checked out the code for the increase the max block gas at GitHub. From what we see, it works as described in the proposal and doesn’t have any malicious behavior.

We also confirmed that the compiled code’s checksum matches the on-chain hash:
db27ada6b1f734008e4a3af440f0666a441fddaf2d8ff44cbc9b6d187949ecd1

2 Likes

Hash matches!

sha256sum max_block_gas.wasm
db27ada6b1f734008e4a3af440f0666a441fddaf2d8ff44cbc9b6d187949ecd1  max_block_gas.wasm
1 Like