Skip to content

Commit

Permalink
feat: add l1_to_l2_gas_ratio in rollup info and fix GetAllRollup's pa…
Browse files Browse the repository at this point in the history
…ram (#1071)
  • Loading branch information
shiki-tak authored Aug 10, 2023
1 parent fa85f8a commit 95ec1c0
Show file tree
Hide file tree
Showing 10 changed files with 170 additions and 85 deletions.
2 changes: 2 additions & 0 deletions docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -9732,6 +9732,7 @@ Msg defines the Msg service.
| ----- | ---- | ----- | ----------- |
| `rollup_name` | [string](#string) | | |
| `creator` | [string](#string) | | |
| `l1_to_l2_gas_ratio` | [uint64](#uint64) | | |
| `permissioned_addresses` | [Sequencers](#finschia.or.rollup.v1.Sequencers) | | |


Expand Down Expand Up @@ -10055,6 +10056,7 @@ Params defines the parameters for the module.
| ----- | ---- | ----- | ----------- |
| `rollup_name` | [string](#string) | | |
| `creator` | [string](#string) | | |
| `l1_to_l2_gas_ratio` | [uint64](#uint64) | | |
| `permissioned_addresses` | [Sequencers](#finschia.or.rollup.v1.Sequencers) | | |


Expand Down
3 changes: 2 additions & 1 deletion proto/finschia/or/rollup/v1/rollup.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ option go_package = "github.com/Finschia/finschia-sdk/x/or/rollup/types";
message Rollup {
string rollup_name = 1;
string creator = 2;
Sequencers permissioned_addresses = 3 [(gogoproto.nullable) = false];
uint64 l1_to_l2_gas_ratio = 3;
Sequencers permissioned_addresses = 4 [(gogoproto.nullable) = false];
}

message Sequencer {
Expand Down
3 changes: 2 additions & 1 deletion proto/finschia/or/rollup/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ service Msg {
message MsgCreateRollup {
string rollup_name = 1;
string creator = 2;
Sequencers permissioned_addresses = 3 [(gogoproto.nullable) = false];
uint64 l1_to_l2_gas_ratio = 3;
Sequencers permissioned_addresses = 4 [(gogoproto.nullable) = false];
}

message MsgRegisterSequencer {
Expand Down
2 changes: 1 addition & 1 deletion x/or/demo/prepare_rollup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ INITBALANCE=$(simd query bank balances $SEQUENCERADDRESS --home $BASE_DIR --outp
echo $INITBALANCE

echo "# Create rollup"
simd tx rollup create-rollup $ROLLUPNAME --from $SEQUENCER --keyring-backend=test --home $BASE_DIR --chain-id sim -y
simd tx rollup create-rollup $ROLLUPNAME 5 --from $SEQUENCER --keyring-backend=test --home $BASE_DIR --chain-id sim -y

sleep 5

Expand Down
14 changes: 10 additions & 4 deletions x/or/rollup/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cli
import (
"encoding/json"
"fmt"
"strconv"

"github.com/Finschia/finschia-sdk/client"
"github.com/Finschia/finschia-sdk/client/flags"
Expand Down Expand Up @@ -40,14 +41,18 @@ func GetTxCmd() *cobra.Command {
func NewCreateRollupCmd() *cobra.Command {
cmd := &cobra.Command{
// TODO: If rollup:sequencer=1:N, add [max-sequencers] parameter
Use: "create-rollup [rollup_name] [permissioned-addresses]",
Use: "create-rollup [rollup_name] [l1_to_l2_gas_ratio] [permissioned-addresses]",
Short: "Create a new rollup",
Args: cobra.RangeArgs(1, 2),
Args: cobra.RangeArgs(2, 3),
RunE: func(cmd *cobra.Command, args []string) (err error) {
argRollupName := args[0]
argL1ToL2GasRatio, err := strconv.ParseUint(args[1], 10, 64)
if err != nil {
return err
}
argPermissionedAddresses := new(types.Sequencers)
if len(args) == 2 {
err = json.Unmarshal([]byte(args[1]), argPermissionedAddresses)
if len(args) == 3 {
err = json.Unmarshal([]byte(args[2]), argPermissionedAddresses)
if err != nil {
return err
}
Expand All @@ -61,6 +66,7 @@ func NewCreateRollupCmd() *cobra.Command {
msg := types.NewMsgCreateRollup(
argRollupName,
clientCtx.GetFromAddress().String(),
argL1ToL2GasRatio,
argPermissionedAddresses,
)

Expand Down
1 change: 1 addition & 0 deletions x/or/rollup/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func (k msgServer) CreateRollup(goCtx context.Context, msg *types.MsgCreateRollu
rollup := types.Rollup{
RollupName: msg.RollupName,
Creator: msg.Creator,
L1ToL2GasRatio: msg.L1ToL2GasRatio,
PermissionedAddresses: msg.PermissionedAddresses,
}

Expand Down
3 changes: 1 addition & 2 deletions x/or/rollup/keeper/rollup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package keeper
import (
"github.com/Finschia/finschia-sdk/store/prefix"
sdk "github.com/Finschia/finschia-sdk/types"
"github.com/Finschia/finschia-sdk/types/query"
"github.com/Finschia/finschia-sdk/x/or/rollup/types"
)

Expand All @@ -24,7 +23,7 @@ func (k Keeper) SetRollup(ctx sdk.Context, rollup types.Rollup) {
store.Set(types.RollupKey(rollup.RollupName), b)
}

func (k Keeper) GetAllRollup(ctx sdk.Context, pagination *query.PageRequest) (list []types.Rollup) {
func (k Keeper) GetAllRollup(ctx sdk.Context) (list []types.Rollup) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.RollupKeyPrefix)
iterator := sdk.KVStorePrefixIterator(store, []byte{})

Expand Down
3 changes: 2 additions & 1 deletion x/or/rollup/types/message_create_rollup.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ const (

var _ sdk.Msg = (*MsgCreateRollup)(nil)

func NewMsgCreateRollup(rollupName, creator string, permissionedAddresses *Sequencers) *MsgCreateRollup {
func NewMsgCreateRollup(rollupName, creator string, l1ToL2GasRatio uint64, permissionedAddresses *Sequencers) *MsgCreateRollup {
return &MsgCreateRollup{
RollupName: rollupName,
Creator: creator,
L1ToL2GasRatio: l1ToL2GasRatio,
PermissionedAddresses: *permissionedAddresses,
}
}
Expand Down
103 changes: 70 additions & 33 deletions x/or/rollup/types/rollup.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 95ec1c0

Please sign in to comment.