This is a Java implementation of the Tiered Transaction Pricing mechanism for calculating blockchain fees. The mechanism was first introduced in the paper Tiered Mechanisms for Blockchain Transaction Fees by Kiayias, et al.
It can be used to run simulations to understand the mechanism better and how the parameters affect the fees and tiers.
This project uses Gradle as the build tool, and requires at least Java 11. To build and run the project, you can use the following command in the root of the repository:
git clone https://github.com/yHSJ/tiered-transaction-mechanism.git \
&& cd tiered-transaction-mechanism \
&& ./gradlew build \
&& java -jar tiered-transaction-mechanism.jar
In order to modify the parameters of the mechanism and your simulation, you can edit the config.json
file.
By default, the configuration values are the same as those used in the experiment described in the paper if applicable.
These parameters are used to configure the simulation, such as the number of blocks to simulate and the maximum size of a block.
-
block_size
:integer > 0
The maximum number of transactions that can be included in a block.
-
block_count
:integer > 0
The total number of blocks to be generated in the simulation.
-
simulated_regions
:integer[]
, whereinteger[i] > 0
This array represents the number of regions to be simulated. Each element of the array represents the exclusive upper bound of that region, i.e. the block number that begins the next region. The final region does not need an upper bound.
-
simulated_region_loads
:integer[]
, whereinteger[i] > 0
This array represents the load of each region to be simulated. Each element of the array represents the number of transactions of the corresponding region in
simulated_regions
. The load of the final region is at indexsimulated_regions.length + 1
. -
correlated_region_count
:integer >= 0
This is the number of regions in which
value(0)
is correlated with the urgency. The finaln
regions will be uncorrelated, wheren
is the value of this parameter.
These parameters are used to configure the mechanism and are described in the paper.
-
target_tx_count_per_tier
:integer > 0
This is the target number of transactions per tier. The mechanism will try to achieve this number of transactions per tier.
-
max_tiers
:integer > 0
This is the maximum number of tiers that can be created by the mechanism.
-
delay_frequency
:integer > 0
This is how often the mechanism updates the delay of the tiers, measured in blocks.
-
probability_decrease
:integer
in the range[0, 100]
This is the percent chance that the mechanism will decrease the delay of a tier, if the delay does not need to be increased.
-
tier_frequency
:integer > 0
This is how often the mechanism updates the number of tiers, measured in blocks.
-
add_tier_price
:double > 0
This determines the maximum price of the final tier. If the price of the last tier is greater than this price, a new tier is added. The space for the new tier is taken from the first tier.
-
remove_tier_price
:double > 0
This determines the minimum price of the final tier. If the price of the last tier is less than this price, the last tier is removed. The space of the removed tier is added to the first tier.
-
tier_price_multipliers
:double[]
This is the parameter
µi
in the paper. If price of a tieri+1
is less thantier_price_multipliersi+1 * pi
wherepi
is the price of thei
th tier, the delay of thei + 1
th tier is increased by one. -
tier_delay_multipliers
:double[]
This is the parameter
λi
in the paper. The delay of tieri
must be at leastpi-1 * λi-1
.