-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into kirill/1248-sequencer-reward-addr
- Loading branch information
Showing
42 changed files
with
2,860 additions
and
1,071 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
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
syntax = "proto3"; | ||
package rollapp.hub_genesis; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "cosmos/bank/v1beta1/bank.proto"; | ||
import "ibc/applications/transfer/v2/packet.proto"; | ||
import "hub-genesis/genesis_info.proto"; | ||
|
||
option go_package = "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types"; | ||
|
||
// GenesisBridgeData is the data struct that is passed to the hub for the | ||
// genesis bridge flow | ||
message GenesisBridgeData { | ||
// genesis_info is the genesis info of the rollapp. used for hub validation | ||
GenesisInfo genesis_info = 1 [ (gogoproto.nullable) = false ]; | ||
// native_denom is the native denom of the rollapp. registered on the hub | ||
cosmos.bank.v1beta1.Metadata native_denom = 2 | ||
[ (gogoproto.nullable) = false ]; | ||
// optional genesis transfer packet data | ||
ibc.applications.transfer.v2.FungibleTokenPacketData genesis_transfer = 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
syntax = "proto3"; | ||
package rollapp.hub_genesis; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "cosmos/bank/v1beta1/bank.proto"; | ||
import "hub-genesis/state.proto"; | ||
|
||
option go_package = "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types"; | ||
|
||
// The genesis info of the rollapp, that is passed to the hub for validation. | ||
// it's populated on the InitGenesis of the rollapp | ||
message GenesisInfo { | ||
// checksum used to verify integrity of the genesis file. currently unused | ||
string genesis_checksum = 1; | ||
// unique bech32 prefix | ||
string bech32_prefix = 2; | ||
// native_denom is the base denom for the native token | ||
DenomMetadata native_denom = 3; | ||
// initial_supply is the initial supply of the native token | ||
string initial_supply = 4 [ | ||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", | ||
(gogoproto.nullable) = false | ||
]; | ||
// accounts on the Hub to fund with some bootstrapping transfers | ||
repeated GenesisAccount genesis_accounts = 5 [ (gogoproto.nullable) = false ]; | ||
} | ||
|
||
message DenomMetadata { | ||
string display = 1; | ||
string base = 2; | ||
uint32 exponent = 3; | ||
} | ||
|
||
|
||
// GenesisAccount is a struct for the genesis account for the rollapp | ||
message GenesisAccount { | ||
// amount of coins to be sent to the genesis address | ||
string amount = 1 [ | ||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", | ||
(gogoproto.nullable) = false | ||
]; | ||
// address is a bech-32 address of the genesis account | ||
string address = 2; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package consensus | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/cosmos/cosmos-sdk/baseapp" | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
"github.com/cosmos/cosmos-sdk/codec/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/gogo/protobuf/proto" | ||
prototypes "github.com/gogo/protobuf/types" | ||
abci "github.com/tendermint/tendermint/abci/types" | ||
) | ||
|
||
// ProcessConsensusMessages processes a batch of consensus messages. | ||
// It unpacks each message, checks if it is allowed, executes it, and returns the responses. | ||
func ProcessConsensusMessages( | ||
ctx sdk.Context, | ||
appCodec codec.Codec, | ||
admissionHandler AdmissionHandler, | ||
msgServiceRouter *baseapp.MsgServiceRouter, | ||
consensusMsgs []*prototypes.Any, | ||
) []*abci.ConsensusMessageResponse { | ||
var responses []*abci.ConsensusMessageResponse | ||
|
||
for _, anyMsg := range consensusMsgs { | ||
sdkAny := &types.Any{ | ||
TypeUrl: "/" + anyMsg.TypeUrl, | ||
Value: anyMsg.Value, | ||
} | ||
|
||
var msg sdk.Msg | ||
err := appCodec.UnpackAny(sdkAny, &msg) | ||
if err != nil { | ||
responses = append(responses, &abci.ConsensusMessageResponse{ | ||
Response: &abci.ConsensusMessageResponse_Error{ | ||
Error: fmt.Errorf("unpack consensus message: %w", err).Error(), | ||
}, | ||
}) | ||
|
||
continue | ||
} | ||
|
||
cacheCtx, writeCache := ctx.CacheContext() | ||
err = admissionHandler(cacheCtx, msg) | ||
if err != nil { | ||
responses = append(responses, &abci.ConsensusMessageResponse{ | ||
Response: &abci.ConsensusMessageResponse_Error{ | ||
Error: fmt.Errorf("consensus message admission: %w", err).Error(), | ||
}, | ||
}) | ||
|
||
continue | ||
} | ||
|
||
resp, err := msgServiceRouter.Handler(msg)(cacheCtx, msg) | ||
if err != nil { | ||
responses = append(responses, &abci.ConsensusMessageResponse{ | ||
Response: &abci.ConsensusMessageResponse_Error{ | ||
Error: fmt.Errorf("execute consensus message: %w", err).Error(), | ||
}, | ||
}) | ||
|
||
continue | ||
} | ||
|
||
theType, err := proto.Marshal(resp) | ||
if err != nil { | ||
responses = append(responses, &abci.ConsensusMessageResponse{ | ||
Response: &abci.ConsensusMessageResponse_Error{ | ||
Error: fmt.Errorf("marshal consensus message response: %w", err).Error(), | ||
}, | ||
}) | ||
|
||
continue | ||
} | ||
|
||
anyResp := &prototypes.Any{ | ||
TypeUrl: proto.MessageName(resp), | ||
Value: theType, | ||
} | ||
|
||
responses = append(responses, &abci.ConsensusMessageResponse{ | ||
Response: &abci.ConsensusMessageResponse_Ok{ | ||
Ok: anyResp, | ||
}, | ||
}) | ||
|
||
writeCache() | ||
} | ||
|
||
return responses | ||
} |
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.