forked from osmosis-labs/mesh-security-sdk
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
finality: sudo message for
BeginBlock
(#8)
Closes #2 This PR provides sudo message `BeginBlock` for Babylon contracts. The sudo message will be sent to BTC staking contract upon each `BeginBlock`. To test, run `make test-e2e`. Note that the wasm files are generated on babylonchain/babylon-contract#123
- Loading branch information
1 parent
7960ef0
commit 22717cd
Showing
24 changed files
with
868 additions
and
122 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 |
---|---|---|
|
@@ -19,3 +19,5 @@ vendor/ | |
|
||
# Go workspace file | ||
coverage.txt | ||
|
||
demo/build/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,24 @@ | ||
syntax = "proto3"; | ||
package babylonchain.babylon.v1beta1; | ||
|
||
import "cosmos_proto/cosmos.proto"; | ||
import "gogoproto/gogo.proto"; | ||
import "amino/amino.proto"; | ||
|
||
option go_package = "github.com/babylonchain/babylon-sdk/x/babylon/types"; | ||
option (gogoproto.goproto_getters_all) = false; | ||
option (gogoproto.equal_all) = false; | ||
|
||
// Params defines the parameters for the x/babylon module. | ||
message Params { | ||
option (amino.name) = "babylon/Params"; | ||
option (gogoproto.equal) = true; | ||
|
||
// MaxGasEndBlocker defines the maximum gas that can be spent in a contract | ||
// sudo callback | ||
uint32 max_gas_end_blocker = 3; | ||
// babylon_contract_address is the address of the Babylon contract | ||
string babylon_contract_address = 1 | ||
[ (cosmos_proto.scalar) = "cosmos.AddressString" ]; | ||
// btc_staking_contract_address is the address of the BTC staking contract | ||
string btc_staking_contract_address = 2 | ||
[ (cosmos_proto.scalar) = "cosmos.AddressString" ]; | ||
// max_gas_begin_blocker defines the maximum gas that can be spent in a | ||
// contract sudo callback | ||
uint32 max_gas_begin_blocker = 3; | ||
} |
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
Binary file not shown.
Binary file not shown.
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 +1 @@ | ||
9695beb27d6f6433582760374ea6a4e4ff58679f | ||
15cbae22a2cfe7c0590b401ae885c68bb1802530 |
This file was deleted.
Oops, something went wrong.
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,7 +1,16 @@ | ||
package contract | ||
|
||
import "time" | ||
|
||
// SudoMsg is a message sent from the Babylon module to a smart contract | ||
// TODO: implement | ||
type SudoMsg struct { | ||
TestSudoMsg *struct{} `json:"test_sudo_msg,omitempty"` | ||
BeginBlockMsg *BeginBlock `json:"begin_block,omitempty"` | ||
} | ||
|
||
type BeginBlock struct { | ||
Height int64 `json:"height"` // Height is the height of the block | ||
HashHex string `json:"hash_hex"` // HashHex is the hash of the block in hex | ||
Time time.Time `json:"time"` // Time is the time of the block | ||
ChainID string `json:"chain_id"` // ChainId is the chain ID of the block | ||
AppHashHex string `json:"app_hash_hex"` // AppHashHex is the app hash of the block in hex | ||
} |
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,22 @@ | ||
package keeper | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/babylonchain/babylon-sdk/x/babylon/types" | ||
abci "github.com/cometbft/cometbft/abci/types" | ||
"github.com/cosmos/cosmos-sdk/telemetry" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
func (k *Keeper) BeginBlocker(ctx sdk.Context) error { | ||
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) | ||
|
||
return k.SendBeginBlockMsg(ctx) | ||
} | ||
|
||
// EndBlocker is called after every block | ||
func (k *Keeper) EndBlocker(ctx sdk.Context) ([]abci.ValidatorUpdate, error) { | ||
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyEndBlocker) | ||
return []abci.ValidatorUpdate{}, nil | ||
} |
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 @@ | ||
package keeper_test |
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.