Skip to content

Instantly share code, notes, and snippets.

Revisions

  1. 0xekez revised this gist Feb 5, 2023. No changes.
  2. 0xekez revised this gist Feb 5, 2023. 1 changed file with 7 additions and 3 deletions.
    10 changes: 7 additions & 3 deletions Automatic payment for execution of Gas Free CosmWasm.md
    Original file line number Diff line number Diff line change
    @@ -52,10 +52,14 @@ $$
    \frac{gD}{G} - 1 < \frac{r-f}{f}
    $$

    So long as,

    $$
    r > f\frac{gD}{G}
    $$

    where $r$ is the absolute amount of DAO DAO validator rewards allocated to execution, it will be profitable for executors to execute $D$ transactions per block. A smart contract can allow governance to select values for these constants, and tune the rest of the system appropriately.
    Note that $g$ scales with $f$ as $fee = gas * gasCost$, call $k$ that scaling factor, $f=gk$.

    $$
    r > g^2\frac{kD}{G}
    $$

    A smart contract can allow governance to select values for these constants and tune the rest of the system appropriately. DAO DAO governance can select values that balance potential for farming with execution rates that keep CosmWasm transactions gas free.
  3. 0xekez revised this gist Feb 5, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Automatic payment for execution of Gas Free CosmWasm.md
    Original file line number Diff line number Diff line change
    @@ -55,7 +55,7 @@ $$
    So long as,

    $$
    r > f(\frac{gD}{G} - 1) + f
    r > f\frac{gD}{G}
    $$

    where $r$ is the absolute amount of DAO DAO validator rewards allocated to execution, it will be profitable for executors to execute $D$ transactions per block. A smart contract can allow governance to select values for these constants, and tune the rest of the system appropriately.
  4. 0xekez revised this gist Feb 5, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Automatic payment for execution of Gas Free CosmWasm.md
    Original file line number Diff line number Diff line change
    @@ -42,7 +42,7 @@ $$
    m \ge \frac{gD}{G}
    $$

    Our earlier equation for $t$ tells us the value of $t$ for which it is profitable to submit a single additional transaction. To make it profitable to submit $m$ transactions, we set $t$ to $m-1$ so that it is profitable to submit one more $m$ transactions.
    Our earlier equation for $t$ tells us the value of $t$ for which it is profitable to submit a single additional transaction. To make it profitable to submit $m$ transactions, we set $t$ to $m-1$ so that it is profitable to submit one more, $m$, transactions.

    $$
    m - 1 < \frac{r-f}{f}
  5. 0xekez revised this gist Feb 5, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Automatic payment for execution of Gas Free CosmWasm.md
    Original file line number Diff line number Diff line change
    @@ -42,7 +42,7 @@ $$
    m \ge \frac{gD}{G}
    $$

    Our earlier equation for $t$ tells us the value of $t$ for which it is profitable to submit a single transaction. To make it profitable to submit $m$ transactions, we set $t$ to $m-1$ so that it is profitable to submit one more $m$ transactions.
    Our earlier equation for $t$ tells us the value of $t$ for which it is profitable to submit a single additional transaction. To make it profitable to submit $m$ transactions, we set $t$ to $m-1$ so that it is profitable to submit one more $m$ transactions.

    $$
    m - 1 < \frac{r-f}{f}
  6. 0xekez revised this gist Feb 5, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Automatic payment for execution of Gas Free CosmWasm.md
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ In [Gas Free CosmWasm](https://gist.github.com/0xekez/98cf6abe3705f4ff83920b7d82

    In this way the Juno blockchain automatically pays people to execute Gas Free CosmWasm messages.

    ## Picking a rewards percentage
    ## Picking a commission percentage

    In a particular block, let $t$ be the total number of messages sent so far, $r$ be the amount of Juno being distributed to executors this block, $f$ be the average fee for executing a transaction, and $x$ be the number of transactions you submit this block.

  7. 0xekez revised this gist Feb 5, 2023. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions Automatic payment for execution of Gas Free CosmWasm.md
    Original file line number Diff line number Diff line change
    @@ -6,9 +6,9 @@ In [Gas Free CosmWasm](https://gist.github.com/0xekez/98cf6abe3705f4ff83920b7d82

    1. We extend the Gas Free CosmWasm spec so that whenever a message is committed to the chain a tally for the message sender increases.
    2. The DAO DAO validator votes to send their commission to a payment splitter contract.
    3. This payment distributor sends a percentage of rewards to another payment distributor contract that distributes payments proportional to the number of messages sent out of the total messages per block.
    3. This payment splitter sends a percentage of commission to another payment splitter contract that distributes payments proportional to the number of messages sent out of the total messages per block.

    In this way the Juno blockchain automatically pays people to execute Gas Free CosmWasm transactions.
    In this way the Juno blockchain automatically pays people to execute Gas Free CosmWasm messages.

    ## Picking a rewards percentage

  8. 0xekez created this gist Feb 5, 2023.
    61 changes: 61 additions & 0 deletions Automatic payment for execution of Gas Free CosmWasm.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,61 @@
    # Automatic payment for execution of Gas Free CosmWasm

    In [Gas Free CosmWasm](https://gist.github.com/0xekez/98cf6abe3705f4ff83920b7d82c7f332) there is a single web2 server that commits messages to the chain, call this piece of software an executor. This gives all the power over what messages get executed to whoever runs the executor. Here I describe a system that allows anyone to run an executor and automatically get paid for doing so.

    ---

    1. We extend the Gas Free CosmWasm spec so that whenever a message is committed to the chain a tally for the message sender increases.
    2. The DAO DAO validator votes to send their commission to a payment splitter contract.
    3. This payment distributor sends a percentage of rewards to another payment distributor contract that distributes payments proportional to the number of messages sent out of the total messages per block.

    In this way the Juno blockchain automatically pays people to execute Gas Free CosmWasm transactions.

    ## Picking a rewards percentage

    In a particular block, let $t$ be the total number of messages sent so far, $r$ be the amount of Juno being distributed to executors this block, $f$ be the average fee for executing a transaction, and $x$ be the number of transactions you submit this block.

    $$
    profit = r \frac{x}{t+x} - fx
    $$

    For it to be profitable to submit a message, $x>=1 \land profit > 0$ . Per [Wolfram Alpha](https://www.wolframalpha.com/input?i=0%3Cr*%28x%2F%28t%2Bx%29%29-f*x%2Cf%3E0%2Cx%3E%3D1%2Cr%3E0%2Ct%3E%3D0), this happens when,

    $$
    0 \le t \lt \frac{r-f}{f}
    $$

    DAO DAO governance controls $r$.

    Let $D$ be the target number of messages per block DAO DAO would like to make profitable, $G$ be the maximum amount of gas allowed per transaction, $g$ be the average gas cost of a CosmWasm transaction, and $m$ be the number of transactions required to execute $x$ messages.

    $$
    \frac{gx}{m} \le G
    $$

    $$
    m \ge \frac{gx}{G}
    $$

    To execute $D$ messages per block,

    $$
    m \ge \frac{gD}{G}
    $$

    Our earlier equation for $t$ tells us the value of $t$ for which it is profitable to submit a single transaction. To make it profitable to submit $m$ transactions, we set $t$ to $m-1$ so that it is profitable to submit one more $m$ transactions.

    $$
    m - 1 < \frac{r-f}{f}
    $$

    $$
    \frac{gD}{G} - 1 < \frac{r-f}{f}
    $$

    So long as,

    $$
    r > f(\frac{gD}{G} - 1) + f
    $$

    where $r$ is the absolute amount of DAO DAO validator rewards allocated to execution, it will be profitable for executors to execute $D$ transactions per block. A smart contract can allow governance to select values for these constants, and tune the rest of the system appropriately.