Skip to content

Commit

Permalink
Merge branch 'main' into contracts/add-active-metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
fbac authored Feb 24, 2025
2 parents 724ca26 + 15a8b8d commit 1e264d5
Show file tree
Hide file tree
Showing 22 changed files with 92 additions and 71 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/lint-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ jobs:
with:
args: --timeout=5m --config .golangci.yaml
- name: golines
uses: nickcharlton/diff-check@main
uses: nickcharlton/diff-check@v1.0.0
with:
command: dev/lint-golines
- name: sqlc
uses: nickcharlton/[email protected]
with:
command: go tool -modfile=tools/go.mod sqlc generate
- name: generate
uses: nickcharlton/[email protected]
with:
command: go generate ./...
- name: mockery
uses: nickcharlton/[email protected]
with:
command: go tool -modfile=tools/go.mod mockery
41 changes: 22 additions & 19 deletions .github/workflows/solidity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ jobs:
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: v0.3.0
version: v1.0.0

- name: Set cache key
id: set-cache-key
run: echo "cache-key=ci-solidity-${{ hashFiles('**/*.sol') }}" >> "$GITHUB_OUTPUT"
run: echo "cache-key=ci-solidity-${{ hashFiles('contracts/**/*') }}" >> "$GITHUB_OUTPUT"

- name: Install dependencies
run: forge soldeer update
Expand All @@ -54,7 +54,11 @@ jobs:
- name: Cache data
uses: actions/cache/save@v4
with:
path: contracts
path: |
contracts/build
contracts/cache
contracts/dependencies
contracts/out
key: ${{ steps.set-cache-key.outputs.cache-key }}

- id: forge
Expand All @@ -70,10 +74,16 @@ jobs:
needs: init
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Restore cache
uses: actions/cache/restore@v4
with:
path: contracts
path: |
contracts/build
contracts/cache
contracts/dependencies
contracts/out
key: ${{ needs.init.outputs.cache-key }}

- name: Restore forge
Expand All @@ -91,6 +101,8 @@ jobs:
needs: init
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Restore cache
uses: actions/cache/restore@v4
with:
Expand All @@ -113,6 +125,8 @@ jobs:
runs-on: ubuntu-latest
if: github.actor != 'dependabot[bot]'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Restore cache
uses: actions/cache/restore@v4
with:
Expand Down Expand Up @@ -164,18 +178,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5

- name: Install abigen
run: go install github.com/ethereum/go-ethereum/cmd/[email protected]

- name: Generate ABIs
run: dev/generate

- name: Check for ABI changes
working-directory: ${{ github.workspace }}
run: |
if git diff --exit-code --ignore-space-change --ignore-all-space --ignore-cr-at-eol -- contracts/pkg; then
echo "No ABI changes detected."
else
echo "ERROR: Generated files are not up to date. Please run 'contracts/dev/generate' and commit the changes."
exit 1
fi
- name: abigen
uses: nickcharlton/[email protected]
with:
command: contracts/dev/generate
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: "nightly-ac81a53d1d5823919ffbadd3c65f081927aa11f2"
version: v1.0.0
- run: contracts/dev/deploy-local
- run: dev/register-local-node
- name: Run Tests
Expand Down
2 changes: 1 addition & 1 deletion contracts/dev/generate
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function generate_bindings() {
rm -f "${output_dir}/${package}"/*.go

# Generate ABI and bytecode
if ! forge inspect "${source_artifact}:${filename}" abi > "${build_artifact}.abi.json"; then
if ! forge inspect "${source_artifact}:${filename}" abi --json > "${build_artifact}.abi.json"; then
echo "ERROR: Failed to generate ABI for ${filename}" >&2
exit 1
fi
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/GroupMessage.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity 0.8.28;

import "forge-std/src/Vm.sol";
import {Test, console} from "forge-std/src/Test.sol";
import {Test} from "forge-std/src/Test.sol";
import {Utils} from "test/utils/Utils.sol";
import {GroupMessages} from "src/GroupMessages.sol";
import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/IdentityUpdates.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity 0.8.28;

import "forge-std/src/Vm.sol";
import {Test, console} from "forge-std/src/Test.sol";
import {Test} from "forge-std/src/Test.sol";
import {Utils} from "test/utils/Utils.sol";
import {IdentityUpdates} from "src/IdentityUpdates.sol";
import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
Expand Down
2 changes: 1 addition & 1 deletion dev/baked/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# BUILD IMAGE --------------------------------------------------------
ARG GO_VERSION=1.24
ARG FOUNDRY_VERSION=0.3.0
ARG FOUNDRY_VERSION=1.0.0
FROM golang:${GO_VERSION}-bookworm AS builder

WORKDIR /app
Expand Down
3 changes: 2 additions & 1 deletion dev/up
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash
set -e

if ! which forge &>/dev/null; then echo "ERROR: Missing foundry binaries. Run 'curl -L https://foundry.paradigm.xyz | bash' and follow the instructions" && exit 1; fi
if ! which forge &>/dev/null; then echo "ERROR: Missing foundry binaries. Run 'curl -L https://foundry.paradigm.xyz | bash' and follow the instructions to install foundry 1.0.0" && exit 1; fi
if ! forge --version | grep -q "v1.0.0"; then echo "ERROR: Foundry version is not 1.0.0. Please install the correct version." && exit 1; fi
if ! which shellcheck &>/dev/null; then brew install shellcheck; fi
if ! which jq &>/dev/null; then brew install jq; fi

Expand Down
2 changes: 1 addition & 1 deletion pkg/mocks/authn/mock_JWTVerifier.go

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

2 changes: 1 addition & 1 deletion pkg/mocks/blockchain/mock_ChainClient.go

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

2 changes: 1 addition & 1 deletion pkg/mocks/blockchain/mock_IBlockchainPublisher.go

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

2 changes: 1 addition & 1 deletion pkg/mocks/indexer/mock_ChainReorgHandler.go

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

2 changes: 1 addition & 1 deletion pkg/mocks/indexer/mock_IBlockTracker.go

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

2 changes: 1 addition & 1 deletion pkg/mocks/metadata_api/mock_MetadataApiClient.go

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

2 changes: 1 addition & 1 deletion pkg/mocks/mls_validationv1/mock_ValidationApiClient.go

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

2 changes: 1 addition & 1 deletion pkg/mocks/mlsvalidate/mock_MLSValidationService.go

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

2 changes: 1 addition & 1 deletion pkg/mocks/registry/mock_NodeRegistry.go

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

2 changes: 1 addition & 1 deletion pkg/mocks/registry/mock_NodesContract.go

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

2 changes: 1 addition & 1 deletion pkg/mocks/storer/mock_LogStorer.go

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

44 changes: 36 additions & 8 deletions pkg/sync/syncWorker.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,15 @@ func (s *syncWorker) subscribeToNode(nodeid uint32) {
func (s *syncWorker) subscribeToNodeRegistration(
registration NodeRegistration,
) {

node, err := s.nodeRegistry.GetNode(registration.nodeid)
if err != nil {
// this should never happen
s.log.Error(fmt.Sprintf("Unexpected state: Failed to get node from registry: %v", err))
s.log.Error(
"Unexpected state: Failed to get node from registry",
zap.Uint32("nodeid", registration.nodeid),
zap.Error(err),
)
s.handleUnhealthyNode(registration)
return
}
Expand All @@ -180,11 +185,18 @@ func (s *syncWorker) subscribeToNodeRegistration(
select {
case <-registration.ctx.Done():
// either registry has changed or we are shutting down
s.log.Debug("Context is done. Closing stream and connection")
s.log.Debug(
"Context is done. Closing stream and connection",
zap.String("address", node.HttpAddress),
)
return
default:
if err != nil {
s.log.Error(fmt.Sprintf("Error: %v, retrying...", err))
s.log.Error(
"Error connecting to node. Retrying...",
zap.String("address", node.HttpAddress),
zap.Error(err),
)
time.Sleep(backoff)
backoff = min(backoff*2, 30*time.Second)
} else {
Expand All @@ -203,7 +215,7 @@ func (s *syncWorker) subscribeToNodeRegistration(
_ = conn.Close()
continue
}
err = s.listenToStream(stream)
err = s.listenToStream(registration.ctx, *node, stream)
_ = stream.stream.CloseSend()
_ = conn.Close()
}
Expand Down Expand Up @@ -272,7 +284,7 @@ func (s *syncWorker) connectToNode(node registry.Node) (*grpc.ClientConn, error)
return nil, fmt.Errorf("failed to connect to peer at %s: %v", node.HttpAddress, err)
}

s.log.Debug(fmt.Sprintf("Successfully connected to peer at %s", node.HttpAddress))
s.log.Debug(fmt.Sprintf("Successfully opened a connection to peer at %s", node.HttpAddress))
return conn, nil
}

Expand Down Expand Up @@ -305,8 +317,14 @@ func (s *syncWorker) setupStream(
},
)
if err != nil {
s.log.Error(
"Failed to batch subscribe to peer",
zap.String("peer", node.HttpAddress),
zap.Error(err),
)
return nil, fmt.Errorf(
"failed to batch subscribe to peer: %v",
"failed to batch subscribe to peer at %s: %v",
node.HttpAddress,
err,
)
}
Expand All @@ -324,6 +342,8 @@ func (s *syncWorker) setupStream(
}

func (s *syncWorker) listenToStream(
_ context.Context,
node registry.Node,
originatorStream *originatorStream,
) error {
recvChan := make(chan *message_api.SubscribeEnvelopesResponse)
Expand All @@ -347,7 +367,11 @@ func (s *syncWorker) listenToStream(
return nil

case envs := <-recvChan:
s.log.Debug("Received envelopes", zap.Any("numEnvelopes", len(envs.Envelopes)))
s.log.Debug(
"Received envelopes",
zap.String("peer", node.HttpAddress),
zap.Any("numEnvelopes", len(envs.Envelopes)),
)
for _, env := range envs.Envelopes {
s.validateAndInsertEnvelope(originatorStream, env)
}
Expand All @@ -358,7 +382,11 @@ func (s *syncWorker) listenToStream(
// let the caller rebuild the stream if required
return nil
}
s.log.Error("Stream closed with error", zap.Error(err))
s.log.Error(
"Stream closed with error",
zap.String("peer", node.HttpAddress),
zap.Error(err),
)
return err
}
}
Expand Down
7 changes: 1 addition & 6 deletions tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ require (
github.com/envoyproxy/go-control-plane v0.13.1 // indirect
github.com/envoyproxy/protoc-gen-validate v1.1.0 // indirect
github.com/ethereum/c-kzg-4844 v1.0.0 // indirect
github.com/ethereum/go-ethereum v1.15.2 // indirect
github.com/ethereum/go-ethereum v1.14.13 // indirect
github.com/ethereum/go-verkle v0.2.2 // indirect
github.com/fatih/structtag v1.2.0 // indirect
github.com/felixge/fgprof v0.9.5 // indirect
Expand Down Expand Up @@ -257,11 +257,6 @@ require (
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86 // indirect
github.com/pingcap/log v1.1.0 // indirect
github.com/pingcap/tidb/pkg/parser v0.0.0-20241203170126-9812d85d0d25 // indirect
github.com/pion/dtls/v2 v2.2.7 // indirect
github.com/pion/logging v0.2.2 // indirect
github.com/pion/stun/v2 v2.0.0 // indirect
github.com/pion/transport/v2 v2.2.1 // indirect
github.com/pion/transport/v3 v3.0.1 // indirect
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/profile v1.7.0 // indirect
Expand Down
Loading

0 comments on commit 1e264d5

Please sign in to comment.