Skip to content

Commit

Permalink
Updating Go v1.20 Prysm v4.0.5 Gethv1.11.6 (ten-protocol#1257)
Browse files Browse the repository at this point in the history
* Updating Go v1.20 Prysm v4.0.3 Gethv1.11.6

* fixing linter

* fixing build CI

* fix EOF on shutdown

* updating geth and prysm

* update beacon config

* using go v1.20.4

* force same version of forks + add delay in host closing conns

* update onboarding doc
  • Loading branch information
otherview authored May 30, 2023
1 parent 37adab1 commit 6727f8e
Show file tree
Hide file tree
Showing 49 changed files with 143 additions and 141 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: 1.20.4

# Makes sure the artifacts are built correctly
- name: Build
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ jobs:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: 1.20.4
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.48.0
version: v1.52.2
args: --timeout=5m --verbose
skip-pkg-cache: true

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/manual-deploy-testnet-l2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ jobs:
steps:
- uses: actions/checkout@v2

- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: 1.20.4

- name: 'Login via Azure CLI'
uses: azure/login@v1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/manual-upgrade-testnet-l2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ jobs:
steps:
- uses: actions/checkout@v2

- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: 1.20.4

- name: 'Login via Azure CLI'
uses: azure/login@v1
Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,14 +279,10 @@ written in [go](https://go.dev). Unless otherwise stated, all paths stated herei
### Dependencies
The following dependencies are required to be installed locally;

- [go](https://go.dev) (version > 1.18)
- [go](https://go.dev) (version > 1.20)
- [docker](https://docs.docker.com/get-docker/) (recommend latest version*)
- [docker compose](https://docs.docker.com/compose/install/) (recommend latest version)

Whilst the recommended version of go is > 1.18, the reference implementation uses _only_ language features up to and
including 1.17. Using 1.18 is recommended for easier setup and installation and is backwards compatible with all 1.17
language features.


### Building
To create the build artifacts local to the checkout of the repository the easiest approach is to build each component
Expand Down
17 changes: 15 additions & 2 deletions developer_onboarding_guide.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
# Developer Onboarding Guide

## Prerequisites
- [go](https://go.dev/doc/install) (version > 1.18)
- [go](https://go.dev/doc/install) (version > 1.20.4)
- [gofumpt](https://github.com/mvdan/gofumpt)
- [golangci-lint](https://golangci-lint.run/) (version 1.48.0)
- [golangci-lint](https://golangci-lint.run/) (version 1.52.2)

# Update Setup quicksheet
- Install golangci-lint :
`curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.52.2`
- Install go1.20.4 :
[Multiversion install](https://go.dev/doc/manage-install) example:
```
$ go install golang.org/dl/go1.20.4@latest
$ go1.20.4 download
# update your .zshrc script so that go is in the PATH
$ export PATH="/Users/pedro/sdk/go1.20.4/bin/:/Users/pedro/go/bin:$PATH"
```

## Creating New PR and Getting It Ready to Be Merged to the Main Branch

Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/enclave.debug.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# build-enclave = copies over the source and builds the enclave using a go compiler cache
# final = using the base system copies over only the enclave executable and creates the final image without source and dependencies.

FROM golang:1.18-alpine as system
FROM golang:1.20-alpine as system

# install build utils
RUN apk add build-base
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/host.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# build-host = copies over the source code and builds the binaries using a compiler cache
# final = copies over only the executables in an alpine image that doesn't have any additional load.

FROM golang:1.18-alpine as system
FROM golang:1.20-alpine as system
# set the base libs to build / run
RUN apk add build-base bash
ENV CGO_ENABLED=1
Expand Down
4 changes: 2 additions & 2 deletions docs/_docs/testnet/starting-a-node.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ How to start a node in the Evan's Cat testnet.
#### - Create an SGX enabled VM
Recommended Standard DC4s v2 (4 vcpus, 16 GiB memory) in Azure.

#### - Install Docker & Go 1.17
#### - Install Docker & Go

```
sudo apt-get update \
&& curl -fsSL https://get.docker.com -o get-docker.sh && sh ./get-docker.sh \
&& sudo snap refresh && sudo snap install --channel=1.17 go --classic
&& sudo snap refresh && sudo snap install --channel=1.20 go --classic
```

#### - Download Obscuro repo
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/obscuronet/go-obscuro

go 1.18
go 1.20

require (
github.com/Azure/azure-sdk-for-go v63.2.0+incompatible
Expand Down
14 changes: 7 additions & 7 deletions go/common/tracers/native/noop.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,28 @@ func newNoopTracer() tracers.Tracer {
}

// CaptureStart implements the EVMLogger interface to initialize the tracing operation.
func (t *noopTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) {
func (t *noopTracer) CaptureStart(_ *vm.EVM, _ common.Address, _ common.Address, _ bool, _ []byte, _ uint64, _ *big.Int) {
}

// CaptureEnd is called after the call finishes to finalize the tracing.
func (t *noopTracer) CaptureEnd(output []byte, gasUsed uint64, _ time.Duration, err error) {
func (t *noopTracer) CaptureEnd(_ []byte, _ uint64, _ time.Duration, _ error) {
}

// CaptureState implements the EVMLogger interface to trace a single step of VM execution.
func (t *noopTracer) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, rData []byte, depth int, err error) {
func (t *noopTracer) CaptureState(_ uint64, _ vm.OpCode, _, _ uint64, _ *vm.ScopeContext, _ []byte, _ int, _ error) {
}

// CaptureFault implements the EVMLogger interface to trace an execution fault.
func (t *noopTracer) CaptureFault(pc uint64, op vm.OpCode, gas, cost uint64, _ *vm.ScopeContext, depth int, err error) {
func (t *noopTracer) CaptureFault(_ uint64, _ vm.OpCode, _, _ uint64, _ *vm.ScopeContext, _ int, _ error) {
}

// CaptureEnter is called when EVM enters a new scope (via call, create or selfdestruct).
func (t *noopTracer) CaptureEnter(typ vm.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
func (t *noopTracer) CaptureEnter(_ vm.OpCode, _ common.Address, _ common.Address, _ []byte, _ uint64, _ *big.Int) {
}

// CaptureExit is called when EVM exits a scope, even if the scope didn't
// execute any code.
func (t *noopTracer) CaptureExit(output []byte, gasUsed uint64, err error) {
func (t *noopTracer) CaptureExit(_ []byte, _ uint64, _ error) {
}

// GetResult returns an empty json object.
Expand All @@ -74,5 +74,5 @@ func (t *noopTracer) GetResult() (json.RawMessage, error) {
}

// Stop terminates execution of the tracer at the first opportune moment.
func (t *noopTracer) Stop(err error) {
func (t *noopTracer) Stop(_ error) {
}
10 changes: 5 additions & 5 deletions go/common/tracers/native/prestate.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ func (t *prestateTracer) CaptureStart(env *vm.EVM, from common.Address, to commo
}

// CaptureEnd is called after the call finishes to finalize the tracing.
func (t *prestateTracer) CaptureEnd(output []byte, gasUsed uint64, _ time.Duration, err error) {
func (t *prestateTracer) CaptureEnd(_ []byte, _ uint64, _ time.Duration, _ error) {
if t.create {
// Exclude created contract.
delete(t.prestate, t.to)
}
}

// CaptureState implements the EVMLogger interface to trace a single step of VM execution.
func (t *prestateTracer) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, rData []byte, depth int, err error) {
func (t *prestateTracer) CaptureState(_ uint64, op vm.OpCode, _, _ uint64, scope *vm.ScopeContext, _ []byte, _ int, _ error) {
stack := scope.Stack
stackData := stack.Data()
stackLen := len(stackData)
Expand Down Expand Up @@ -139,16 +139,16 @@ func (t *prestateTracer) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64,
}

// CaptureFault implements the EVMLogger interface to trace an execution fault.
func (t *prestateTracer) CaptureFault(pc uint64, op vm.OpCode, gas, cost uint64, _ *vm.ScopeContext, depth int, err error) {
func (t *prestateTracer) CaptureFault(_ uint64, _ vm.OpCode, _, _ uint64, _ *vm.ScopeContext, _ int, _ error) {
}

// CaptureEnter is called when EVM enters a new scope (via call, create or selfdestruct).
func (t *prestateTracer) CaptureEnter(typ vm.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
func (t *prestateTracer) CaptureEnter(_ vm.OpCode, _ common.Address, _ common.Address, _ []byte, _ uint64, _ *big.Int) {
}

// CaptureExit is called when EVM exits a scope, even if the scope didn't
// execute any code.
func (t *prestateTracer) CaptureExit(output []byte, gasUsed uint64, err error) {
func (t *prestateTracer) CaptureExit(_ []byte, _ uint64, _ error) {
}

// GetResult returns the json-encoded nested list of call traces, and any
Expand Down
2 changes: 1 addition & 1 deletion go/common/tracers/native/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func register(name string, ctor func() tracers.Tracer) {
}

// lookup returns a tracer, if one can be matched to the given name.
func lookup(name string, ctx *tracers.Context) (tracers.Tracer, error) {
func lookup(name string, _ *tracers.Context) (tracers.Tracer, error) {
if ctors == nil {
ctors = make(map[string]func() tracers.Tracer)
}
Expand Down
2 changes: 1 addition & 1 deletion go/enclave/components/batch_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func (br *batchRegistryImpl) getMissingBatches(fromHash *common.L2BatchHash) ([]

func (br *batchRegistryImpl) FindAncestralBatchFor(block *common.L1Block) (*core.Batch, error) {
currentBlock := block
var ancestorBatch *core.Batch = nil
var ancestorBatch *core.Batch
var err error

br.logger.Trace("Searching for ancestral batch")
Expand Down
4 changes: 2 additions & 2 deletions go/enclave/crosschain/message_bus_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (m *MessageBusManager) GetBusAddress() *common.L2Address {
}

// DeriveOwner - Generates the key pair that will be used to transact with the L2 message bus.
func (m *MessageBusManager) DeriveOwner(seed []byte) (*common.L2Address, error) {
func (m *MessageBusManager) DeriveOwner(_ []byte) (*common.L2Address, error) {
// todo (#1549) - implement with cryptography epic
return m.messageBusAddress, nil
}
Expand Down Expand Up @@ -123,7 +123,7 @@ func (m *MessageBusManager) ExtractOutboundMessages(receipts common.L2Receipts)
// todo (@stefan) - fix ordering of messages, currently it is irrelevant.
// todo (@stefan) - do not extract messages below their consistency level. Irrelevant security wise.
// todo (@stefan) - surface errors
func (m *MessageBusManager) RetrieveInboundMessages(fromBlock *common.L1Block, toBlock *common.L1Block, rollupState *state.StateDB) common.CrossChainMessages {
func (m *MessageBusManager) RetrieveInboundMessages(fromBlock *common.L1Block, toBlock *common.L1Block, _ *state.StateDB) common.CrossChainMessages {
messages := make(common.CrossChainMessages, 0)

from := fromBlock.Hash()
Expand Down
14 changes: 7 additions & 7 deletions go/enclave/db/sql/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ func (sqlDB *EnclaveDB) NewIterator(prefix []byte, start []byte) ethdb.Iterator
}
}

func (sqlDB *EnclaveDB) Stat(property string) (string, error) {
func (sqlDB *EnclaveDB) Stat(_ string) (string, error) {
// todo - implement me
sqlDB.logger.Crit("implement me")
return "", nil
}

func (sqlDB *EnclaveDB) Compact(start []byte, limit []byte) error {
func (sqlDB *EnclaveDB) Compact(_ []byte, _ []byte) error {
// todo - implement me
sqlDB.logger.Crit("implement me")
return nil
Expand All @@ -124,17 +124,17 @@ func (sqlDB *EnclaveDB) Compact(start []byte, limit []byte) error {
var errNotSupported = errors.New("this operation is not supported")

// HasAncient returns an error as we don't have a backing chain freezer.
func (sqlDB *EnclaveDB) HasAncient(kind string, number uint64) (bool, error) {
func (sqlDB *EnclaveDB) HasAncient(_ string, _ uint64) (bool, error) {
return false, errNotSupported
}

// Ancient returns an error as we don't have a backing chain freezer.
func (sqlDB *EnclaveDB) Ancient(kind string, number uint64) ([]byte, error) {
func (sqlDB *EnclaveDB) Ancient(_ string, _ uint64) ([]byte, error) {
return nil, errNotSupported
}

// AncientRange returns an error as we don't have a backing chain freezer.
func (sqlDB *EnclaveDB) AncientRange(kind string, start, max, maxByteSize uint64) ([][]byte, error) {
func (sqlDB *EnclaveDB) AncientRange(_ string, _, _, _ uint64) ([][]byte, error) {
return nil, errNotSupported
}

Expand All @@ -144,7 +144,7 @@ func (sqlDB *EnclaveDB) Ancients() (uint64, error) {
}

// AncientSize returns an error as we don't have a backing chain freezer.
func (sqlDB *EnclaveDB) AncientSize(kind string) (uint64, error) {
func (sqlDB *EnclaveDB) AncientSize(_ string) (uint64, error) {
return 0, errNotSupported
}

Expand All @@ -154,7 +154,7 @@ func (sqlDB *EnclaveDB) ModifyAncients(func(ethdb.AncientWriteOp) error) (int64,
}

// TruncateAncients returns an error as we don't have a backing chain freezer.
func (sqlDB *EnclaveDB) TruncateAncients(items uint64) error {
func (sqlDB *EnclaveDB) TruncateAncients(_ uint64) error {
return errNotSupported
}

Expand Down
8 changes: 4 additions & 4 deletions go/enclave/db/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ func (s *storageImpl) loadLogs(requestingAccount *gethcommon.Address, whereCondi
query += whereCondition
queryParams = append(queryParams, whereParams...)

rows, err := s.db.GetSQLDB().Query(query, queryParams...)
rows, err := s.db.GetSQLDB().Query(query, queryParams...) //nolint: rowserrcheck
if err != nil {
return nil, err
}
Expand All @@ -545,7 +545,7 @@ func (s *storageImpl) loadLogs(requestingAccount *gethcommon.Address, whereCondi
result = append(result, &l)
}

if err = rows.Close(); err != nil {
if err = rows.Close(); err != nil { //nolint: sqlclosecheck
return nil, syserr.NewInternalError(err)
}

Expand All @@ -567,7 +567,7 @@ func (s *storageImpl) DebugGetLogs(txHash common.TxHash) ([]*tracers.DebugLogs,

result := make([]*tracers.DebugLogs, 0)

rows, err := s.db.GetSQLDB().Query(query, queryParams...)
rows, err := s.db.GetSQLDB().Query(query, queryParams...) //nolint: rowserrcheck
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -615,7 +615,7 @@ func (s *storageImpl) DebugGetLogs(txHash common.TxHash) ([]*tracers.DebugLogs,
result = append(result, &l)
}

if err = rows.Close(); err != nil {
if err = rows.Close(); err != nil { //nolint: sqlclosecheck
return nil, err
}

Expand Down
4 changes: 2 additions & 2 deletions go/enclave/enclave.go
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ func (e *enclaveImpl) GetLogs(encryptedParams common.EncryptedParamsGetLogs) (*r
// once the work of obscuro gas mechanics is established this method should be simplified
func (e *enclaveImpl) DoEstimateGas(args *gethapi.TransactionArgs, blkNumber *gethrpc.BlockNumber, gasCap uint64) (hexutil.Uint64, common.SystemError) { //nolint: gocognit
// Binary search the gas requirement, as it may be higher than the amount used
var (
var ( //nolint: revive
lo = params.TxGas - 1
hi uint64
cap uint64 //nolint:predeclared
Expand Down Expand Up @@ -1144,7 +1144,7 @@ func (e *enclaveImpl) DoEstimateGas(args *gethapi.TransactionArgs, blkNumber *ge
e.logger.Warn("Caller gas above allowance, capping", "requested", hi, "cap", gasCap)
hi = gasCap
}
cap = hi
cap = hi //nolint: revive

// Execute the binary search and hone in on an isGasEnough gas limit
for lo+1 < hi {
Expand Down
5 changes: 1 addition & 4 deletions go/enclave/enclave_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,11 +622,8 @@ func injectNewBlockAndChangeBalance(enclave common.Enclave, funds []genesis.Acco
if err = enclave.(*enclaveImpl).storage.UpdateHeadBatch(blockHash, batch, nil, dbBatch); err != nil {
return err
}
if err = enclave.(*enclaveImpl).storage.CommitBatch(dbBatch); err != nil {
return err
}

return nil
return enclave.(*enclaveImpl).storage.CommitBatch(dbBatch)
}

func checkExpectedBalance(enclave common.Enclave, blkNumber gethrpc.BlockNumber, w wallet.Wallet, expectedAmount *big.Int) error {
Expand Down
6 changes: 3 additions & 3 deletions go/enclave/evm/chain_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ func (occ *ObscuroChainContext) Engine() consensus.Engine {
return &ObscuroNoOpConsensusEngine{logger: occ.logger}
}

func (occ *ObscuroChainContext) GetHeader(hash common.Hash, height uint64) *types.Header {
batch, err := occ.storage.FetchBatchHeader(hash)
func (occ *ObscuroChainContext) GetHeader(hash common.Hash, _ uint64) *types.Header {
batch, err := occ.storage.FetchBatch(hash)
if err != nil {
if errors.Is(err, errutil.ErrNotFound) {
return nil
}
occ.logger.Crit("Could not retrieve rollup", log.ErrKey, err)
}

h, err := gethencoding.ConvertToEthHeader(batch, secret(occ.storage))
h, err := gethencoding.ConvertToEthHeader(batch.Header, secret(occ.storage))
if err != nil {
occ.logger.Crit("Could not convert to eth header", log.ErrKey, err)
return nil
Expand Down
Loading

0 comments on commit 6727f8e

Please sign in to comment.