8000 chore(build): upgrade golang to 1.19 by MaxMustermann2 · Pull Request #4335 · harmony-one/harmony · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

chore(build): upgrade golang to 1.19 #4335

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

Merged
merged 6 commits into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ os: linux
dist: bionic
language: go
go:
- 1.18
- 1.19.5
go_import_path: github.com/harmony-one/harmony
cache:
directories:
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ubuntu:18.04

ARG TARGETARCH
ARG GOLANG_VERSION="1.18"
ARG GOLANG_VERSION="1.19"

SHELL ["/bin/bash", "-c"]

Expand Down Expand Up @@ -79,7 +79,7 @@ ARG KS3=f4267bb5a2f0e65b8f5792bb6992597fac2b35ebfac9885ce0f4152c451ca31a
RUN hmy keys import-private-key ${KS1} && \
hmy keys import-private-key ${KS2} && \
hmy keys import-private-key ${KS3} && \
hmy keys generate-bls-key > keys.json
hmy keys generate-bls-key > keys.json

RUN jq '.["encrypted-private-key-path"]' -r keys.json > /root/keypath && cp keys.json /root && \
echo "export BLS_KEY_PATH=$(cat /root/keypath)" >> /root/.bashrc && \
Expand Down
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ http://api.hmny.io/

## Requirements

### **Go 1.18**
### **Go 1.19**
### **GMP and OpenSSL**

On macOS:
Expand All @@ -35,19 +35,19 @@ sudo yum install glibc-static gmp-devel gmp-static openssl-libs openssl-static g
```
### **Docker** (for testing)

On macOS:
On macOS:
```bash
brew install --cask docker
open /Applications/Docker.app
```
On Linux, reference official documentation [here](https://docs.docker.com/engine/install/).
### **Bash 4+**
### **Bash 4+**

For macOS, you can reference this [guide](http://tldrdevnotes.com/bash-upgrade-3-4-macos). For Linux, you can reference this [guide](https://fossbytes.com/installing-gnu-bash-4-4-linux-distros/).

## Dev Environment

**Most repos from [harmony-one](https://github.com/harmony-one) assumes the GO AE88 PATH convention. More information [here](https://github.com/golang/go/wiki/GOPATH).**
**Most repos from [harmony-one](https://github.com/harmony-one) assumes the GOPATH convention. More information [here](https://github.com/golang/go/wiki/GOPATH).**

### First Install
Clone and set up all of the repos with the following set of commands:
Expand All @@ -57,7 +57,7 @@ Clone and set up all of the repos with the following set of commands:
mkdir -p $(go env GOPATH)/src/github.com/harmony-one
cd $(go env GOPATH)/src/github.com/harmony-one
```
> If you get 'unknown command' or something along those lines, make sure to install [golang](https://golang.org/doc/install) first.
> If you get 'unknown command' or something along those lines, make sure to install [golang](https://golang.org/doc/install) first.

2. Clone this repo & dependent repos.
```bash
Expand All @@ -77,9 +77,9 @@ make

## Dev Docker Image

Included in this repo is a Dockerfile that has a full harmony development environment and
comes with emacs, vim, ag, tig and other creature comforts. Most importantly, it already has the go environment
with our C/C++ based library dependencies (`libbls` and `mcl`) set up correctly for you.
Included in this repo is a Dockerfile that has a full harmony development environment and
comes with emacs, vim, ag, tig and other creature comforts. Most importantly, it already has the go environment
with our C/C++ based library dependencies (`libbls` and `mcl`) set up correctly for you.

You can build the docker image for yourself with the following commands:
```bash
Expand Down Expand Up @@ -110,7 +110,7 @@ Learn more about docker [here](https://docker-curriculum.com/).

## Build

The `make` command should automatically build the Harmony binary & all dependent libs.
The `make` command should automatically build the Harmony binary & all dependent libs.

However, if you wish to bypass the Makefile, first export the build flags:
```bash
Expand Down Expand Up @@ -150,7 +150,7 @@ make debug-kill

To keep things consistent, we have a docker image to run all tests. **These are the same tests ran on the pull request checks**.

Note that all testing docker container binds a couple of ports to the host machine for your convince. The ports are:
Note that all testing docker container binds a couple of ports to the host machine for your convince. The ports are:
* `9500` - Shard 0 RPC for a validator
* `9501` - Shard 1 RPC for a validator
* `9599` - Shard 0 RPC for an explorer
Expand All @@ -159,13 +159,13 @@ Note that all testing docker container binds a couple of ports to the host machi
* `9798` - Shard 1 Rosetta (for an explorer)
* `9899` - Shard 0 WS for an explorer
* `9898` - Shard 1 WS for an explorer
> This allows you to use curl, hmy CLI, postman, rosetta-cli, etc... on your host machine to play with or probe the localnet that was used for the test.
> This allows you to use curl, hmy CLI, postman, rosetta-cli, etc... on your host machine to play with or probe the localnet that was used for the test.

### Go tests
To run this test, do:
```bash
make test-go
```
```
This test runs the go tests along with go lint, go fmt, go imports, go mod, and go generate checks.

### RPC tests
Expand All @@ -174,7 +174,7 @@ To run this test, do:
make test-rpc
```
This test starts a localnet (within the Docker container), **ensures it reaches a consensus**, and runs a series of tests to ensure correct RPC behavior.
This test also acts as a preliminary integration test (more through tests are done on the testnets).
This test also acts as a preliminary integration test (more through tests are done on the testnets).
> The tests ran by this command can be found [here](https://github.com/harmony-one/harmony-test/tree/master/localnet).

If you wish to debug further with the localnet after the tests are done, open a new shell and run:
Expand All @@ -184,8 +184,8 @@ make test-rpc-attach
> This will open a shell in the docker container that is running the Node API tests.
>
> Note that the docker container has the [Harmony CLI](https://docs.harmony.one/home/wallets/harmony-cli) on path,
> therefore you can use that to debug if needed. For example, one could do `hmy blockchain latest-headers` to check
> the current block height of localnet. Reference the documentation for the CLI [here](https://docs.harmony.one/home/wallets/harmony-cli)
> therefore you can use that to debug if needed. For example, one could do `hmy blockchain latest-headers` to check
> the current block height of localnet. Reference the documentation for the CLI [here](https://docs.harmony.one/home/wallets/harmony-cli)
> for more details & commands.

### Rosetta tests
Expand Down
34 changes: 20 additions & 14 deletions accounts/abi/abi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,9 @@ func TestInvalidABI(t *testing.T) {

// TestConstructor tests a constructor function.
// The test is based on the following contract:
// contract TestConstructor {
// constructor(uint256 a, uint256 b) public{}
//
// contract TestConstructor {
// constructor(uint256 a, uint256 b) public{}
// }
func TestConstructor(t *testing.T) {
json := `[{ "inputs": [{"internalType": "uint256","name": "a","type": "uint256" },{ "internalType": "uint256","name": "b","type": "uint256"}],"stateMutability": "nonpayable","type": "constructor"}]`
Expand Down Expand Up @@ -707,16 +708,19 @@ func TestBareEvents(t *testing.T) {
}

// TestUnpackEvent is based on this contract:
// contract T {
// event received(address sender, uint amount, bytes memo);
// event receivedAddr(address sender);
// function receive(bytes memo) external payable {
// received(msg.sender, msg.value, memo);
// receivedAddr(msg.sender);
// }
// }
//
// contract T {
// event received(address sender, uint amount, bytes memo);
// event receivedAddr(address sender);
// function receive(bytes memo) external payable {
// received(msg.sender, msg.value, memo);
// receivedAddr(msg.sender);
// }
// }
//
// When receive("X") is called with sender 0x00... and value 1, it produces this tx receipt:
// receipt{status=1 cgas=23949 bloom=00000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 10000 000000000000000000000000000000000000000000000800000000000000000000000000000000000040200000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 logs=[log: b6818c8064f645cd82d99b59a1a267d6d61117ef [75fd880d39c1daf53b6547ab6cb59451fc6452d27caa90e5b6649dd8293b9eed] 000000000000000000000000376c47978271565f56deb45495afa69e59c16ab200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000158 9ae378b6d4409eada347a5dc0c180f186cb62dc68fcc0f043425eb917335aa28 0 95d429d309bb9d753954195fe2d69bd140b4ae731b9b5b605c34323de162cf00 0]}
//
// receipt{status=1 cgas=23949 bloom=00000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000040200000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 logs=[log: b6818c8064f645cd82d99b59a1a267d6d61117ef [75fd880d39c1daf53b6547ab6cb59451fc6452d27caa90e5b6649dd8293b9eed] 000000000000000000000000376c47978271565f56deb45495afa69e59c16ab200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000158 9ae378b6d4409eada347a5dc0c180f186cb62dc68fcc0f043425eb917335aa28 0 95d429d309bb9d753954195fe2d69bd140b4ae731b9b5b605c34323de162cf00 0]}
func TestUnpackEvent(t *testing.T) {
const abiJSON = `[{"constant":false,"inputs":[{"name":"memo","type":"bytes"}],"name":"receive","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"memo","type":"bytes"}],"name":"received","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"}],"name":"receivedAddr","type":"event"}]`
abi, err := JSON(strings.NewReader(abiJSON))
Expand Down Expand Up @@ -1063,8 +1067,9 @@ func TestDoubleDuplicateMethodNames(t *testing.T) {
// TestDoubleDuplicateEventNames checks that if send0 already exists, there won't be a name
// conflict and that the second send event will be renamed send1.
// The test runs the abi of the following contract.
// contract DuplicateEvent {
// event send(uint256 a);
//
// contract DuplicateEvent {
// event send(uint256 a);
// event send0();
// event send();
// }
Expand All @@ -1091,7 +1096,8 @@ func TestDoubleDuplicateEventNames(t *testing.T) {
// TestUnnamedEventParam checks that an event with unnamed parameters is
// correctly handled.
// The test runs the abi of the following contract.
// contract TestEvent {
//
// contract TestEvent {
// event send(uint256, uint256);
// }
func TestUnnamedEventParam(t *testing.T) {
Expand Down
22 changes: 14 additions & 8 deletions accounts/abi/reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ import (
// given type
// e.g. turn
// var fields []reflect.StructField
// fields = append(fields, reflect.StructField{
// Name: "X",
// Type: reflect.TypeOf(new(big.Int)),
// Tag: reflect.StructTag("json:\"" + "x" + "\""),
// }
//
// fields = append(fields, reflect.StructField{
// Name: "X",
// Type: reflect.TypeOf(new(big.Int)),
// Tag: reflect.StructTag("json:\"" + "x" + "\""),
// }
//
// into
// type TupleT struct { X *big.Int }
func ConvertType(in interface{}, proto interface{}) interface{} {
Expand Down Expand Up @@ -178,10 +180,14 @@ func setStruct(dst, src reflect.Value) error {

// mapArgNamesToStructFields maps a slice of argument names to struct fields.
// first round: for each Exportable field that contains a `abi:""` tag
// and this field name exists in the given argument name list, pair them together.
//
// and this field name exists in the given argument name list, pair them together.
//
// second round: for each argument name that has not been already linked,
// find what variable is expected to be mapped into, if it exists and has not been
// used, pair them.
//
// find what variable is expected to be mapped into, if it exists and has not been
// used, pair them.
//
// Note this function assumes the given value is a struct value.
func mapArgNamesToStructFields(argNames []string, value reflect.Value) (map[string]string, error) {
typ := value.Type()
Expand Down
6 changes: 4 additions & 2 deletions accounts/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ type Backend interface {
// safely used to calculate a signature from.
//
// The hash is calulcated as
// keccak256("\x19Ethereum Signed Message:\n"${message length}${message}).
//
// keccak256("\x19Ethereum Signed Message:\n"${message length}${message}).
//
// This gives context to the signed message and prevents signing of transactions.
func TextHash(data []byte) []byte {
Expand All @@ -188,7 +189,8 @@ func TextHash(data []byte) []byte {
// safely used to calculate a signature from.
//
// The hash is calulcated as
// keccak256("\x19Ethereum Signed Message:\n"${message length}${message}).
//
// keccak256("\x19Ethereum Signed Message:\n"${message length}${message}).
//
// This gives context to the signed message and prevents signing of transactions.
func TextAndHash(data []byte) ([]byte, string) {
Expand Down
2 changes: 1 addition & 1 deletion accounts/hd.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var LegacyLedgerBaseDerivationPath = DerivationPath{0x80000000 + 44, 0x80000000
// The BIP-32 spec https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki
// defines derivation paths to be of the form:
//
// m / purpose' / coin_type' / account' / change / address_index
// m / purpose' / coin_type' / account' / change / address_index
//
// The BIP-44 spec https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki
// defines that the `purpose` be 44' (or 0x8000002C) for crypto currencies, and
Expand Down
7 changes: 3 additions & 4 deletions accounts/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,9 @@ func (u *URL) UnmarshalJSON(input []byte) error {

// Cmp compares x and y and returns:
//
// -1 if x < y
// 0 if x == y
// +1 if x > y
//
// -1 if x < y
// 0 if x == y
// +1 if x > y
func (u URL) Cmp(url URL) int {
if u.Scheme == url.Scheme {
return strings.Compare(u.Path, url.Path)
Expand Down
2 changes: 1 addition & 1 deletion api/proto/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ n - 2 bytes - actual message payload
// MessageCategory defines the message category enum
type MessageCategory byte

//Consensus and other message categories
// Consensus and other message categories
const (
Consensus MessageCategory = iota
Node
Expand Down
4 changes: 3 additions & 1 deletion api/proto/message/message.pb.go

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

2 changes: 1 addition & 1 deletion api/service/legacysync/downloader/proto/downloader.pb.go

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

2 changes: 1 addition & 1 deletion api/service/stagedsync/stage_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func (stg *StageStates) Exec(firstCycle bool, invalidBlockRevert bool, s *StageS
return nil
}

//verifyBlockSignatures verifies block signatures
// verifyBlockSignatures verifies block signatures
func (stg *StageStates) verifyBlockSignatures(bc core.BlockChain, block *types.Block, verifyCurrentSig bool, verifySeal bool, verifyAllSig bool) (err error) {
if verifyCurrentSig {
sig, bitmap, err := chain.ParseCommitSigAndBitmap(block.GetCurrentCommitSig())
Expand Down
2 changes: 1 addition & 1 deletion common/denominations/denominations.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package denominations

//ONE Units
// ONE Units
const (
Atto = 1
Nano = 1e9
Expand Down
8 changes: 4 additions & 4 deletions common/math/big.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,10 @@ func U256Bytes(n *big.Int) []byte {
// S256 interprets x as a two's complement number.
// x must not exceed 256 bits (the result is undefined if it does) and is not modified.
//
// S256(0) = 0
// S256(1) = 1
// S256(2**255) = -2**255
// S256(2**256-1) = -1
// S256(0) = 0
// S256(1) = 1
// S256(2**255) = -2**255
// S256(2**256-1) = -1
func S256(x *big.Int) *big.Int {
if x.Cmp(tt255) < 0 {
return x
Expand Down
1 change: 1 addition & 0 deletions core/blockchain_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -3448,6 +3448,7 @@ var (
// 3. Corrupted db data. (leveldb.errors.ErrCorrupted)
// 4. OS error when open file (too many open files, ...)
// 5. OS error when write file (read-only, not enough disk space, ...)
//
// Among all the above leveldb errors, only `too many open files` error is known to be recoverable,
// thus the unrecoverable errors refers to error that is
// 1. The error is from the lower storage level (from module leveldb)
Expand Down
7 changes: 4 additions & 3 deletions core/headerchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ type HeaderChain struct {
}

// NewHeaderChain creates a new HeaderChain structure.
// getValidator should return the parent's validator
// procInterrupt points to the parent's interrupt semaphore
// wg points to the parent's shutdown wait group
//
// getValidator should return the parent's validator
// procInterrupt points to the parent's interrupt semaphore
// wg points to the parent's shutdown wait group
func NewHeaderChain(chainDb ethdb.Database, config *params.ChainConfig, engine consensus_engine.Engine, procInterrupt func() bool) (*HeaderChain, error) {
headerCache, _ := lru.New(headerCacheLimit)
tdCache, _ := lru.New(tdCacheLimit)
Expand Down
4 changes: 2 additions & 2 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,8 @@ func (db *DB) createObject(addr common.Address) (newobj, prev *Object) {
// CreateAccount is called during the EVM CREATE operation. The situation might arise that
// a contract does the following:
//
// 1. sends funds to sha(account ++ (nonce + 1))
// 2. tx_create(sha(account ++ nonce)) (note that this gets the address of 1)
// 1. sends funds to sha(account ++ (nonce + 1))
// 2. tx_create(sha(account ++ nonce)) (note that this gets the address of 1)
//
// Carrying over the balance ensures that Ether doesn't disappear.
func (db *DB) CreateAccount(addr common.Address) {
Expand Down
1 change: 0 additions & 1 deletion core/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
// Validator is an interface which defines the standard for block validation. It
// is only responsible for validating block contents, as the header validation is
// done by the specific consensus engines.
//
type Validator interface {
// ValidateBody validates the given block's content.
ValidateBody(block *types.Block) error
Expand Down
Loading
0