github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/x/evidence/doc.go (about)

     1  /*
     2  Package evidence implements a Cosmos SDK module, per ADR 009, that allows for the
     3  submission and handling of arbitrary evidence of misbehavior.
     4  
     5  All concrete evidence types must implement the Evidence interface contract. Submitted
     6  evidence is first routed through the evidence module's Router in which it attempts
     7  to find a corresponding Handler for that specific evidence type. Each evidence type
     8  must have a Handler registered with the evidence module's keeper in order for it
     9  to be successfully executed.
    10  
    11  Each corresponding handler must also fulfill the Handler interface contract. The
    12  Handler for a given Evidence type can perform any arbitrary state transitions
    13  such as slashing, jailing, and tombstoning. This provides developers with great
    14  flexibility in designing evidence handling.
    15  
    16  A full setup of the evidence module may look something as follows:
    17  
    18  	ModuleBasics = module.NewBasicManager(
    19  	  // ...,
    20  	  evidence.AppModuleBasic{},
    21  	)
    22  
    23  	// First, create the keeper's subspace for parameters and the keeper itself.
    24  	evidenceParamspace := app.ParamsKeeper.Subspace(evidence.DefaultParamspace)
    25  	evidenceKeeper := evidence.NewKeeper(
    26  	  app.cdc, keys[evidence.StoreKey], evidenceParamspace, evidence.DefaultCodespace,
    27  	)
    28  
    29  
    30  	// Second, create the evidence Handler and register all desired routes.
    31  	evidenceRouter := evidence.NewRouter().
    32  	  AddRoute(evidenceRoute, evidenceHandler).
    33  	  AddRoute(..., ...)
    34  
    35  	evidenceKeeper.SetRouter(evidenceRouter)
    36  
    37  	app.mm = module.NewManager(
    38  	  // ...
    39  	  evidence.NewAppModule(evidenceKeeper),
    40  	)
    41  
    42  	// Remaining application bootstrapping...
    43  */
    44  package evidence