Skip to content

Commit

Permalink
merge develop
Browse files Browse the repository at this point in the history
  • Loading branch information
temaniarpit27 committed Oct 17, 2023
2 parents 0559bd1 + 398c6ba commit 3d8ee19
Show file tree
Hide file tree
Showing 23 changed files with 1,674 additions and 331 deletions.
19 changes: 16 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ jobs:

- name: Test
run: make test

- uses: actions/upload-artifact@v2
with:
name: unitTest-coverage
path: cover.out

#- name: Data race tests
# run: make test-race
Expand Down Expand Up @@ -153,17 +158,25 @@ jobs:
- name: test-integration
run: make test-integration

- uses: actions/upload-artifact@v2
with:
name: integrationTest-coverage
path: cover.out

codecov:
if: (github.event.action != 'closed' || github.event.pull_request.merged == true)
strategy:
matrix:
os: [ ubuntu-20.04 ] # list of os: https://github.com/actions/virtual-environments
runs-on: ${{ matrix.os }}
needs: [unit-tests, integration-tests]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v2
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
file: ./cover.out
uses: codecov/codecov-action@v3

e2e-tests:
if: (github.event.action != 'closed' || github.event.pull_request.merged == true)
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "CodeQL"

on:
push:
branches: [ "master", "develop" ]
pull_request:
branches: [ "master", "develop" ]
schedule:
- cron: '0 0 * * *'

jobs:
analyze:
name: Analyze
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'go' ]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Security CI
name: Govuln
on: [ push, pull_request ]

jobs:
Expand All @@ -8,12 +8,12 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Running govulncheck
uses: Templum/govulncheck-action@v0.10.1
uses: Templum/govulncheck-action@v1.0.0
continue-on-error: true
env:
DEBUG: "true"
with:
go-version: 1.20.5
go-version: 1.21
package: ./...
github-token: ${{ secrets.GITHUB_TOKEN }}
fail-on-vuln: true
Expand Down
41 changes: 0 additions & 41 deletions .snyk

This file was deleted.

5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,12 @@ test-txpool-race:

test-race:
$(GOTEST) --timeout 15m -race -shuffle=on $(TESTALL)

gocovmerge-deps:
$(GOBUILD) -o $(GOBIN)/gocovmerge github.com/wadey/gocovmerge

test-integration:
$(GOTEST) --timeout 60m -tags integration $(TESTE2E)
$(GOTEST) --timeout 60m -cover -coverprofile=cover.out -covermode=atomic -tags integration $(TESTE2E)

escape:
cd $(path) && go test -gcflags "-m -m" -run none -bench=BenchmarkJumpdest* -benchmem -memprofile mem.out
Expand Down
9 changes: 8 additions & 1 deletion accounts/usbwallet/trezor.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,14 @@ func (w *trezorDriver) trezorExchange(req proto.Message, results ...proto.Messag
return 0, err
}

payload := make([]byte, 8+len(data))
var payload []byte

if len(data) < 64*1024*1024 {
payload = make([]byte, 8+len(data))
} else {
return 0, errors.New("data too large")
}

copy(payload, []byte{0x23, 0x23})
binary.BigEndian.PutUint16(payload[2:], trezor.Type(req))
binary.BigEndian.PutUint32(payload[4:], uint32(len(data)))
Expand Down
2 changes: 1 addition & 1 deletion builder/files/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ syncmode = "full"
# nodekeyhex = ""
[p2p.discovery]
# v5disc = false
bootnodes = ["enode://b8f1cc9c5d4403703fbf377116469667d2b1823c0daf16b7250aa576bacf399e42c3930ccfcb02c5df6879565a2b8931335565f0e8d3f8e72385ecf4a4bf160a@3.36.224.80:30303", "enode://8729e0c825f3d9cad382555f3e46dcff21af323e89025a0e6312df541f4a9e73abfa562d64906f5e59c51fe6f0501b3e61b07979606c56329c020ed739910759@54.194.245.5:30303"]
bootnodes = ["enode://76316d1cb93c8ed407d3332d595233401250d48f8fbb1d9c65bd18c0495eca1b43ec38ee0ea1c257c0abb7d1f25d649d359cdfe5a805842159cfe36c5f66b7e8@52.78.36.216:30303", "enode://b8f1cc9c5d4403703fbf377116469667d2b1823c0daf16b7250aa576bacf399e42c3930ccfcb02c5df6879565a2b8931335565f0e8d3f8e72385ecf4a4bf160a@3.36.224.80:30303", "enode://8729e0c825f3d9cad382555f3e46dcff21af323e89025a0e6312df541f4a9e73abfa562d64906f5e59c51fe6f0501b3e61b07979606c56329c020ed739910759@54.194.245.5:30303", "enode://681ebac58d8dd2d8a6eef15329dfbad0ab960561524cf2dfde40ad646736fe5c244020f20b87e7c1520820bc625cfb487dd71d63a3a3bf0baea2dbb8ec7c79f1@34.240.245.39:30303"]
# Uncomment below `bootnodes` field for Mumbai bootnode
# bootnodes = ["enode://bdcd4786a616a853b8a041f53496d853c68d99d54ff305615cd91c03cd56895e0a7f6e9f35dbf89131044e2114a9a782b792b5661e3aff07faf125a98606a071@43.200.206.40:30303", "enode://209aaf7ed549cf4a5700fd833da25413f80a1248bd3aa7fe2a87203e3f7b236dd729579e5c8df61c97bf508281bae4969d6de76a7393bcbd04a0af70270333b3@54.216.248.9:30303"]
# bootnodesv4 = []
Expand Down
22 changes: 20 additions & 2 deletions consensus/bor/heimdall/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var (
ErrNotSuccessfulResponse = errors.New("error while fetching data from Heimdall")
ErrNotInRejectedList = errors.New("milestoneID doesn't exist in rejected list")
ErrNotInMilestoneList = errors.New("milestoneID doesn't exist in Heimdall")
ErrServiceUnavailable = errors.New("service unavailable")
)

const (
Expand Down Expand Up @@ -277,10 +278,18 @@ func FetchWithRetry[T any](ctx context.Context, client http.Client, url *url.URL
return result, nil
}

// 503 (Service Unavailable) is thrown when an endpoint isn't activated
// yet in heimdall. E.g. when the hardfork hasn't hit yet but heimdall
// is upgraded.
if errors.Is(err, ErrServiceUnavailable) {
log.Debug("Heimdall service unavailable at the moment", "path", url.Path, "error", err)
return nil, err
}

Check warning on line 287 in consensus/bor/heimdall/client.go

View check run for this annotation

Codecov / codecov/patch

consensus/bor/heimdall/client.go#L285-L287

Added lines #L285 - L287 were not covered by tests

// attempt counter
attempt := 1

log.Warn("an error while trying fetching from Heimdall", "attempt", attempt, "error", err)
log.Warn("an error while trying fetching from Heimdall", "path", url.Path, "attempt", attempt, "error", err)

// create a new ticker for retrying the request
ticker := time.NewTicker(retryCall)
Expand All @@ -307,9 +316,14 @@ retryLoop:
request = &Request{client: client, url: url, start: time.Now()}
result, err = Fetch[T](ctx, request)

if errors.Is(err, ErrServiceUnavailable) {
log.Debug("Heimdall service unavailable at the moment", "path", url.Path, "error", err)
return nil, err
}

Check warning on line 322 in consensus/bor/heimdall/client.go

View check run for this annotation

Codecov / codecov/patch

consensus/bor/heimdall/client.go#L319-L322

Added lines #L319 - L322 were not covered by tests

if err != nil {
if attempt%logEach == 0 {
log.Warn("an error while trying fetching from Heimdall", "attempt", attempt, "error", err)
log.Warn("an error while trying fetching from Heimdall", "path", url.Path, "attempt", attempt, "error", err)

Check warning on line 326 in consensus/bor/heimdall/client.go

View check run for this annotation

Codecov / codecov/patch

consensus/bor/heimdall/client.go#L326

Added line #L326 was not covered by tests
}

continue retryLoop
Expand Down Expand Up @@ -426,6 +440,10 @@ func internalFetch(ctx context.Context, client http.Client, u *url.URL) ([]byte,

defer res.Body.Close()

if res.StatusCode == http.StatusServiceUnavailable {
return nil, fmt.Errorf("%w: response code %d", ErrServiceUnavailable, res.StatusCode)
}

Check warning on line 445 in consensus/bor/heimdall/client.go

View check run for this annotation

Codecov / codecov/patch

consensus/bor/heimdall/client.go#L444-L445

Added lines #L444 - L445 were not covered by tests

// check status code
if res.StatusCode != 200 && res.StatusCode != 204 {
return nil, fmt.Errorf("%w: response code %d", ErrNotSuccessfulResponse, res.StatusCode)
Expand Down
10 changes: 9 additions & 1 deletion eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/consensus/beacon"
"github.com/ethereum/go-ethereum/consensus/bor"
"github.com/ethereum/go-ethereum/consensus/bor/heimdall"
"github.com/ethereum/go-ethereum/consensus/clique"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/bloombits"
Expand Down Expand Up @@ -788,6 +789,10 @@ func (s *Ethereum) handleMilestone(ctx context.Context, ethHandler *ethHandler,
ethHandler.downloader.ProcessFutureMilestone(num, hash)

Check warning on line 789 in eth/backend.go

View check run for this annotation

Codecov / codecov/patch

eth/backend.go#L780-L789

Added lines #L780 - L789 were not covered by tests
}

if errors.Is(err, heimdall.ErrServiceUnavailable) {
return nil
}

Check warning on line 794 in eth/backend.go

View check run for this annotation

Codecov / codecov/patch

eth/backend.go#L792-L794

Added lines #L792 - L794 were not covered by tests

if err != nil {
return err
}

Check warning on line 798 in eth/backend.go

View check run for this annotation

Codecov / codecov/patch

eth/backend.go#L796-L798

Added lines #L796 - L798 were not covered by tests
Expand All @@ -800,7 +805,10 @@ func (s *Ethereum) handleMilestone(ctx context.Context, ethHandler *ethHandler,
func (s *Ethereum) handleNoAckMilestone(ctx context.Context, ethHandler *ethHandler, bor *bor.Bor) error {
milestoneID, err := ethHandler.fetchNoAckMilestone(ctx, bor)

//If failed to fetch the no-ack milestone then it give the error.
if errors.Is(err, heimdall.ErrServiceUnavailable) {
return nil
}

Check warning on line 810 in eth/backend.go

View check run for this annotation

Codecov / codecov/patch

eth/backend.go#L805-L810

Added lines #L805 - L810 were not covered by tests

if err != nil {

Check warning on line 812 in eth/backend.go

View check run for this annotation

Codecov / codecov/patch

eth/backend.go#L812

Added line #L812 was not covered by tests
return err
}
Expand Down
16 changes: 15 additions & 1 deletion eth/handler_bor.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus/bor"
"github.com/ethereum/go-ethereum/consensus/bor/heimdall"
"github.com/ethereum/go-ethereum/log"
)

Expand Down Expand Up @@ -63,6 +64,11 @@ func (h *ethHandler) fetchWhitelistMilestone(ctx context.Context, bor *bor.Bor,

// fetch latest milestone
milestone, err := bor.HeimdallClient.FetchMilestone(ctx)
if errors.Is(err, heimdall.ErrServiceUnavailable) {
log.Debug("Failed to fetch latest milestone for whitelisting", "err", err)
return num, hash, err
}

Check warning on line 70 in eth/handler_bor.go

View check run for this annotation

Codecov / codecov/patch

eth/handler_bor.go#L68-L70

Added lines #L68 - L70 were not covered by tests

if err != nil {
log.Error("Failed to fetch latest milestone for whitelisting", "err", err)
return num, hash, errMilestone
Expand Down Expand Up @@ -92,9 +98,13 @@ func (h *ethHandler) fetchNoAckMilestone(ctx context.Context, bor *bor.Bor) (str

// fetch latest milestone
milestoneID, err := bor.HeimdallClient.FetchLastNoAckMilestone(ctx)
if errors.Is(err, heimdall.ErrServiceUnavailable) {
log.Debug("Failed to fetch latest no-ack milestone", "err", err)
return milestoneID, err

Check warning on line 103 in eth/handler_bor.go

View check run for this annotation

Codecov / codecov/patch

eth/handler_bor.go#L99-L103

Added lines #L99 - L103 were not covered by tests
}

if err != nil {
log.Error("Failed to fetch latest no-ack milestone", "err", err)

return milestoneID, errMilestone
}

Check warning on line 109 in eth/handler_bor.go

View check run for this annotation

Codecov / codecov/patch

eth/handler_bor.go#L106-L109

Added lines #L106 - L109 were not covered by tests

Expand All @@ -104,6 +114,10 @@ func (h *ethHandler) fetchNoAckMilestone(ctx context.Context, bor *bor.Bor) (str
func (h *ethHandler) fetchNoAckMilestoneByID(ctx context.Context, bor *bor.Bor, milestoneID string) error {
// fetch latest milestone
err := bor.HeimdallClient.FetchNoAckMilestone(ctx, milestoneID)
if errors.Is(err, heimdall.ErrServiceUnavailable) {
log.Debug("Failed to fetch no-ack milestone by ID", "milestoneID", milestoneID, "err", err)
return err

Check warning on line 119 in eth/handler_bor.go

View check run for this annotation

Codecov / codecov/patch

eth/handler_bor.go#L114-L119

Added lines #L114 - L119 were not covered by tests
}

// fixme: handle different types of errors
if errors.Is(err, ErrNotInRejectedList) {
Expand Down
Loading

0 comments on commit 3d8ee19

Please sign in to comment.