conflict

package
v0.35.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

README

x/conflict

Abstract

This document specifies the conflict module of Lava Protocol.

The purpose of the conflict module is to ensure data reliability from providers that offer their services on Lava. To achieve this, Lava allows consumers to report mismatches between different responses to the same request (for deterministic APIs). This way, Lava can identify fraudulent providers and penalize them by confiscating their staked tokens. Consumers are incentivized to do so by Lava, as they receive tokens taken from the fraudulent provider being punished.

Contents

Concepts

Response Conflict

A response conflict occurs when a consumer receives mismatched responses from different providers. In such cases, the consumer is eligible to send a conflict detection message (this is done randomly, determined by the spec reliability threshold field), which includes the relay request and responses from the two providers. This conflict detection message is then validated to ensure that the responses are different, the signatures match the providers and consumer, and that the API is deterministic. If the message is valid, a conflict is opened.

A group of validators is selected as a jury to determine the fraudulent and honest providers. Through an event, the chain announces the conflict voting period and the participating providers. During the voting period, providers need to submit their hashed response + salt to the original relay request. This is done to prevent other providers from cheating or copying their vote. Once the voting period ends, the conflict moves to the reveal state. In this state, providers need to reveal their response + salt, which is then verified and compared to the original responses. After the reveal period ends, the votes are counted, and the provider with the fewest votes, and the jury that voted for him, are penalized by having a fraction of their staked tokens taken and distributed among all the other participants.

Finalization Conflict

N/A

Self Provider Conflict

N/A

Commit Period

This is the voting period of the conflict, providers that are selected as jury are required to submit their hashed vote. The hash consisnt of nonce + response hash + provider address.

type MsgConflictVoteCommit struct {
	Creator string // provider address
	VoteID  string // the conflict unique id
	Hash    []byte // the hashed nonce + response + provider address
}
Reveal Period

Once the commit period ends, the conflict enters the reveal state. At this point, providers are required to submit their full response and nonce. These responses are then validated and compared to the original providers' responses. The result of the vote (Provider A, Provider B, None) is then saved in the state, awaiting the end of the conflict.

type MsgConflictVoteReveal struct {
	Creator string // provider address
	VoteID  string // the conflict unique id
	Nonce   int64  // random nonce
	Hash    []byte // hash of the response
}
Conflict Resolve

Once the reveal period ends, votes are counted to determine the results of the conflict. The votes are weighted based on the providers' stake. Providers on the jury who did not vote will be punished with jail and slashing, and the slashed amount will be added to the conflict reward pool.

To resolve the conflict, a majority of votes must be in favor of Provider A, Provider B, or None of them. If a majority is not reached, the conflict reward pool is given to the consumer who reported the conflict.

Once a majority is reached, providers who voted for the wrong side of the conflict will be slashed and frozen, and the slashed amount will be added to the conflict reward pool. The reward pool is then distributed between the consumer and the providers who voted for the correct provider. Providers in the jury that did not vote are punished by jail and slashing, their slashed amount will be added to the conflict reward pool. For the conflict resolution there needs to be a majority met of votes for Provider A, Provider B or None of them. If a majority was not met, conflict reward pool is given to the consumer that reported the conflict. Once a majority is met providers that voted to the wrong side of the conflict are slashed and frozen, the slashed amount is added to the conflict reward pool. Now the reward pool is distributed between the comsumer and the providers that voted for the correct provider.

Parameters

The conflict module contains the following parameters:

Key Type Default Value
MajorityPercent math.LegacyDec 0.95
VoteStartSpan uint64 3
VotePeriod uint64 2
Rewards rewards N/A

MajorityPercent determines the majority needed to conclude who is the winner of the conflict.

VoteStartSpan is the amount of epochs in the past that a consumer can send conflict detection message for.

VotePeriod is the number of epochs in the past that a consumer can send a conflict detection message for. Rewards defines how the reward pool tokens will be distributed between all the participants.

type Rewards struct {
	WinnerRewardPercent github_com_cosmos_cosmos_sdk_types.Dec // the conflict's winner portion (provider)
	ClientRewardPercent github_com_cosmos_cosmos_sdk_types.Dec // the conflict's reporter portion
	VotersRewardPercent github_com_cosmos_cosmos_sdk_types.Dec // the jury portion
}

Queries

The Conflict module supports the following queries:

Query Arguments What it does
params none show the params of the module
consumer-conflicts consumer (string) shows all the reported and active conflicts by a consumer
list-conflict-vote none shows all active conflicts
show-conflict-vote voteID (string) shows a specific active conflict

Transactions

The Conflict module transactions are not meant to be used by the CLI and are used by the consumers and providers. for more information look here.

Events

The conflict module has the following events:

Event When it happens
response_conflict_detection A new conflict has been opened, which involves all of the jury providers. It is now entering the commit stage
conflict_vote_reveal_started conflict has transitioned to reveal state
conflict_vote_got_commit provider commited his vote
conflict_vote_got_reveal provider revealed his vote
conflict_unstake_fraud_voter provider was unstaked due to conflict
conflict_detection_vote_resolved conflict was succesfully resolved
conflict_detection_vote_unresolved conflict was not resolved (did not reach majority)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExportGenesis

func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState

ExportGenesis returns the capability module's exported genesis.

func InitGenesis

func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState)

InitGenesis initializes the capability module's state from a provided genesis state.

func NewHandler

func NewHandler(k keeper.Keeper) sdk.Handler

NewHandler ...

Types

type AppModule

type AppModule struct {
	AppModuleBasic
	// contains filtered or unexported fields
}

AppModule implements the AppModule interface for the capability module.

func NewAppModule

func NewAppModule(
	cdc codec.Codec,
	keeper keeper.Keeper,
	accountKeeper types.AccountKeeper,
	bankKeeper types.BankKeeper,
) AppModule

func (AppModule) BeginBlock

func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock)

BeginBlock executes all ABCI BeginBlock logic respective to the capability module.

func (AppModule) ConsensusVersion

func (AppModule) ConsensusVersion() uint64

ConsensusVersion implements ConsensusVersion.

func (AppModule) EndBlock

EndBlock executes all ABCI EndBlock logic respective to the capability module. It returns no validator updates.

func (AppModule) ExportGenesis

func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage

ExportGenesis returns the capability module's exported genesis state as raw JSON bytes.

func (AppModule) GenerateGenesisState

func (AppModule) GenerateGenesisState(simState *module.SimulationState)

GenerateGenesisState creates a randomized GenState of the module

func (AppModule) InitGenesis

func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate

InitGenesis performs the capability module's genesis initialization It returns no validator updates.

func (AppModule) Name

func (am AppModule) Name() string

Name returns the capability module's name.

func (AppModule) ProposalMsgs

TODO: Add weighted proposals

func (AppModule) RegisterInvariants

func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry)

RegisterInvariants registers the capability module's invariants.

func (AppModule) RegisterServices

func (am AppModule) RegisterServices(cfg module.Configurator)

RegisterServices registers a GRPC query service to respond to the module-specific GRPC queries.

func (AppModule) RegisterStoreDecoder

func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry)

RegisterStoreDecoder registers a decoder

func (AppModule) WeightedOperations

func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation

WeightedOperations returns the all the gov module operations with their respective weights.

type AppModuleBasic

type AppModuleBasic struct {
	// contains filtered or unexported fields
}

AppModuleBasic implements the AppModuleBasic interface for the capability module.

func NewAppModuleBasic

func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic

func (AppModuleBasic) DefaultGenesis

func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage

DefaultGenesis returns the capability module's default genesis state.

func (AppModuleBasic) GetQueryCmd

func (AppModuleBasic) GetQueryCmd() *cobra.Command

GetQueryCmd returns the capability module's root query command.

func (AppModuleBasic) GetTxCmd

func (a AppModuleBasic) GetTxCmd() *cobra.Command

GetTxCmd returns the capability module's root tx command.

func (AppModuleBasic) Name

func (AppModuleBasic) Name() string

Name returns the capability module's name.

func (AppModuleBasic) RegisterCodec

func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino)

func (AppModuleBasic) RegisterGRPCGatewayRoutes

func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux)

RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module.

func (AppModuleBasic) RegisterInterfaces

func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry)

RegisterInterfaces registers the module's interface types

func (AppModuleBasic) RegisterLegacyAminoCodec

func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino)

func (AppModuleBasic) RegisterRESTRoutes

func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router)

RegisterRESTRoutes registers the capability module's REST service handlers.

func (AppModuleBasic) ValidateGenesis

func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error

ValidateGenesis performs genesis state validation for the capability module.

Directories

Path Synopsis
client
cli
migrations
v5
Package types is a reverse proxy.
Package types is a reverse proxy.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL