You are viewing an archive of the Piccadilly Circus Games Competition. Join our Discord for the latest information.
Gas Guzzler
How to interact with the Gas Guzzler contract in the round’s On-chain Tasks!
Synopsis
This page provides a how-to guide for how to call the Gas Guzzler contract when taking part in the on-chain PnL challenge.
Gas Guzzler is a contract-based task implementing an economic game to earn ATN rewards as the transaction base fee adjusts in transaction fee markets.
This page details:
- the mechanics of the Gas Guzzler contract-based economic game
- resources for how to understand Autonity’s transaction fee model and for calling the Gas Guzzler contract
- how to get the base fee and if it will change from block data
- how to interact with the on-chain Gas Guzzler contract
Game mechanics
Gas Guzzler is part of the PnL Challenge on-chain task. It is a contract-based economic game based on transaction fee markets and allows you to earn ATN rewards calling the contract’s guzzle()
function.
guzzle()
is a simple function designed to guzzle up gas. For each call it returns a fixed ATN reward amount of 0.200076
ATN
to the function caller.
Depending on the transaction fee economics of the function caller, calling guzzle()
may return a profit or loss on the transaction cost. Whether calling the function results in a profit or loss will depend on EIP-1559 mechanics:
- the value of the base fee at the time of the function call
- the value of the priority fee tip if set
There is a logical ‘profit window’ in which calling the function will result in a profit - i.e. between the floor of the minimum base fee allowed by the protocol configuration, and the base fee cost ceiling below which calling the function is still profitable. If the base fee is higher than that ceiling, the cost of calling guzzle()
is higher than the fixed ATN reward amount of 0.200076000000000000 ATN
returned for calling the function and a loss is made by the function caller.
To participate profitably in the Gas Guzzler game you need to price your call and discover if calling guzzle()
will be a profit or loss. To do this you need to understand the base fee value range within which calling the guzzle()
function is profitable. Getting that understanding is your task. To help you understand the base fee economics of the network it is key to:
Understand the EIP 1559 fee markets model and the Autonity EIP-1559 implementation. See resource links on this page.
Understand the base fee value range: the minimum base fee, i.e. the floor for the base fee value, undestand the base fee value at which calling the
guzzle()
function would result in a loss.Understand how the base fee can adjust by block. There are 2 aspects to consider:
- block period, i.e. the temporal rate at which blocks are produced by the network
- base fee change, i.e. the percentage rate at which base fee value can increase or decrease in the next block according to block capacity filled and the EIP-1559 transaction model.
Identify the logical ‘profit window’ in which
guzzle()
can be profitably called and only call it in that window to avoid loss.
That’s it. Good luck!
Resource links
Autonity transaction fee mechanism
For Autonity’s implementation of Ethereum’s EIP 1559 fee markets, see the Concept description System model, Transaction fees in docs.autonity.org.
The Gas Guzzler contract
The Gas Guzzler is deployed on Piccadilly testnet at address 0xcc9cfae85d20c569551838ad1c456350f240cf97
.
The Gas Guzzler contract ABI is as follows:
[{"inputs":[],"name":"award","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"guzzle","outputs":[],"stateMutability":"nonpayable","type":"function"}]
You can paste this ABI into a file named a GasGuzzler.abi
.
How to guzzle()
Preparations
You will need to setup your tooling to submit transactions to the Gas Guzzler contract from the participant account you created when registering.
You may guzzle()
using your preferred tool or Web3 programming framework such as web3.py
(docs, GitHub).
This guide assumes you will use the aut
command line tool you setup in the Quick Start and the aut contract
command group. To use aut contract
for this you will need to create a GasGuzzler.abi
file. For how to do this see The Gas Guzzler contract section in resource links on this page.
Obtain gas statistics
To determine if the Gas Guzzler contract can be called profitably you need to determine the base fee value and if the base fee will increase or decrease.
This can be determined from minimum and latest block base fee values, and from the gas used in the latest block.
Get the minimum base fee
Discover the minimum base fee for the network by calling getMinimumBaseFee()
. Use the aut protocol minimum-base-fee
command. For example:
aut protocol minimum-base-fee
500000000
Get the block period
Discover the interval at which blocks are produced for the network by calling getBlockPeriod()
. Use the aut protocol block-period
command. For example:
aut protocol block-period
1
This will tell you how long a ‘profit window’ may last for. This may be useful when allowing for the time required to make an RPC over the Internet.
Get the base fee
Discover the base fee for the last committed block by using the aut block get
command to return the baseFeePerGas
for the latest block. For example:
aut block get
{"baseFeePerGas": 500000000, ... }
Call guzzle()
To submit a transaction to the guzzle()
function no arguments are required. Simply submit a transaction using aut contract tx
where:
--abi
: is the path to theGasGuzzler
ABI file--address
: is the Gas Guzzler contract address
aut contract tx \
--abi GasGuzzler.abi \
--address 0xcc9cfae85d20c569551838ad1c456350f240cf97 \
\
guzzle | aut tx sign - \
| aut tx send -