diff --git a/.github/workflows/go-ci.yml b/.github/workflows/go-ci.yml index 3e6bf622..bc4e702c 100644 --- a/.github/workflows/go-ci.yml +++ b/.github/workflows/go-ci.yml @@ -15,16 +15,16 @@ jobs: - name: Install Go uses: actions/setup-go@v2 with: - go-version: 1.17 + go-version: 1.18 - name: Checkout code uses: actions/checkout@v2 - name: golangci-lint uses: golangci/golangci-lint-action@v2 with: - version: v1.43.0 # version of golangci-lint, not the action + version: v1.45.0 # version of golangci-lint, not the action skip-go-installation: true # rules: https://golangci-lint.run/usage/quick-start/ - args: -E asciicheck,goimports + args: -E asciicheck,goimports,misspell - name: Test and generate coverage run: go test -coverpkg=./... -coverprofile=coverage.out -covermode=atomic ./... - name: Upload coverage output diff --git a/go.mod b/go.mod index 80da39b0..7f9c98b5 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/ethereum-optimism/optimistic-specs -go 1.17 +go 1.18 require ( github.com/ethereum/go-ethereum v1.10.16 diff --git a/l2os/Makefile b/l2os/Makefile index 1fab682f..5642d8c1 100644 --- a/l2os/Makefile +++ b/l2os/Makefile @@ -19,7 +19,7 @@ test: go test -v ./... lint: - golangci-lint run ./... + golangci-lint run -E asciicheck,goimports,misspell ./... bindings: bindings-mock-l2-output-oracle diff --git a/l2os/l2_output_submitter.go b/l2os/l2_output_submitter.go index cff23be6..191020d3 100644 --- a/l2os/l2_output_submitter.go +++ b/l2os/l2_output_submitter.go @@ -175,8 +175,8 @@ func dialEthClientWithTimeout(ctx context.Context, url string) ( return ethclient.DialContext(ctxt, url) } -// parseAddress parses an ETH addres from a hex string. This method will fail if -// the address is not a valid hexidecimal address. +// parseAddress parses an ETH address from a hex string. This method will fail if +// the address is not a valid hexadecimal address. func parseAddress(address string) (common.Address, error) { if common.IsHexAddress(address) { return common.HexToAddress(address), nil diff --git a/l2os/txmgr/send_state.go b/l2os/txmgr/send_state.go index c223f743..2f34cbb3 100644 --- a/l2os/txmgr/send_state.go +++ b/l2os/txmgr/send_state.go @@ -11,7 +11,7 @@ import ( // SendState tracks information about the publication state of a given txn. In // this context, a txn may correspond to multiple different txn hashes due to // varying gas prices, though we treat them all as the same logical txn. This -// struct is primarly used to determine whether or not the txmgr should abort a +// struct is primarily used to determine whether or not the txmgr should abort a // given txn and retry with a higher nonce. type SendState struct { minedTxs map[common.Hash]struct{} @@ -77,7 +77,7 @@ func (s *SendState) TxNotMined(txHash common.Hash) { // If the txn got reorged and left us with no mined txns, reset the nonce // too low count, otherwise we might abort too soon when processing the next // error. If the nonce too low errors persist, we want to ensure we wait out - // the full safe abort count to enesure we have a sufficient number of + // the full safe abort count to ensure we have a sufficient number of // observations. if len(s.minedTxs) == 0 && wasMined { s.nonceTooLowCount = 0 diff --git a/l2os/txmgr/send_state_test.go b/l2os/txmgr/send_state_test.go index 8dd61079..42d16342 100644 --- a/l2os/txmgr/send_state_test.go +++ b/l2os/txmgr/send_state_test.go @@ -80,8 +80,8 @@ func TestSendStateMiningTxCancelsAbort(t *testing.T) { } // TestSendStateReorgingTxResetsAbort asserts that unmining a tx does not -// consider ErrNonceTooLow's prior to being mined when determing whether to -// abort. +// consider ErrNonceTooLow's prior to being mined when determining whether +// to abort. func TestSendStateReorgingTxResetsAbort(t *testing.T) { sendState := newSendState() diff --git a/l2os/txmgr/txmgr.go b/l2os/txmgr/txmgr.go index ca206da1..90379c3a 100644 --- a/l2os/txmgr/txmgr.go +++ b/l2os/txmgr/txmgr.go @@ -209,7 +209,7 @@ func (m *SimpleTxManager) Send( // Avoid republishing if we are waiting for confirmation on an // existing tx. This is primarily an optimization to reduce the // number of API calls we make, but also reduces the chances of - // getting a false postive reading for ShouldAbortImmediately. + // getting a false positive reading for ShouldAbortImmediately. if sendState.IsWaitingForConfirmation() { continue } diff --git a/l2os/txmgr/txmgr_test.go b/l2os/txmgr/txmgr_test.go index 3fb0c492..81cf9cab 100644 --- a/l2os/txmgr/txmgr_test.go +++ b/l2os/txmgr/txmgr_test.go @@ -37,7 +37,7 @@ func newTestHarnessWithConfig(cfg txmgr.Config) *testHarness { } } -// newTestHarness initializes a testHarness with a defualt configuration that is +// newTestHarness initializes a testHarness with a default configuration that is // suitable for most tests. func newTestHarness() *testHarness { return newTestHarnessWithConfig(configWithNumConfs(1)) diff --git a/meta/linting.md b/meta/linting.md index 45e77798..c356d1c8 100644 --- a/meta/linting.md +++ b/meta/linting.md @@ -59,7 +59,7 @@ Justification for linting rules: ```shell # Install linter globally (should not affect go.mod) -go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.43.0 +go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.45.0 # run linter, add --fix option to fix problems (where supported) -golangci-lint run -E asciicheck,goimports +golangci-lint run -E asciicheck,goimports,misspell ``` diff --git a/opnode/.gitignore b/opnode/.gitignore new file mode 100644 index 00000000..ba077a40 --- /dev/null +++ b/opnode/.gitignore @@ -0,0 +1 @@ +bin diff --git a/opnode/Makefile b/opnode/Makefile new file mode 100644 index 00000000..d2c8a6c0 --- /dev/null +++ b/opnode/Makefile @@ -0,0 +1,26 @@ +GITCOMMIT := $(shell git rev-parse HEAD) +GITDATE := $(shell git show -s --format='%ct') +VERSION := v0.0.0 + +LDFLAGSSTRING +=-X main.GitCommit=$(GITCOMMIT) +LDFLAGSSTRING +=-X main.GitDate=$(GITDATE) +LDFLAGSSTRING +=-X main.Version=$(VERSION) +LDFLAGS := -ldflags "$(LDFLAGSSTRING)" + +opnode: + env GO111MODULE=on go build -v $(LDFLAGS) -o ./bin/opnode ./cmd/main.go + +clean: + rm bin/opnode + +test: + go test -v ./... + +lint: + golangci-lint run -E asciicheck,goimports,misspell ./... + +.PHONY: \ + bss \ + clean \ + test \ + lint diff --git a/opnode/backoff/operation.go b/opnode/backoff/operation.go index 4bd7f453..54818875 100644 --- a/opnode/backoff/operation.go +++ b/opnode/backoff/operation.go @@ -23,7 +23,7 @@ func (e *ErrFailedPermanently) Error() string { // Do performs the provided Operation up to maxAttempts times // with delays in between each retry according to the provided // Strategy. -func Do(maxAttempts int, strat Strategy, op Operation) error { +func Do(maxAttempts int, strategy Strategy, op Operation) error { var attempt int for { @@ -39,6 +39,6 @@ func Do(maxAttempts int, strat Strategy, op Operation) error { LastErr: err, } } - time.Sleep(strat.Duration(attempt - 1)) + time.Sleep(strategy.Duration(attempt - 1)) } } diff --git a/opnode/backoff/operation_test.go b/opnode/backoff/operation_test.go index a7e2d174..063e9685 100644 --- a/opnode/backoff/operation_test.go +++ b/opnode/backoff/operation_test.go @@ -9,12 +9,12 @@ import ( ) func TestDo(t *testing.T) { - strat := Fixed(10 * time.Millisecond) + strategy := Fixed(10 * time.Millisecond) dummyErr := errors.New("explode") start := time.Now() var i int - require.NoError(t, Do(2, strat, func() error { + require.NoError(t, Do(2, strategy, func() error { if i == 1 { return nil } @@ -26,7 +26,7 @@ func TestDo(t *testing.T) { start = time.Now() // add one because the first attempt counts - err := Do(3, strat, func() error { + err := Do(3, strategy, func() error { return dummyErr }) require.Equal(t, dummyErr, err.(*ErrFailedPermanently).LastErr) diff --git a/opnode/backoff/strategies_test.go b/opnode/backoff/strategies_test.go index 852ee2b6..2988a323 100644 --- a/opnode/backoff/strategies_test.go +++ b/opnode/backoff/strategies_test.go @@ -8,7 +8,7 @@ import ( ) func TestExponential(t *testing.T) { - strat := &ExponentialStrategy{ + strategy := &ExponentialStrategy{ Min: 3000, Max: 10000, MaxJitter: 0, @@ -16,6 +16,6 @@ func TestExponential(t *testing.T) { durations := []int{4, 5, 7, 10, 10} for i, dur := range durations { - require.Equal(t, time.Millisecond*time.Duration(dur*1000), strat.Duration(i)) + require.Equal(t, time.Millisecond*time.Duration(dur*1000), strategy.Duration(i)) } } diff --git a/opnode/cmd/main.go b/opnode/cmd/main.go index 2d571d11..d7af2124 100644 --- a/opnode/cmd/main.go +++ b/opnode/cmd/main.go @@ -15,15 +15,21 @@ import ( ) var ( - Version = "0.0.0" - // GitCommit = "" - // GitDate = "" + Version = "0.0.0" + GitCommit = "" + GitDate = "" VersionMeta = "dev" ) // VersionWithMeta holds the textual version string including the metadata. var VersionWithMeta = func() string { v := Version + if GitCommit != "" { + v += "-" + GitCommit[:8] + } + if GitDate != "" { + v += "-" + GitDate + } if VersionMeta != "" { v += "-" + VersionMeta } diff --git a/opnode/rollup/derive/doc.go b/opnode/rollup/derive/doc.go index e0b46265..e8bdb699 100644 --- a/opnode/rollup/derive/doc.go +++ b/opnode/rollup/derive/doc.go @@ -1,5 +1,5 @@ // Package derive provides the data transformation functions that take L1 data -// and turn it into L2 blocks and results. Certian L2 data is also able to +// and turn it into L2 blocks and results. Certain L2 data is also able to // turned back into L1 data. // // The flow is data is as follows diff --git a/opnode/rollup/driver/state_test.go b/opnode/rollup/driver/state_test.go index 112df039..b3848e47 100644 --- a/opnode/rollup/driver/state_test.go +++ b/opnode/rollup/driver/state_test.go @@ -128,7 +128,7 @@ type stateTestCase struct { } func (tc *stateTestCase) Run(t *testing.T) { - log := testlog.Logger(t, log.LvlTrace) + log := testlog.Logger(t, log.LvlError) chainSource := NewFakeChainSource(tc.l1Chains, tc.l2Chains, log) l1headsCh := make(chan eth.L1BlockRef, 10) // Unbuffered channels to force a sync point between the test and the state loop. diff --git a/opnode/rollup/sync/start_test.go b/opnode/rollup/sync/start_test.go index c6b71ce8..c3364ce8 100644 --- a/opnode/rollup/sync/start_test.go +++ b/opnode/rollup/sync/start_test.go @@ -125,7 +125,7 @@ type syncStartTestCase struct { GenesisL2 rune ExpectedNextRefsL1 string // The L1 extension to follow (i.e. L1 after the L1 parent in the new L2 Head) - ExpectedRefL2 rune // The new L2 tip after a L1 change that may have occured + ExpectedRefL2 rune // The new L2 tip after a L1 change that may have occurred ExpectedErr error }