Skip to content

Commit

Permalink
delete CHAIN_TYPE prefix from batch info chain type (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
sh-cha authored Dec 17, 2024
1 parent 3ed9c06 commit 7da22a7
Show file tree
Hide file tree
Showing 19 changed files with 187 additions and 212 deletions.
112 changes: 55 additions & 57 deletions api/opinit/ophost/v1/types.pulsar.go

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

6 changes: 3 additions & 3 deletions contrib/launchtools/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,16 @@ func (opBridge *OpBridge) Finalize(buf *bufio.Reader) error {
opBridge.OutputSubmissionStartHeight = 1
}

if opBridge.BatchSubmissionTarget == ophosttypes.BatchInfo_CHAIN_TYPE_UNSPECIFIED {
if opBridge.BatchSubmissionTarget == ophosttypes.BatchInfo_UNSPECIFIED {
useCelestia, err := input.GetConfirmation("Use Celestia as DA layer?", buf, os.Stderr)
if err != nil {
return err
}

if useCelestia {
opBridge.BatchSubmissionTarget = ophosttypes.BatchInfo_CHAIN_TYPE_CELESTIA
opBridge.BatchSubmissionTarget = ophosttypes.BatchInfo_CELESTIA
} else {
opBridge.BatchSubmissionTarget = ophosttypes.BatchInfo_CHAIN_TYPE_INITIA
opBridge.BatchSubmissionTarget = ophosttypes.BatchInfo_INITIA
}
}

Expand Down
2 changes: 1 addition & 1 deletion contrib/launchtools/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func Test_opBridgeConfig_JSON(t *testing.T) {
OutputSubmissionInterval: &submissionInterval,
OutputFinalizationPeriod: &finalizationPeriod,
OutputSubmissionStartHeight: 1,
BatchSubmissionTarget: ophosttypes.BatchInfo_CHAIN_TYPE_CELESTIA,
BatchSubmissionTarget: ophosttypes.BatchInfo_CELESTIA,
}

bz, err := json.Marshal(opBridgeConfig)
Expand Down
4 changes: 2 additions & 2 deletions contrib/launchtools/utils/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ func DeriveL2Address(mnemonic string) (string, error) {
func DeriveDAAddress(mnemonic string, chainType ophosttypes.BatchInfo_ChainType) (string, error) {
var codec address.Codec
switch chainType {
case ophosttypes.BatchInfo_CHAIN_TYPE_INITIA:
case ophosttypes.BatchInfo_INITIA:
codec = L1AddressCodec()
case ophosttypes.BatchInfo_CHAIN_TYPE_CELESTIA:
case ophosttypes.BatchInfo_CELESTIA:
codec = CelestiaAddressCodec()
default:
return "", errors.New("unsupported chain type")
Expand Down
6 changes: 3 additions & 3 deletions proto/opinit/ophost/v1/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ message BatchInfo {
// ChainType defines the type of chain.
enum ChainType {
// Unspecified chain type.
CHAIN_TYPE_UNSPECIFIED = 0;
UNSPECIFIED = 0;
// The chain type of the initia chain.
CHAIN_TYPE_INITIA = 1;
INITIA = 1;
// The chain type of the celestia chain.
CHAIN_TYPE_CELESTIA = 2;
CELESTIA = 2;
}

// The address of the batch submitter.
Expand Down
2 changes: 1 addition & 1 deletion x/opchild/keeper/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func Test_GenesisImportExport(t *testing.T) {
Proposer: addrsStr[3],
BatchInfo: ophosttypes.BatchInfo{
Submitter: addrsStr[4],
ChainType: ophosttypes.BatchInfo_CHAIN_TYPE_INITIA,
ChainType: ophosttypes.BatchInfo_INITIA,
},
SubmissionInterval: time.Minute,
FinalizationPeriod: time.Hour,
Expand Down
4 changes: 2 additions & 2 deletions x/opchild/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ func Test_MsgServer_Withdraw(t *testing.T) {
Proposer: addrsStr[3],
BatchInfo: ophosttypes.BatchInfo{
Submitter: addrsStr[4],
ChainType: ophosttypes.BatchInfo_CHAIN_TYPE_INITIA,
ChainType: ophosttypes.BatchInfo_INITIA,
},
SubmissionInterval: time.Minute,
FinalizationPeriod: time.Hour,
Expand Down Expand Up @@ -344,7 +344,7 @@ func Test_MsgServer_SetBridgeInfo(t *testing.T) {
Proposer: addrsStr[3],
BatchInfo: ophosttypes.BatchInfo{
Submitter: addrsStr[4],
ChainType: ophosttypes.BatchInfo_CHAIN_TYPE_INITIA,
ChainType: ophosttypes.BatchInfo_INITIA,
},
SubmissionInterval: time.Minute,
FinalizationPeriod: time.Hour,
Expand Down
2 changes: 1 addition & 1 deletion x/opchild/keeper/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func Test_QuerySetBridgeInfo(t *testing.T) {
Proposer: addrsStr[3],
BatchInfo: ophosttypes.BatchInfo{
Submitter: addrsStr[4],
ChainType: ophosttypes.BatchInfo_CHAIN_TYPE_INITIA,
ChainType: ophosttypes.BatchInfo_INITIA,
},
SubmissionInterval: time.Minute,
FinalizationPeriod: time.Hour,
Expand Down
10 changes: 5 additions & 5 deletions x/ophost/keeper/batch_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func Test_SetGetBatchInfo(t *testing.T) {
ctx, input := createDefaultTestInput(t)
batchInfo1 := types.BatchInfo{
Submitter: addrsStr[0],
ChainType: types.BatchInfo_CHAIN_TYPE_INITIA,
ChainType: types.BatchInfo_INITIA,
}
output1 := types.Output{
OutputRoot: []byte{1, 2, 3},
Expand All @@ -25,7 +25,7 @@ func Test_SetGetBatchInfo(t *testing.T) {

batchInfo2 := types.BatchInfo{
Submitter: addrsStr[1],
ChainType: types.BatchInfo_CHAIN_TYPE_INITIA,
ChainType: types.BatchInfo_INITIA,
}
output2 := types.Output{
OutputRoot: []byte{4, 5, 6},
Expand All @@ -38,7 +38,7 @@ func Test_SetGetBatchInfo(t *testing.T) {

batchInfo3 := types.BatchInfo{
Submitter: addrsStr[0],
ChainType: types.BatchInfo_CHAIN_TYPE_CELESTIA,
ChainType: types.BatchInfo_CELESTIA,
}
output3 := types.Output{
OutputRoot: []byte{1, 2, 3},
Expand All @@ -51,7 +51,7 @@ func Test_SetGetBatchInfo(t *testing.T) {

batchInfo4 := types.BatchInfo{
Submitter: addrsStr[1],
ChainType: types.BatchInfo_CHAIN_TYPE_CELESTIA,
ChainType: types.BatchInfo_CELESTIA,
}
output4 := types.Output{
OutputRoot: []byte{4, 5, 6},
Expand All @@ -64,7 +64,7 @@ func Test_SetGetBatchInfo(t *testing.T) {

batchInfo5 := types.BatchInfo{
Submitter: addrsStr[1],
ChainType: types.BatchInfo_CHAIN_TYPE_CELESTIA,
ChainType: types.BatchInfo_CELESTIA,
}
output5 := types.Output{
OutputRoot: []byte{4, 5, 6},
Expand Down
6 changes: 3 additions & 3 deletions x/ophost/keeper/bridge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func Test_BridgeConfig(t *testing.T) {
FinalizationPeriod: time.Second * 10,
SubmissionStartHeight: 1,
Metadata: []byte{1, 2, 3},
BatchInfo: types.BatchInfo{Submitter: addrsStr[0], ChainType: types.BatchInfo_CHAIN_TYPE_INITIA},
BatchInfo: types.BatchInfo{Submitter: addrsStr[0], ChainType: types.BatchInfo_INITIA},
}
require.NoError(t, input.OPHostKeeper.SetBridgeConfig(ctx, 1, config))
_config, err := input.OPHostKeeper.GetBridgeConfig(ctx, 1)
Expand All @@ -34,7 +34,7 @@ func Test_IterateBridgeConfig(t *testing.T) {
FinalizationPeriod: time.Second * 10,
SubmissionStartHeight: 1,
Metadata: []byte{1, 2, 3},
BatchInfo: types.BatchInfo{Submitter: addrsStr[0], ChainType: types.BatchInfo_CHAIN_TYPE_INITIA},
BatchInfo: types.BatchInfo{Submitter: addrsStr[0], ChainType: types.BatchInfo_INITIA},
}
config2 := types.BridgeConfig{
Challenger: addrs[2].String(),
Expand All @@ -43,7 +43,7 @@ func Test_IterateBridgeConfig(t *testing.T) {
FinalizationPeriod: time.Second * 10,
SubmissionStartHeight: 1,
Metadata: []byte{3, 4, 5},
BatchInfo: types.BatchInfo{Submitter: addrsStr[0], ChainType: types.BatchInfo_CHAIN_TYPE_INITIA},
BatchInfo: types.BatchInfo{Submitter: addrsStr[0], ChainType: types.BatchInfo_INITIA},
}
require.NoError(t, input.OPHostKeeper.SetBridgeConfig(ctx, 1, config1))
require.NoError(t, input.OPHostKeeper.SetBridgeConfig(ctx, 2, config2))
Expand Down
Loading

0 comments on commit 7da22a7

Please sign in to comment.