chore(build): upgrade golang to 1.19 (#4335)

* chore(build): upgrade golang to 1.19

* chore(build): run `go mod tidy`

* chore(build): run `goimports -w -e ${file}`

* chore(build): revert github ci changes

* chore(build): pin golang version to 1.19.5

* chore(build): fix protoc version on gen files
pull/4337/head
Max 2 years ago committed by GitHub
parent 5e35d5f6ba
commit b300a4ec4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .travis.yml
  2. 2
      Dockerfile
  3. 2
      README.md
  4. 34
      accounts/abi/abi_test.go
  5. 22
      accounts/abi/reflect.go
  6. 6
      accounts/accounts.go
  7. 2
      accounts/hd.go
  8. 7
      accounts/url.go
  9. 2
      api/proto/common.go
  10. 4
      api/proto/message/message.pb.go
  11. 2
      api/service/legacysync/downloader/proto/downloader.pb.go
  12. 2
      api/service/stagedsync/stage_state.go
  13. 2
      common/denominations/denominations.go
  14. 8
      common/math/big.go
  15. 1
      core/blockchain_impl.go
  16. 7
      core/headerchain.go
  17. 4
      core/state/statedb.go
  18. 1
      core/types.go
  19. 3
      core/types/block.go
  20. 18
      core/vm/gas_table.go
  21. 19
      core/vm/instructions.go
  22. 57
      eth/rpc/doc.go
  23. 15
      eth/rpc/handler.go
  24. 1
      go.mod
  25. 6
      go.sum
  26. 12
      hmy/tracers/internal/tracers/assets.go
  27. 5
      internal/blsgen/helper.go
  28. 23
      internal/blsgen/kms.go
  29. 5
      internal/blsgen/loader.go
  30. 18
      internal/blsgen/passphrase.go
  31. 9
      internal/cli/parse.go
  32. 2
      internal/tikv/redis_helper/pubsub.go
  33. 13
      numeric/decimal.go
  34. 5
      p2p/stream/common/ratelimiter/ratelimiter.go
  35. 2
      p2p/stream/protocols/sync/message/compose.go
  36. 5
      p2p/stream/protocols/sync/message/msg.pb.go
  37. 3
      p2p/stream/types/utils.go
  38. 2
      rosetta/infra/Dockerfile
  39. 2
      scripts/travis_go_checker.sh
  40. 5
      shard/values.go

@ -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:

@ -1,7 +1,7 @@
FROM ubuntu:18.04
ARG TARGETARCH
ARG GOLANG_VERSION="1.18"
ARG GOLANG_VERSION="1.19"
SHELL ["/bin/bash", "-c"]

@ -16,7 +16,7 @@ http://api.hmny.io/
## Requirements
### **Go 1.18**
### **Go 1.19**
### **GMP and OpenSSL**
On macOS:

@ -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"}]`
@ -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=00000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000040200000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 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))
@ -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();
// }
@ -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) {

@ -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{} {
@ -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()

@ -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 {
@ -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) {

@ -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

@ -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)

@ -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

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.26.0
// protoc-gen-go v1.28.1
// protoc v3.15.8
// source: message.proto
@ -219,6 +219,7 @@ type Message struct {
Type MessageType `protobuf:"varint,2,opt,name=type,proto3,enum=message.MessageType" json:"type,omitempty"`
Signature []byte `protobuf:"bytes,3,opt,name=signature,proto3" json:"signature,omitempty"`
// Types that are assignable to Request:
//
// *Message_Staking
// *Message_Consensus
// *Message_Drand
@ -372,6 +373,7 @@ type Response struct {
ServiceType ServiceType `protobuf:"varint,1,opt,name=service_type,json=serviceType,proto3,enum=message.ServiceType" json:"service_type,omitempty"`
Type MessageType `protobuf:"varint,2,opt,name=type,proto3,enum=message.MessageType" json:"type,omitempty"`
// Types that are assignable to Response:
//
// *Response_LotteryResponse
Response isResponse_Response `protobuf_oneof:"response"`
}

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.26.0
// protoc-gen-go v1.28.1
// protoc v3.15.8
// source: downloader.proto

@ -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())

@ -1,6 +1,6 @@
package denominations
//ONE Units
// ONE Units
const (
Atto = 1
Nano = 1e9

@ -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

@ -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)

@ -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)

@ -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) {

@ -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

@ -139,7 +139,8 @@ type Body struct {
// matches the version of the given field.
//
// TODO ek – this is a stopgap, and works only while there is a N:1 mapping
// between header and body versions. Replace usage with factory.
//
// between header and body versions. Replace usage with factory.
func NewBodyForMatchingHeader(h *block.Header) (*Body, error) {
var bi BodyInterface
switch h.Header.(type) {

@ -162,19 +162,19 @@ func gasSStore(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySi
return params.NetSstoreDirtyGas, nil
}
// 0. If *gasleft* is less than or equal to 2300, fail the current call.
// 1. If current value equals new value (this is a no-op), SSTORE_NOOP_GAS gas is deducted.
// 2. If current value does not equal new value:
// 2.1. If original value equals current value (this storage slot has not been changed by the current execution context):
// 0. If *gasleft* is less than or equal to 2300, fail the current call.
// 1. If current value equals new value (this is a no-op), SSTORE_NOOP_GAS gas is deducted.
// 2. If current value does not equal new value:
// 2.1. If original value equals current value (this storage slot has not been changed by the current execution context):
// 2.1.1. If original value is 0, SSTORE_INIT_GAS gas is deducted.
// 2.1.2. Otherwise, SSTORE_CLEAN_GAS gas is deducted. If new value is 0, add SSTORE_CLEAR_REFUND to refund counter.
// 2.2. If original value does not equal current value (this storage slot is dirty), SSTORE_DIRTY_GAS gas is deducted. Apply both of the following clauses:
// 2.2. If original value does not equal current value (this storage slot is dirty), SSTORE_DIRTY_GAS gas is deducted. Apply both of the following clauses:
// 2.2.1. If original value is not 0:
// 2.2.1.1. If current value is 0 (also means that new value is not 0), subtract SSTORE_CLEAR_REFUND gas from refund counter. We can prove that refund counter will never go below 0.
// 2.2.1.2. If new value is 0 (also means that current value is not 0), add SSTORE_CLEAR_REFUND gas to refund counter.
// 2.2.1.1. If current value is 0 (also means that new value is not 0), subtract SSTORE_CLEAR_REFUND gas from refund counter. We can prove that refund counter will never go below 0.
// 2.2.1.2. If new value is 0 (also means that current value is not 0), add SSTORE_CLEAR_REFUND gas to refund counter.
// 2.2.2. If original value equals new value (this storage slot is reset):
// 2.2.2.1. If original value is 0, add SSTORE_INIT_REFUND to refund counter.
// 2.2.2.2. Otherwise, add SSTORE_CLEAN_REFUND gas to refund counter.
// 2.2.2.1. If original value is 0, add SSTORE_INIT_REFUND to refund counter.
// 2.2.2.2. Otherwise, add SSTORE_CLEAN_REFUND gas to refund counter.
func gasSStoreEIP2200(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) {
// If we fail the minimum gas availability invariant, fail (0)
if contract.Gas <= params.SstoreSentryGasEIP2200 {

@ -519,16 +519,21 @@ func opExtCodeCopy(pc *uint64, interpreter *EVMInterpreter, contract *Contract,
// opExtCodeHash returns the code hash of a specified account.
// There are several cases when the function is called, while we can relay everything
// to `state.GetCodeHash` function to ensure the correctness.
// (1) Caller tries to get the code hash of a normal contract account, state
//
// (1) Caller tries to get the code hash of a normal contract account, state
//
// should return the relative code hash and set it as the result.
//
// (2) Caller tries to get the code hash of a non-existent account, state should
// (2) Caller tries to get the code hash of a non-existent account, state should
//
// return common.Hash{} and zero will be set as the result.
//
// (3) Caller tries to get the code hash for an account without contract code,
// (3) Caller tries to get the code hash for an account without contract code,
//
// state should return emptyCodeHash(0xc5d246...) as the result.
//
// (4) Caller tries to get the code hash of a precompiled account, the result
// (4) Caller tries to get the code hash of a precompiled account, the result
//
// should be zero or emptyCodeHash.
//
// It is worth noting that in order to avoid unnecessary create and clean,
@ -537,10 +542,12 @@ func opExtCodeCopy(pc *uint64, interpreter *EVMInterpreter, contract *Contract,
// If the precompile account is not transferred any amount on a private or
// customized chain, the return value will be zero.
//
// (5) Caller tries to get the code hash for an account which is marked as suicided
// (5) Caller tries to get the code hash for an account which is marked as suicided
//
// in the current transaction, the code hash of this account should be returned.
//
// (6) Caller tries to get the code hash for an account which is marked as deleted,
// (6) Caller tries to get the code hash for an account which is marked as deleted,
//
// this account should be regarded as a non-existent account and zero should be returned.
func opExtCodeHash(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
slot := stack.peek()

@ -15,7 +15,6 @@
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
/*
Package rpc implements bi-directional JSON-RPC 2.0 on multiple transports.
It provides access to the exported methods of an object across a network or other I/O
@ -23,16 +22,16 @@ connection. After creating a server or client instance, objects can be registere
them visible as 'services'. Exported methods that follow specific conventions can be
called remotely. It also has support for the publish/subscribe pattern.
RPC Methods
# RPC Methods
Methods that satisfy the following criteria are made available for remote access:
- method must be exported
- method returns 0, 1 (response or error) or 2 (response and error) values
- method must be exported
- method returns 0, 1 (response or error) or 2 (response and error) values
An example method:
func (s *CalcService) Add(a, b int) (int, error)
func (s *CalcService) Add(a, b int) (int, error)
When the returned error isn't nil the returned integer is ignored and the error is sent
back to the client. Otherwise the returned integer is sent back to the client.
@ -41,7 +40,7 @@ Optional arguments are supported by accepting pointer values as arguments. E.g.
to do the addition in an optional finite field we can accept a mod argument as pointer
value.
func (s *CalcService) Add(a, b int, mod *int) (int, error)
func (s *CalcService) Add(a, b int, mod *int) (int, error)
This RPC method can be called with 2 integers and a null value as third argument. In that
case the mod argument will be nil. Or it can be called with 3 integers, in that case mod
@ -56,40 +55,40 @@ to the client out of order.
An example server which uses the JSON codec:
type CalculatorService struct {}
type CalculatorService struct {}
func (s *CalculatorService) Add(a, b int) int {
return a + b
}
func (s *CalculatorService) Add(a, b int) int {
return a + b
}
func (s *CalculatorService) Div(a, b int) (int, error) {
if b == 0 {
return 0, errors.New("divide by zero")
}
return a/b, nil
}
func (s *CalculatorService) Div(a, b int) (int, error) {
if b == 0 {
return 0, errors.New("divide by zero")
}
return a/b, nil
}
calculator := new(CalculatorService)
server := NewServer()
server.RegisterName("calculator", calculator)
l, _ := net.ListenUnix("unix", &net.UnixAddr{Net: "unix", Name: "/tmp/calculator.sock"})
server.ServeListener(l)
calculator := new(CalculatorService)
server := NewServer()
server.RegisterName("calculator", calculator)
l, _ := net.ListenUnix("unix", &net.UnixAddr{Net: "unix", Name: "/tmp/calculator.sock"})
server.ServeListener(l)
Subscriptions
# Subscriptions
The package also supports the publish subscribe pattern through the use of subscriptions.
A method that is considered eligible for notifications must satisfy the following
criteria:
- method must be exported
- first method argument type must be context.Context
- method must have return types (rpc.Subscription, error)
- method must be exported
- first method argument type must be context.Context
- method must have return types (rpc.Subscription, error)
An example method:
func (s *BlockChainService) NewBlocks(ctx context.Context) (rpc.Subscription, error) {
...
}
func (s *BlockChainService) NewBlocks(ctx context.Context) (rpc.Subscription, error) {
...
}
When the service containing the subscription method is registered to the server, for
example under the "blockchain" namespace, a subscription is created by calling the
@ -101,7 +100,7 @@ the client and server. The server will close the connection for any write error.
For more information about subscriptions, see https://github.com/ethereum/go-ethereum/wiki/RPC-PUB-SUB.
Reverse Calls
# Reverse Calls
In any method handler, an instance of rpc.Client can be accessed through the
ClientFromContext method. Using this client instance, server-to-client method calls can be

@ -34,21 +34,20 @@ import (
//
// The entry points for incoming messages are:
//
// h.handleMsg(message)
// h.handleBatch(message)
// h.handleMsg(message)
// h.handleBatch(message)
//
// Outgoing calls use the requestOp struct. Register the request before sending it
// on the connection:
//
// op := &requestOp{ids: ...}
// h.addRequestOp(op)
// op := &requestOp{ids: ...}
// h.addRequestOp(op)
//
// Now send the request, then wait for the reply to be delivered through handleMsg:
//
// if err := op.wait(...); err != nil {
// h.removeRequestOp(op) // timeout, etc.
// }
//
// if err := op.wait(...); err != nil {
// h.removeRequestOp(op) // timeout, etc.
// }
type handler struct {
reg *serviceRegistry
unsubscribeCb *callback

@ -83,6 +83,7 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.2.2 // indirect
github.com/bombsimon/wsl/v2 v2.0.0 // indirect
github.com/btcsuite/btcd v0.21.0-beta // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/containerd/cgroups v1.0.4 // indirect

@ -95,14 +95,8 @@ github.com/aristanetworks/goarista v0.0.0-20170210015632-ea17b1a17847/go.mod h1:
github.com/aristanetworks/goarista v0.0.0-20190607111240-52c2a7864a08 h1:UxoB3EYChE92EDNqRCS5vuE2ta4L/oKpeFaCK73KGvI=
github.com/aristanetworks/goarista v0.0.0-20190607111240-52c2a7864a08/go.mod h1:D/tb0zPVXnP7fmsLZjtdUhSsumbK/ij54UXjjVgMGxQ=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A=
github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU=
github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aws/aws-sdk-go v1.33.0 h1:Bq5Y6VTLbfnJp1IV8EL/qUU5qO1DYHda/zis/sqevkY=
github.com/aws/aws-sdk-go v1.33.0/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0=
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
github.com/beevik/ntp v0.3.0 h1:xzVrPrE4ziasFXgBVBZJDP0Wg/KpMwk2KHJ4Ba8GrDw=
github.com/beevik/ntp v0.3.0/go.mod h1:hIHWr+l3+/clUnF44zdK+CWW7fO8dR5cIylAQ76NRpg=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=

@ -345,11 +345,13 @@ var _bindata = map[string]func() (*asset, error){
// directory embedded in the file by go-bindata.
// For example if you run go-bindata on data/... and data contains the
// following hierarchy:
// data/
// foo.txt
// img/
// a.png
// b.png
//
// data/
// foo.txt
// img/
// a.png
// b.png
//
// then AssetDir("data") would return []string{"foo.txt", "img"}
// AssetDir("data/img") would return []string{"a.png", "b.png"}
// AssetDir("foo.txt") and AssetDir("notexist") would return an error

@ -10,8 +10,9 @@ import (
)
// loadHelper defines the helper interface to load bls keys. Implemented by
// multiKeyLoader - load key files with a slice of target key files
// blsDirLoader - load key files from a directory
//
// multiKeyLoader - load key files with a slice of target key files
// blsDirLoader - load key files from a directory
type loadHelper interface {
loadKeys() (multibls.PrivateKeys, error)
}

@ -16,10 +16,11 @@ import (
)
// AwsCfgSrcType is the type of src to load aws config. Four options available:
// AwsCfgSrcNil - Disable kms decryption
// AwsCfgSrcFile - Provide the aws config through a file (json).
// AwsCfgSrcPrompt - Provide the aws config though prompt.
// AwsCfgSrcShared - Use the shard aws config (env -> default .aws directory)
//
// AwsCfgSrcNil - Disable kms decryption
// AwsCfgSrcFile - Provide the aws config through a file (json).
// AwsCfgSrcPrompt - Provide the aws config though prompt.
// AwsCfgSrcShared - Use the shard aws config (env -> default .aws directory)
type AwsCfgSrcType uint8
const (
@ -144,11 +145,14 @@ func (cfg AwsConfig) toAws() *aws.Config {
}
// awsConfigProvider provides the aws config. Implemented by
// sharedACProvider - provide the nil to use shared AWS configuration
// fileACProvider - provide the aws config with a json file
// promptACProvider - provide the config field from prompt with time out
//
// sharedACProvider - provide the nil to use shared AWS configuration
// fileACProvider - provide the aws config with a json file
// promptACProvider - provide the config field from prompt with time out
//
// TODO: load aws session set up in a more official way. E.g. session.Opt.SharedConfigFiles,
// profile, env, e.t.c.
//
// profile, env, e.t.c.
type awsConfigProvider interface {
getAwsConfig() (*AwsConfig, error)
}
@ -187,7 +191,8 @@ func (provider *fileACProvider) getAwsConfig() (*AwsConfig, error) {
// promptACProvider provide a user interactive console for AWS config.
// Four fields are asked:
// 1. AccessKey 2. SecretKey 3. Region
// 1. AccessKey 2. SecretKey 3. Region
//
// Each field is asked with a timeout mechanism.
type promptACProvider struct {
timeout time.Duration

@ -78,8 +78,9 @@ func (cfg *Config) getKmsProviderConfig() kmsDecrypterConfig {
// keyDecrypter is the interface to decrypt the bls key file. Currently, two
// implementations are supported:
// passDecrypter - decrypt with passphrase for file name with extension .key
// kmsDecrypter - decrypt with aws kms service for file name with extension .bls
//
// passDecrypter - decrypt with passphrase for file name with extension .key
// kmsDecrypter - decrypt with aws kms service for file name with extension .bls
type keyDecrypter interface {
extension() string
decryptFile(keyFile string) (*bls_core.SecretKey, error)

@ -13,10 +13,11 @@ import (
// PassSrcType is the type of passphrase provider source.
// Four options available:
// PassSrcNil - Do not use passphrase decryption
// PassSrcFile - Read the passphrase from files
// PassSrcPrompt - Read the passphrase from prompt
// PassSrcAuto - First try to unlock with passphrase from file, then read passphrase from prompt
//
// PassSrcNil - Do not use passphrase decryption
// PassSrcFile - Read the passphrase from files
// PassSrcPrompt - Read the passphrase from prompt
// PassSrcAuto - First try to unlock with passphrase from file, then read passphrase from prompt
type PassSrcType uint8
const (
@ -121,10 +122,11 @@ func (pd *passDecrypter) getFilePassProvider() passProvider {
// passProvider is the interface to provide the passphrase of a bls keys.
// Implemented by
// promptPassProvider - provide passphrase through user-interactive prompt
// staticPassProvider - provide passphrase from a static .pass file
// dynamicPassProvider - provide the passphrase based on the given key file keyFile
// dirPassProvider - provide passphrase from .pass files in a directory
//
// promptPassProvider - provide passphrase through user-interactive prompt
// staticPassProvider - provide passphrase from a static .pass file
// dynamicPassProvider - provide the passphrase based on the given key file keyFile
// dirPassProvider - provide passphrase from .pass files in a directory
type passProvider interface {
getPassphrase(keyFile string) (string, error)
}

@ -13,10 +13,11 @@ var (
// SetParseErrorHandle set the error handle function used for cli parsing flags.
// An error handle example:
// cli.SetParseErrorHandle(func(err error) {
// fmt.Println(err)
// os.Exit(3)
// })
//
// cli.SetParseErrorHandle(func(err error) {
// fmt.Println(err)
// os.Exit(3)
// })
func SetParseErrorHandle(f errorHandle) {
parseErrorHandleFunc = f
}

@ -109,7 +109,7 @@ func PublishNewFilterLogEvent(shardID uint32, namespace, id string, crit ethereu
Publish(context.Background(), fmt.Sprintf("%s_new_filter_log_%d", namespace, shardID), msg).Err()
}
//TxPoolUpdate tx pool update event
// TxPoolUpdate tx pool update event
type TxPoolUpdate struct {
typ string
Local bool

@ -119,12 +119,15 @@ func NewDecFromIntWithPrec(i *big.Int, prec int64) Dec {
// NewDecFromStr creates a decimal from an input decimal string.
// valid must come in the form:
// (-) whole integers (.) decimal integers
//
// (-) whole integers (.) decimal integers
//
// examples of acceptable input include:
// -123.456
// 456.7890
// 345
// -456789
//
// -123.456
// 456.7890
// 345
// -456789
//
// NOTE - An error will return if more decimal places
// are provided in the string than the constant Precision.

@ -24,8 +24,9 @@ type RateLimiter interface {
// rateLimiter is the implementation of RateLimiter.
// The rateLimiter limit request rate:
// 1. For global stream requests
// 2. For requests from a stream
// 1. For global stream requests
// 2. For requests from a stream
//
// TODO: make request weighted in rate limiter
type rateLimiter struct {
globalLimiter ratelimit.Limiter

@ -35,7 +35,7 @@ func MakeGetBlocksByNumRequest(bns []uint64) *Request {
}
}
//MakeGetBlockByHashesRequest makes the GetBlocksByHashes request
// MakeGetBlockByHashesRequest makes the GetBlocksByHashes request
func MakeGetBlocksByHashesRequest(hashes []common.Hash) *Request {
return &Request{
Request: &Request_GetBlocksByHashesRequest{

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.26.0
// protoc-gen-go v1.28.1
// protoc v3.15.8
// source: msg.proto
@ -26,6 +26,7 @@ type Message struct {
unknownFields protoimpl.UnknownFields
// Types that are assignable to ReqOrResp:
//
// *Message_Req
// *Message_Resp
ReqOrResp isMessage_ReqOrResp `protobuf_oneof:"req_or_resp"`
@ -107,6 +108,7 @@ type Request struct {
ReqId uint64 `protobuf:"varint,1,opt,name=req_id,json=reqId,proto3" json:"req_id,omitempty"`
// Types that are assignable to Request:
//
// *Request_GetBlockNumberRequest
// *Request_GetBlockHashesRequest
// *Request_GetBlocksByNumRequest
@ -402,6 +404,7 @@ type Response struct {
ReqId uint64 `protobuf:"varint,1,opt,name=req_id,json=reqId,proto3" json:"req_id,omitempty"`
// Types that are assignable to Response:
//
// *Response_ErrorResponse
// *Response_GetBlockNumberResponse
// *Response_GetBlockHashesResponse

@ -36,7 +36,8 @@ type ProtoID libp2p_proto.ID
// ProtoSpec is the un-serialized stream proto id specification
// TODO: move this to service wise module since different protocol might have different
// protoID information
//
// protoID information
type ProtoSpec struct {
Service string
NetworkType nodeconfig.NetworkType

@ -1,5 +1,5 @@
# Build
FROM golang:1.18 AS build
FROM golang:1.19 AS build
RUN apt update -y && \
apt install libgmp-dev libssl-dev git -y && \

@ -71,6 +71,8 @@ then
echo "go generate FAILED!"
echo "go generate changed working tree contents!"
"${progdir}/print_file.sh" "${gogenerate_status_diff}" "git status diff"
"${progdir}/print_file.sh" "${gogenerate_status_before}" "gogenerate before"
"${progdir}/print_file.sh" "${gogenerate_status_after}" "gogenerate after"
ok=false
fi
else

@ -13,8 +13,9 @@ const (
)
// TODO ek – Schedule should really be part of a general-purpose network
// configuration. We are OK for the time being,
// until the day we should let one node process join multiple networks.
//
// configuration. We are OK for the time being,
// until the day we should let one node process join multiple networks.
var (
// Schedule is the sharding configuration schedule.
// Depends on the type of the network. Defaults to the mainnet schedule.

Loading…
Cancel
Save