Skip to content

Commit

Permalink
chore: change ostracon and oc, ost prefix to tendermint term
Browse files Browse the repository at this point in the history
  • Loading branch information
zemyblue committed Nov 21, 2023
1 parent 84b136b commit cf41328
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 30 deletions.
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ linters-settings:
sections:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- prefix(github.com/Finschia/ostracon)
- prefix(github.com/Finschia/finschia-sdk)
revive:
rules:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ mocks: $(MOCKS_DIR)
mockgen -source=types/router.go -package mocks -destination tests/mocks/types_router.go
mockgen -source=types/handler.go -package mocks -destination tests/mocks/types_handler.go
mockgen -package mocks -destination tests/mocks/grpc_server.go github.com/gogo/protobuf/grpc Server
mockgen -package mocks -destination tests/mocks/tendermint_tendermint_libs_log_DB.go github.com/Finschia/ostracon/libs/log Logger
mockgen -package mocks -destination tests/mocks/tendermint_tendermint_libs_log_DB.go github.com/tendermint/tendermint/libs/log Logger
mockgen -source=x/stakingplus/expected_keepers.go -package testutil -destination x/stakingplus/testutil/expected_keepers_mocks.go
.PHONY: mocks

Expand Down
4 changes: 2 additions & 2 deletions client/grpc/tmservice/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ func (s queryServer) GetSyncing(ctx context.Context, _ *GetSyncingRequest) (*Get
}, nil
}

// ConvertOcProtoBlockToTmProtoBlock convert from tendermint proto block to tendermint proto block.
func ConvertOcProtoBlockToTmProtoBlock(block *tmtypes.Block) *tmtypes.Block {
// ConvertTmProtoBlockToTmProtoBlock convert from tendermint proto block to tendermint proto block.
func ConvertTmProtoBlockToTmProtoBlock(block *tmtypes.Block) *tmtypes.Block {

Check warning on line 51 in client/grpc/tmservice/service.go

View check run for this annotation

Codecov / codecov/patch

client/grpc/tmservice/service.go#L51

Added line #L51 was not covered by tests
return &tmtypes.Block{
Header: block.Header,
Data: block.Data,
Expand Down
14 changes: 7 additions & 7 deletions crypto/keys/secp256k1/secp256k1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,10 @@ func TestMarshalAmino(t *testing.T) {
func TestMarshalAmino_BackwardsCompatibility(t *testing.T) {
aminoCdc := codec.NewLegacyAmino()
// Create tendermint keys.
ostPrivKey := tmsecp256k1.GenPrivKey()
ostPubKey := ostPrivKey.PubKey()
tmPrivKey := tmsecp256k1.GenPrivKey()
tmPubKey := tmPrivKey.PubKey()
// Create our own keys, with the same private key as Tendermint's.
privKey := &secp256k1.PrivKey{Key: []byte(ostPrivKey)}
privKey := &secp256k1.PrivKey{Key: []byte(tmPrivKey)}
pubKey := privKey.PubKey().(*secp256k1.PubKey)

testCases := []struct {
Expand All @@ -415,25 +415,25 @@ func TestMarshalAmino_BackwardsCompatibility(t *testing.T) {
}{
{
"secp256k1 private key, binary",
ostPrivKey,
tmPrivKey,
privKey,
aminoCdc.Marshal,
},
{
"secp256k1 private key, JSON",
ostPrivKey,
tmPrivKey,
privKey,
aminoCdc.MarshalJSON,
},
{
"secp256k1 public key, binary",
ostPubKey,
tmPubKey,
pubKey,
aminoCdc.Marshal,
},
{
"secp256k1 public key, JSON",
ostPubKey,
tmPubKey,
pubKey,
aminoCdc.MarshalJSON,
},
Expand Down
2 changes: 1 addition & 1 deletion crypto/ledger/ledger_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (mock LedgerSECP256K1Mock) GetAddressPubKeySECP256K1(derivationPath []uint3
compressedPublicKey := make([]byte, csecp256k1.PubKeySize)
copy(compressedPublicKey, cmp.SerializeCompressed())

// Generate the bech32 addr using existing ostcrypto/etc.
// Generate the bech32 addr using existing tmcrypto/etc.
pub := &csecp256k1.PubKey{Key: compressedPublicKey}
addr := sdk.AccAddress(pub.Address()).String()
return pk, addr, err
Expand Down
2 changes: 1 addition & 1 deletion x/capability/spec/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func NewApp(...) *App {
// Initialize and seal the capability keeper so all persistent capabilities
// are loaded in-memory and prevent any further modules from creating scoped
// sub-keepers.
ctx := app.BaseApp.NewContext(true, ocproto.Header{})
ctx := app.BaseApp.NewContext(true, tmproto.Header{})
app.capabilityKeeper.InitializeAndSeal(ctx)

return app
Expand Down
20 changes: 10 additions & 10 deletions x/staking/teststaking/tm.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package teststaking

import (
occrypto "github.com/tendermint/tendermint/crypto"
tmcrypto "github.com/tendermint/tendermint/crypto"
tmtypes "github.com/tendermint/tendermint/types"

cryptocodec "github.com/Finschia/finschia-sdk/crypto/codec"
sdk "github.com/Finschia/finschia-sdk/types"
"github.com/Finschia/finschia-sdk/x/staking/types"
)

// GetOcConsPubKey gets the validator's public key as an occrypto.PubKey.
func GetOcConsPubKey(v types.Validator) (occrypto.PubKey, error) {
// GetTmConsPubKey gets the validator's public key as an tmcrypto.PubKey.
func GetTmConsPubKey(v types.Validator) (tmcrypto.PubKey, error) {
pk, err := v.ConsPubKey()
if err != nil {
return nil, err
Expand All @@ -19,22 +19,22 @@ func GetOcConsPubKey(v types.Validator) (occrypto.PubKey, error) {
return cryptocodec.ToTmPubKeyInterface(pk)
}

// ToOcValidator casts an SDK validator to a tendermint type Validator.
func ToOcValidator(v types.Validator, r sdk.Int) (*tmtypes.Validator, error) {
ocPk, err := GetOcConsPubKey(v)
// ToTmValidator casts an SDK validator to a tendermint type Validator.
func ToTmValidator(v types.Validator, r sdk.Int) (*tmtypes.Validator, error) {
tmPk, err := GetTmConsPubKey(v)
if err != nil {
return nil, err
}

return tmtypes.NewValidator(ocPk, v.ConsensusPower(r)), nil
return tmtypes.NewValidator(tmPk, v.ConsensusPower(r)), nil
}

// ToOcValidators casts all validators to the corresponding tendermint type.
func ToOcValidators(v types.Validators, r sdk.Int) ([]*tmtypes.Validator, error) {
// ToTmValidators casts all validators to the corresponding tendermint type.
func ToTmValidators(v types.Validators, r sdk.Int) ([]*tmtypes.Validator, error) {
validators := make([]*tmtypes.Validator, len(v))
var err error
for i, val := range v {
validators[i], err = ToOcValidator(val, r)
validators[i], err = ToTmValidator(val, r)
if err != nil {
return nil, err
}
Expand Down
8 changes: 4 additions & 4 deletions x/staking/types/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,27 +257,27 @@ func (d Description) EnsureLength() (Description, error) {
// ABCIValidatorUpdate returns an abci.ValidatorUpdate from a staking validator type
// with the full validator power
func (v Validator) ABCIValidatorUpdate(r sdk.Int) abci.ValidatorUpdate {
ocProtoPk, err := v.TmConsPublicKey()
tmProtoPk, err := v.TmConsPublicKey()
if err != nil {
panic(err)
}

return abci.ValidatorUpdate{
PubKey: ocProtoPk,
PubKey: tmProtoPk,
Power: v.ConsensusPower(r),
}
}

// ABCIValidatorUpdateZero returns an abci.ValidatorUpdate from a staking validator type
// with zero power used for validator updates.
func (v Validator) ABCIValidatorUpdateZero() abci.ValidatorUpdate {
ocprotoPk, err := v.TmConsPublicKey()
tmProtoPk, err := v.TmConsPublicKey()
if err != nil {
panic(err)
}

return abci.ValidatorUpdate{
PubKey: ocprotoPk,
PubKey: tmProtoPk,
Power: 0,
}
}
Expand Down
6 changes: 3 additions & 3 deletions x/staking/types/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,15 @@ func TestValidatorsSortTendermint(t *testing.T) {
valz := types.Validators(vals)

// create expected tendermint validators by converting to tendermint then sorting
expectedVals, err := teststaking.ToOcValidators(valz, sdk.DefaultPowerReduction)
expectedVals, err := teststaking.ToTmValidators(valz, sdk.DefaultPowerReduction)
require.NoError(t, err)
sort.Sort(tmtypes.ValidatorsByVotingPower(expectedVals))

// sort in SDK and then convert to tendermint
sort.SliceStable(valz, func(i, j int) bool {
return types.ValidatorsByVotingPower(valz).Less(i, j, sdk.DefaultPowerReduction)
})
actualVals, err := teststaking.ToOcValidators(valz, sdk.DefaultPowerReduction)
actualVals, err := teststaking.ToTmValidators(valz, sdk.DefaultPowerReduction)
require.NoError(t, err)

require.Equal(t, expectedVals, actualVals, "sorting in SDK is not the same as sorting in Tendermint")
Expand All @@ -315,7 +315,7 @@ func TestValidatorToTm(t *testing.T) {
require.NoError(t, err)
expected[i] = tmtypes.NewValidator(tmPk, val.ConsensusPower(sdk.DefaultPowerReduction))
}
vs, err := teststaking.ToOcValidators(vals, sdk.DefaultPowerReduction)
vs, err := teststaking.ToTmValidators(vals, sdk.DefaultPowerReduction)
require.NoError(t, err)
require.Equal(t, expected, vs)
}
Expand Down

0 comments on commit cf41328

Please sign in to comment.