Skip to content

Commit

Permalink
chore: Preliminary file setup prior to adding script (#117)
Browse files Browse the repository at this point in the history
* prelim setup

* comments
  • Loading branch information
samricotta authored Feb 2, 2024
1 parent c23a63e commit 185af5d
Show file tree
Hide file tree
Showing 29 changed files with 1,763 additions and 1 deletion.
5 changes: 5 additions & 0 deletions docs/tutorials/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"label": "Advanced Tutorials",
"position": 2,
"link": null
}
12 changes: 12 additions & 0 deletions docs/tutorials/tutorials.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
sidebar_position: 0
---
# Tutorials

## Advanced Tutorials

This section provides a concise overview of tutorials focused on implementing vote extensions in the Cosmos SDK. Vote extensions are a powerful feature for enhancing the security and fairness of blockchain applications, particularly in scenarios like implementing oracles and mitigating auction front-running.

* **Implementing Oracle with Vote Extensions** - This tutorial details how to use vote extensions for the implementation of a secure and reliable oracle within a blockchain application. It demonstrates the use of vote extensions to securely include oracle data submissions in blocks, ensuring the data's integrity and reliability for the blockchain.

* **Mitigating Auction Front-Running with Vote Extensions** - Explore how to prevent auction front-running using vote extensions. This tutorial outlines the creation of a module aimed at mitigating front-running in nameservice auctions, emphasising the `ExtendVote`, `PrepareProposal`, and `ProcessProposal` functions to facilitate a fair auction process.
5 changes: 5 additions & 0 deletions docs/tutorials/vote-extensions/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"label": "Vote Extensions Tutorials",
"position": 1,
"link": null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Getting Started

## Table of Contents

* [Getting Started](#overview-of-the-project)
* [Understanding Front-Running](01-understanding-front-running)
* [Mitigating Front-running with Vote Extensions](02-mitigating-front-running-with-vote-extensions)
* [Demo of Mitigating Front-Running](03-demo-of-mitigating-front-running)

## Getting Started

### Overview of the Project

This tutorial outlines the development of a module designed to mitigate front-running in nameservice auctions. The following functions are central to this module:

* `ExtendVote`: Gathers bids from the mempool and includes them in the vote extension to ensure a fair and transparent auction process.
* `PrepareProposal`: Processes the vote extensions from the previous block, creating a special transaction that encapsulates bids to be included in the current proposal.
* `ProcessProposal`: Validates that the first transaction in the proposal is the special transaction containing the vote extensions and ensures the integrity of the bids.

In this advanced tutorial, we will be working with an example application that facilitates the auctioning of nameservices. To see what frontrunning and nameservices are [here](./01-understanding-frontrunning.md) This application provides a practical use case to explore the prevention of auction front-running, also known as "bid sniping", where a validator takes advantage of seeing a bid in the mempool to place their own higher bid before the original bid is processed.

The tutorial will guide you through using the Cosmos SDK to mitigate front-running using vote extensions. The module will be built on top of the base blockchain provided in the `tutorials/base` directory and will use the `auction` module as a foundation. By the end of this tutorial, you will have a better understanding of how to prevent front-running in blockchain auctions, specifically in the context of nameservice auctioning.

## What are Vote extensions?

Vote extensions is arbitrary information which can be inserted into a block. This feature is part of ABCI 2.0, which is available for use in the SDK 0.50 release and part of the 0.38 CometBFT release.

More information about vote extensions can be seen [here](https://docs.cosmos.network/main/build/abci/vote-extensions).

## Requirements and Setup

Before diving into the advanced tutorial on auction front-running simulation, ensure you meet the following requirements:

* [Golang >1.21.5](https://golang.org/doc/install) installed
* Familiarity with the concepts of front-running and MEV, as detailed in [Understanding Front-Running](./01-understanding-frontrunning.md)
* Understanding of Vote Extensions as described [here](https://docs.cosmos.network/main/build/abci/vote-extensions)

You will also need a foundational blockchain to build upon coupled with your own module. The `tutorials/base` directory has the necessary blockchain code to start your custom project with the Cosmos SDK. For the module, you can use the `auction` module provided in the `tutorials/auction/x/auction` directory as a reference but please be aware that all of the code needed to implement vote extensions is already implemented in this module.

This will set up a strong base for your blockchain, enabling the integration of advanced features such as auction front-running simulation.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Understanding Front-Running and more

## Introduction

Blockchain technology is vulnerable to practices that can affect the fairness and security of the network. Two such practices are front-running and Maximal Extractable Value (MEV), which are important for blockchain participants to understand.

## What is Front-Running?

Front-running is when someone, such as a validator, uses their ability to see pending transactions to execute their own transactions first, benefiting from the knowledge of upcoming transactions. In nameservice auctions, a front-runner might place a higher bid before the original bid is confirmed, unfairly winning the auction.

## Nameservices and Nameservice Auctions

Nameservices are human-readable identifiers on a blockchain, akin to internet domain names, that correspond to specific addresses or resources. They simplify interactions with typically long and complex blockchain addresses, allowing users to have a memorable and unique identifier for their blockchain address or smart contract.

Nameservice auctions are the process by which these identifiers are bid on and acquired. To combat front-running—where someone might use knowledge of pending bids to place a higher bid first—mechanisms such as commit-reveal schemes, auction extensions, and fair sequencing are implemented. These strategies ensure a transparent and fair bidding process, reducing the potential for Maximal Extractable Value (MEV) exploitation.

## What is Maximal Extractable Value (MEV)?

MEV is the highest value that can be extracted by manipulating the order of transactions within a block, beyond the standard block rewards and fees. This has become more prominent with the growth of decentralised finance (DeFi), where transaction order can greatly affect profits.

## Implications of MEV

MEV can lead to:

- **Network Security**: Potential centralisation, as those with more computational power might dominate the process, increasing the risk of attacks.
- **Market Fairness**: An uneven playing field where only a few can gain at the expense of the majority.
- **User Experience**: Higher fees and network congestion due to the competition for MEV.

## Mitigating MEV and Front-Running

Some solutions being developed to mitigate MEV and front-running, including:

- **Time-delayed Transactions**: Random delays to make transaction timing unpredictable.
- **Private Transaction Pools**: Concealing transactions until they are mined.
- **Fair Sequencing Services**: Processing transactions in the order they are received.

For this tutorial, we will be exploring the last solution, fair sequencing services, in the context of nameservice auctions.

## Conclusion

MEV and front-running are challenges to blockchain integrity and fairness. Ongoing innovation and implementation of mitigation strategies are crucial for the ecosystem's health and success.
Loading

0 comments on commit 185af5d

Please sign in to comment.