Skip to content

Commit

Permalink
chg: address PR comments / temp comment out scheduled CI jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
marcello33 committed Jan 29, 2024
1 parent 7e59e70 commit d2cc050
Show file tree
Hide file tree
Showing 25 changed files with 579 additions and 396 deletions.
508 changes: 254 additions & 254 deletions .github/dependabot.yml

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions .github/workflows/clean-action-artifacts.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
name: Remove GitHub Action Old Artifacts

on:
schedule:
# Every day at 1am
- cron: "0 1 * * *"

jobs:
remove-old-artifacts:
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- name: Remove old artifacts
uses: c-hive/gha-remove-artifacts@v1
with:
age: "7 days"
#name: Remove GitHub Action Old Artifacts
#
#on:
# schedule:
# # Every day at 1am
# - cron: "0 1 * * *"
#
#jobs:
# remove-old-artifacts:
# runs-on: ubuntu-latest
# timeout-minutes: 30
#
# steps:
# - name: Remove old artifacts
# uses: c-hive/gha-remove-artifacts@v1
# with:
# age: "7 days"
4 changes: 2 additions & 2 deletions .github/workflows/sims-045.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Sims release/0.45.x
# Sims workflow runs multiple types of simulations (nondeterminism, import-export, after-import, multi-seed-short)
# This workflow will run on all Pull Requests, if a .go, .mod or .sum file have been changed
on:
schedule:
- cron: "0 0,12 * * *"
# schedule:
# - cron: "0 0,12 * * *"
release:
types: [published]

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sims-046.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Sims release/0.46.x
# Sims workflow runs multiple types of simulations (nondeterminism, import-export, after-import, multi-seed-short)
# This workflow will run on all Pull Requests, if a .go, .mod or .sum file have been changed
on:
schedule:
- cron: "0 0,12 * * *"
# schedule:
# - cron: "0 0,12 * * *"
release:
types: [published]

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sims-047.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Sims release/0.47.x
# Sims workflow runs multiple types of simulations (nondeterminism, import-export, after-import, multi-seed-short)
# This workflow will run on all Pull Requests, if a .go, .mod or .sum file have been changed
on:
schedule:
- cron: "0 0,12 * * *"
# schedule:
# - cron: "0 0,12 * * *"
release:
types: [published]

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sims-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Sims Nightly (Long)
# Release Sims workflow runs long-lived (multi-seed & large block size) simulations
# This workflow only runs mightly at 8am UTC and on releases
on:
schedule:
- cron: "0 8 * * *"
# schedule:
# - cron: "0 8 * * *"
release:
types: [published]

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sims.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Sims
# Sims workflow runs multiple types of simulations (nondeterminism, import-export, after-import, multi-seed-short)
# This workflow will run on all Pull Requests, if a .go, .mod or .sum file have been changed
on:
schedule:
- cron: "0 */2 * * *"
# schedule:
# - cron: "0 */2 * * *"
release:
types: [published]

Expand Down
52 changes: 26 additions & 26 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
name: "Close stale issues & pull requests"
on:
schedule:
- cron: "0 0 * * *"

permissions:
contents: read

jobs:
stale:
permissions:
issues: write # for actions/stale to close stale issues
pull-requests: write # for actions/stale to close stale PRs
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v8
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-pr-message: "This pull request has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions."
days-before-stale: -1
days-before-close: -1
days-before-pr-stale: 30
days-before-pr-close: 4
exempt-pr-labels: "pinned, security, proposal, blocked"
#name: "Close stale issues & pull requests"
#on:
# schedule:
# - cron: "0 0 * * *"
#
#permissions:
# contents: read
#
#jobs:
# stale:
# permissions:
# issues: write # for actions/stale to close stale issues
# pull-requests: write # for actions/stale to close stale PRs
# runs-on: ubuntu-latest
# steps:
# - uses: actions/stale@v8
# with:
# repo-token: ${{ secrets.GITHUB_TOKEN }}
# stale-pr-message: "This pull request has been automatically marked as stale because it has not had
# recent activity. It will be closed if no further activity occurs. Thank you
# for your contributions."
# days-before-stale: -1
# days-before-close: -1
# days-before-pr-stale: 30
# days-before-pr-close: 4
# exempt-pr-labels: "pinned, security, proposal, blocked"
35 changes: 34 additions & 1 deletion client/keys/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func Test_multiSigKey_Properties(t *testing.T) {

addr, err := k.GetAddress()
require.NoError(t, err)
require.Equal(t, "cosmos16wfryel63g7axeamw68630wglalcnk3l0zuadc", sdk.MustHexifyAddressBytes("cosmos", addr))
require.Equal(t, "cosmos16wfryel63g7axeamw68630wglalcnk3l0zuadc", sdk.MustHexifyAddressBytes(addr))
}

func Test_showKeysCmd(t *testing.T) {
Expand Down Expand Up @@ -186,3 +186,36 @@ func Test_validateMultisigThreshold(t *testing.T) {
})
}
}

// TODO HV2: removed as irrelevant to Heimdall
/*
func Test_getBechKeyOut(t *testing.T) {
type args struct {
bechPrefix string
}
tests := []struct {
name string
args args
want bechKeyOutFn
wantErr bool
}{
{"empty", args{""}, nil, true},
{"wrong", args{"???"}, nil, true},
{"acc", args{sdk.PrefixAccount}, MkAccKeyOutput, false},
{"val", args{sdk.PrefixValidator}, MkValKeyOutput, false},
{"cons", args{sdk.PrefixConsensus}, MkConsKeyOutput, false},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
got, err := getBechKeyOut(tt.args.bechPrefix)
if tt.wantErr {
require.Error(t, err)
} else {
require.NoError(t, err)
require.NotNil(t, got)
}
})
}
}
*/
8 changes: 4 additions & 4 deletions types/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ func (ca ConsAddress) String() string {
// HexifyAddressBytes returns a hex representation of address bytes.
// Returns an empty string if the byte slice is 0-length. Returns an error if the hex conversion
// fails or the prefix is empty.
func HexifyAddressBytes(_ string, bs []byte) (string, error) {
func HexifyAddressBytes(bs []byte) (string, error) {
if len(bs) == 0 {
return "", nil
}
Expand All @@ -441,8 +441,8 @@ func HexifyAddressBytes(_ string, bs []byte) (string, error) {
// MustHexifyAddressBytes returns a hex representation of address bytes.
// Returns an empty sting if the byte slice is 0-length. It panics if the hex conversion
// fails or the prefix is empty.
func MustHexifyAddressBytes(prefix string, bs []byte) string {
s, err := HexifyAddressBytes(prefix, bs)
func MustHexifyAddressBytes(bs []byte) string {
s, err := HexifyAddressBytes(bs)
if err != nil {
panic(err)
}
Expand All @@ -467,7 +467,7 @@ func (ca ConsAddress) Format(s fmt.State, verb rune) {
// ----------------------------------------------------------------------------

// GetFromHex decodes a bytestring from a hex encoded string.
func GetFromHex(hexStr, _ string) ([]byte, error) {
func GetFromHex(hexStr string) ([]byte, error) {
return addressBytesFromHexString(hexStr)
}

Expand Down
70 changes: 64 additions & 6 deletions types/address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/types"
//nolint:staticcheck
)

type addressTestSuite struct {
Expand Down Expand Up @@ -250,6 +249,65 @@ func RandString(n int) string {
return string(b)
}

// TODO HV2: removed as irrelevant to Heimdall
/*
func (s *addressTestSuite) TestConfiguredPrefix() {
pubBz := make([]byte, ed25519.PubKeySize)
pub := &ed25519.PubKey{Key: pubBz}
for length := 1; length < 10; length++ {
for times := 1; times < 20; times++ {
rand.Read(pub.Key[:])
// Test if randomly generated prefix of a given length works
prefix := RandString(length)
// Assuming that GetConfig is not sealed.
config := types.GetConfig()
config.SetBech32PrefixForAccount(
prefix+types.PrefixAccount,
prefix+types.PrefixPublic)
acc := types.AccAddress(pub.Address())
s.Require().True(strings.HasPrefix(
acc.String(),
prefix+types.PrefixAccount), acc.String())
bech32Pub := legacybech32.MustMarshalPubKey(legacybech32.AccPK, pub) //nolint:staticcheck // SA1019: legacybech32 is deprecated: use the bech32 package instead.
s.Require().True(strings.HasPrefix(
bech32Pub,
prefix+types.PrefixPublic))
config.SetBech32PrefixForValidator(
prefix+types.PrefixValidator+types.PrefixAddress,
prefix+types.PrefixValidator+types.PrefixPublic)
val := types.ValAddress(pub.Address())
s.Require().True(strings.HasPrefix(
val.String(),
prefix+types.PrefixValidator+types.PrefixAddress))
bech32ValPub := legacybech32.MustMarshalPubKey(legacybech32.ValPK, pub) //nolint:staticcheck // SA1019: legacybech32 is deprecated: use the bech32 package instead.
s.Require().True(strings.HasPrefix(
bech32ValPub,
prefix+types.PrefixValidator+types.PrefixPublic))
config.SetBech32PrefixForConsensusNode(
prefix+types.PrefixConsensus+types.PrefixAddress,
prefix+types.PrefixConsensus+types.PrefixPublic)
cons := types.ConsAddress(pub.Address())
s.Require().True(strings.HasPrefix(
cons.String(),
prefix+types.PrefixConsensus+types.PrefixAddress))
bech32ConsPub := legacybech32.MustMarshalPubKey(legacybech32.ConsPK, pub) //nolint:staticcheck // SA1019: legacybech32 is deprecated: use the bech32 package instead.
s.Require().True(strings.HasPrefix(
bech32ConsPub,
prefix+types.PrefixConsensus+types.PrefixPublic))
}
}
}
*/

func (s *addressTestSuite) TestAddressInterface() {
pubBz := make([]byte, ed25519.PubKeySize)
pub := &ed25519.PubKey{Key: pubBz}
Expand Down Expand Up @@ -362,7 +420,7 @@ func (s *addressTestSuite) TestBech32ifyAddressBytes() {
for _, tt := range tests {
tt := tt
s.T().Run(tt.name, func(t *testing.T) {
got, err := types.HexifyAddressBytes(tt.args.prefix, tt.args.bs)
got, err := types.HexifyAddressBytes(tt.args.bs)
if (err != nil) != tt.wantErr {
t.Errorf("Bech32ifyBytes() error = %v, wantErr %v", err, tt.wantErr)
return
Expand Down Expand Up @@ -396,10 +454,10 @@ func (s *addressTestSuite) TestMustBech32ifyAddressBytes() {
tt := tt
s.T().Run(tt.name, func(t *testing.T) {
if tt.wantPanic {
require.Panics(t, func() { types.MustHexifyAddressBytes(tt.args.prefix, tt.args.bs) })
require.Panics(t, func() { types.MustHexifyAddressBytes(tt.args.bs) })
return
}
require.Equal(t, tt.want, types.MustHexifyAddressBytes(tt.args.prefix, tt.args.bs))
require.Equal(t, tt.want, types.MustHexifyAddressBytes(tt.args.bs))
})
}
}
Expand Down Expand Up @@ -458,10 +516,10 @@ func (s *addressTestSuite) TestGetConsAddress() {
}

func (s *addressTestSuite) TestGetFromBech32() {
_, err := types.GetFromHex("", "prefix")
_, err := types.GetFromHex("")
s.Require().Error(err)
s.Require().Equal("decoding Bech32 address failed: must provide a non empty address", err.Error())
_, err = types.GetFromHex("cosmos1qqqsyqcyq5rqwzqfys8f67", "x")
_, err = types.GetFromHex("cosmos1qqqsyqcyq5rqwzqfys8f67")
s.Require().Error(err)
s.Require().Equal("invalid Bech32 prefix; expected x, got cosmos", err.Error())
}
4 changes: 1 addition & 3 deletions types/bech32/legacybech32/pk.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ func getPrefix(pkt Bech32PubKeyType) string {
// Deprecated: UnmarshalPubKey returns a PublicKey from a bech32-encoded PublicKey with
// a given key type.
func UnmarshalPubKey(pkt Bech32PubKeyType, pubkeyStr string) (cryptotypes.PubKey, error) {
bech32Prefix := getPrefix(pkt)

bz, err := sdk.GetFromHex(pubkeyStr, bech32Prefix)
bz, err := sdk.GetFromHex(pubkeyStr)
if err != nil {
return nil, err
}
Expand Down
6 changes: 6 additions & 0 deletions types/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,10 @@ var (

// ErrPanic should only be set when we recovering from a panic
ErrPanic = errorsmod.ErrPanic

// ErrSetBlockProposer defines an error when setting the block proposer fails.
ErrSetBlockProposer = errorsmod.Register(RootCodespace, 43, "error setting block proposer")

// ErrRemoveBlockProposer defines an error when removing the block proposer fails.
ErrRemoveBlockProposer = errorsmod.Register(RootCodespace, 44, "error removing block proposer")
)
Loading

0 comments on commit d2cc050

Please sign in to comment.