Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backport/v0.41.x]: Compatibility with the ARM architecture #8450

Merged
merged 3 commits into from
Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,26 @@ jobs:
path: ~/go/bin
key: ${{ runner.os }}-go-tparse-binary

build:
runs-on: ubuntu-latest
strategy:
matrix:
go-arch: ["amd64", "arm", "arm64"]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2.1.3
with:
go-version: 1.15
- uses: technote-space/get-diff-action@v4
id: git_diff
with:
PATTERNS: |
**/**.go
go.mod
go.sum
- name: Build
run: GOARCH=${{ matrix.go-arch }} LEDGER_ENABLED=false make build

test-cosmovisor:
runs-on: ubuntu-latest
steps:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ Ref: https://keepachangelog.com/en/1.0.0/

# Changelog

## [Unreleased]

### Improvements

* [\#8396](https://github.com/cosmos/cosmos-sdk/pull/8396) Add support for ARM platform

## [v0.41.0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.41.0) - 2021-01-26

### State Machine Breaking
Expand Down
6 changes: 3 additions & 3 deletions snapshots/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (s *Store) Get(height uint64, format uint32) (*types.Snapshot, error) {

// Get fetches the latest snapshot from the database, if any.
func (s *Store) GetLatest() (*types.Snapshot, error) {
iter, err := s.db.ReverseIterator(encodeKey(0, 0), encodeKey(math.MaxUint64, math.MaxUint32))
iter, err := s.db.ReverseIterator(encodeKey(0, 0), encodeKey(uint64(math.MaxUint64), math.MaxUint32))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this is needed? Isn't math.MaxUint64 already uint64?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All casts are related to this Go specification

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's an untyped constant: https://golang.org/ref/spec#Constants (not a bug, a feature! :))

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, exactly. constants will adapt to the expected types. The encodeKey has following declaration:

func encodeKey(height uint64, format uint32) []byte

so the math.MaxUint64 will automatically become uint64 - seems that this conversion is not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was actually re-reviewing this and you're right. In master we should revise the code patch as follows:

  1. revert it
  2. build multi-arch
  3. fix build errors one by one

if err != nil {
return nil, sdkerrors.Wrap(err, "failed to find latest snapshot")
}
Expand All @@ -111,7 +111,7 @@ func (s *Store) GetLatest() (*types.Snapshot, error) {

// List lists snapshots, in reverse order (newest first).
func (s *Store) List() ([]*types.Snapshot, error) {
iter, err := s.db.ReverseIterator(encodeKey(0, 0), encodeKey(math.MaxUint64, math.MaxUint32))
iter, err := s.db.ReverseIterator(encodeKey(0, 0), encodeKey(uint64(math.MaxUint64), math.MaxUint32))
if err != nil {
return nil, sdkerrors.Wrap(err, "failed to list snapshots")
}
Expand Down Expand Up @@ -181,7 +181,7 @@ func (s *Store) loadChunkFile(height uint64, format uint32, chunk uint32) (io.Re

// Prune removes old snapshots. The given number of most recent heights (regardless of format) are retained.
func (s *Store) Prune(retain uint32) (uint64, error) {
iter, err := s.db.ReverseIterator(encodeKey(0, 0), encodeKey(math.MaxUint64, math.MaxUint32))
iter, err := s.db.ReverseIterator(encodeKey(0, 0), encodeKey(uint64(math.MaxUint64), math.MaxUint32))
if err != nil {
return 0, sdkerrors.Wrap(err, "failed to prune snapshots")
}
Expand Down
4 changes: 2 additions & 2 deletions store/rootmulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -711,9 +711,9 @@ func (rs *Store) Restore(
if height == 0 {
return sdkerrors.Wrap(sdkerrors.ErrLogic, "cannot restore snapshot at height 0")
}
if height > math.MaxInt64 {
if height > uint64(math.MaxInt64) {
return sdkerrors.Wrapf(snapshottypes.ErrInvalidMetadata,
"snapshot height %v cannot exceed %v", height, math.MaxInt64)
"snapshot height %v cannot exceed %v", height, int64(math.MaxInt64))
}

// Signal readiness. Must be done before the readers below are set up, since the zlib
Expand Down
4 changes: 2 additions & 2 deletions x/ibc/applications/transfer/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ func ValidateTransferChannelParams(
if err != nil {
return err
}
if channelSequence > math.MaxUint32 {
return sdkerrors.Wrapf(types.ErrMaxTransferChannels, "channel sequence %d is greater than max allowed transfer channels %d", channelSequence, math.MaxUint32)
if channelSequence > uint64(math.MaxUint32) {
return sdkerrors.Wrapf(types.ErrMaxTransferChannels, "channel sequence %d is greater than max allowed transfer channels %d", channelSequence, uint64(math.MaxUint32))
}
if order != channeltypes.UNORDERED {
return sdkerrors.Wrapf(channeltypes.ErrInvalidChannelOrdering, "expected %s channel, got %s ", channeltypes.UNORDERED, order)
Expand Down
2 changes: 1 addition & 1 deletion x/ibc/core/02-client/types/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func ValidateClientType(clientType string) error {
}

smallestPossibleClientID := FormatClientIdentifier(clientType, 0)
largestPossibleClientID := FormatClientIdentifier(clientType, math.MaxUint64)
largestPossibleClientID := FormatClientIdentifier(clientType, uint64(math.MaxUint64))

// IsValidClientID will check client type format and if the sequence is a uint64
if !IsValidClientID(smallestPossibleClientID) {
Expand Down