-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve README and emit events
- Loading branch information
Showing
17 changed files
with
1,895 additions
and
390 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<h1 align="center">CosmWasm Lifecycle Module</h1> | ||
|
||
![IMG](./docs/logo.jpg) | ||
|
||
### Abstract | ||
|
||
CosmWasm Lifecycle blockchain module leverages [CosmoSDK's lifecycle](https://docs.cosmos.network/main/build/building-modules/beginblock-endblock) to facilitate the execution of smart contracts at the initiation and conclusion of each block. Given the necessity for swift and resource-light execution in both stages, this module mandates [Gov](https://docs.cosmos.network/main/build/modules/gov) voting and demands a collateral deposit for each smart contract on an individual basis. This collateral deposit will be burned if the smart contract fails to execute multiple times. | ||
|
||
|
||
### Usecases | ||
|
||
Automatic execution of smart contracts is very useful because it enables multiple usecases like for example: | ||
- laverage consensus of multiple parties to do oracle data voting, | ||
- decentralized LP rebalancing by a protocol itself, | ||
- automatic disputes resolution, | ||
- rewards claiming and restaking, | ||
|
||
As you can see there are multiple use cases that will be enabled with this module. | ||
|
||
### Drawbacks | ||
|
||
Automatic smart contract executions in consensus is a double edge sword because too many smart contract executions or too many operations in the smart contracts can slowdown the block production significantly. | ||
|
||
### Solution to the drawbacks | ||
|
||
<table> | ||
<tr> | ||
<td align="center"><img src="./docs/icons/governance.jpg" height="150px"></td> | ||
<td align="center"><img src="./docs/icons/collateral.jpg" height="150px"></td> | ||
<td align="center"><img src="./docs/icons/technology.jpg" height="150px"></td> | ||
</tr> | ||
<tr> | ||
<th><span align="center">Governance</span></th> | ||
<th><span align="center">Collateral</span></th> | ||
<th><span align="center">Technology</span><th> | ||
</tr> | ||
<tr> | ||
<td> | ||
The first messure to the issues is to involve `chain governance` to collectively vote on enabling each smart contract execution at begin or end block. That way the overall community can decide if the usecase and optimization of the smart contract is good enough for the required computation. | ||
</td> | ||
<td> | ||
A secondary measure is to `require a collateral deposit` for each smart contract that will be executed on block lifecycle. This deposit will burned if the smart contract fails the execution many times (which is defined in the module params). | ||
</td> | ||
<td> | ||
The latest measure is to allow smart contracts execution each `n number of blocks`. Which means that execution at end and begin block decreases computation complexity because it does not have to load all the wasm environment and try an execution each time. | ||
</td> | ||
</tr> | ||
</table> | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,66 @@ | ||
syntax = "proto3"; | ||
package emidev98.cosmwasmlifecycle; | ||
|
||
import "cosmos/base/v1beta1/coin.proto"; | ||
import "cosmos_proto/cosmos.proto"; | ||
import "emidev98/cosmwasmlifecycle/execution_type.proto"; | ||
import "gogoproto/gogo.proto"; | ||
|
||
option go_package = "github.com/emidev98/cosmwasm-lifecycle/x/cosmwasmlifecycle/types"; | ||
|
||
// TODO: add remaining events on msgs | ||
message ContractDeleteEvent { | ||
// This event is executed when a contract is registered using MsgRegisterContractProposal | ||
message RegisterContractEvent { | ||
string module_name = 1; | ||
string contract_address = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; | ||
cosmos.base.v1beta1.Coin contract_deposit = 3 [ | ||
(gogoproto.nullable) = false, | ||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin" | ||
]; | ||
ExecutionType execution_type = 4; | ||
int64 block_frequency = 5; | ||
} | ||
|
||
// This event is executed when a contract is modified using MsgModifyContractProposal | ||
message ModifyContractEvent { | ||
string module_name = 1; | ||
string contract_address = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; | ||
ExecutionType new_execution_type = 3; | ||
int64 new_block_frequency = 4; | ||
} | ||
|
||
// This event is executed when a contract is removed using MsgRemoveContractProposal | ||
message RemoveContractEvent { | ||
string module_name = 1; | ||
string contract_address = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; | ||
string refund_account = 3 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; | ||
cosmos.base.v1beta1.Coin refund_amount = 4 [ | ||
(gogoproto.nullable) = false, | ||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin" | ||
]; | ||
} | ||
|
||
// This event is executed when a contract is funded using MsgFundExistentContract | ||
message FundExistentContractEvent { | ||
string module_name = 1; | ||
string contract_address = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; | ||
string sender_address = 3 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; | ||
cosmos.base.v1beta1.Coin deposit_amount = 4 [ | ||
(gogoproto.nullable) = false, | ||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin" | ||
]; | ||
} | ||
|
||
// This event is executed each time a contract returns an error and it's striked | ||
message ContractStrikeEvent { | ||
string module_name = 1; | ||
string contract_address = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; | ||
int64 current_strike = 3; | ||
string strike_reason = 4; | ||
} | ||
} | ||
|
||
// This event is executed when a contract reaches the maximum number of strikes | ||
// the contract is removed and the funds are burn | ||
message ForceRemoveContractEvent { | ||
string module_name = 1; | ||
string contract_address = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.