Skip to content

Commit

Permalink
Merge branch 'main' into edz/update-cardinal-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ezavada authored Jan 16, 2025
2 parents d29ca92 + d2f8eff commit a34f54f
Show file tree
Hide file tree
Showing 98 changed files with 19,238 additions and 3,022 deletions.
46 changes: 23 additions & 23 deletions .github/workflows/ci-evm.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
name: CI
# name: CI

on:
pull_request:
paths:
- evm/**
push:
paths:
- evm/**
branches:
- main
# on:
# pull_request:
# paths:
# - evm/**
# push:
# paths:
# - evm/**
# branches:
# - main

jobs:
build-evm:
name: Build (EVM)
runs-on: namespace-profile-linux-8vcpu-16gb-cached
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Rollup
run: make rollup-build
# jobs:
# build-evm:
# name: Build (EVM)
# runs-on: namespace-profile-linux-8vcpu-16gb-cached
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - name: Install Foundry
# uses: foundry-rs/foundry-toolchain@v1
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
# - name: Build Rollup
# run: make rollup-build
34 changes: 2 additions & 32 deletions .github/workflows/ci-go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
version: v1.57.1
version: v1.62.2
args: --timeout=10m -v ${{ steps.go-dir.outputs.path }}
## skip cache, use Namespace volume cache
skip-cache: true
Expand Down Expand Up @@ -123,34 +123,4 @@ jobs:
- name: E2E docker compose logs last status
if: success() || failure()
run: |
docker compose logs
e2e-evm:
name: E2E (EVM)
runs-on:
- nscloud-ubuntu-22.04-amd64-4x16-with-cache-with-features
- nscloud-cache-tag-e2e
- nscloud-exp-features:privileged;host-pid-namespace
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Golang
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
## skip cache, use Namespace volume cache
cache: false
- name: Install and configure Namespace CLI
uses: namespacelabs/nscloud-setup@v0
- name: Configure Namespace powered Buildx
uses: namespacelabs/nscloud-setup-buildx-action@v0
- name: Setup Namespace cache
uses: namespacelabs/nscloud-cache-action@v1
with:
cache: go
- name: E2E Test (EVM)
run: make e2e-evm
- name: E2E docker compose logs last status
if: success() || failure()
run: |
docker compose logs
docker compose logs
12 changes: 10 additions & 2 deletions .github/workflows/release-nakama.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ jobs:
type=semver,pattern={{version}},value=${{ steps.semver.outputs.tag }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.semver.outputs.tag }}
type=sha
- name: Prepare arm64 tags
id: arm64_tags
run: |
TAGS="${{ steps.meta.outputs.tags }}"
TAGS_ARM64="$(echo "$TAGS" | grep -v 'sha-' | sed 's/$/-arm64/g')"
echo "tags<<EOF" >> $GITHUB_OUTPUT
echo "$TAGS_ARM64" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@v5
with:
Expand All @@ -70,5 +78,5 @@ jobs:
target: nakama-arm
platforms: linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}-arm64
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.arm64_tags.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}-arm64
13 changes: 8 additions & 5 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ linters-settings:
# Default: true
skipRecvDeref: false

gomnd:
mnd:
# List of function patterns to exclude from analysis.
# Values always ignored: `time.Date`,
# `strconv.FormatInt`, `strconv.FormatUint`, `strconv.FormatFloat`,
Expand Down Expand Up @@ -139,7 +139,7 @@ linters-settings:
nolintlint:
# Exclude following linters from requiring an explanation.
# Default: []
allow-no-explanation: [ funlen, gocognit, lll, exhaustruct, decorder, gomnd ]
allow-no-explanation: [funlen, gocognit, lll, exhaustruct, decorder, mnd]
# Enable to require an explanation of nonzero length after each nolint directive.
# Default: false
require-explanation: true
Expand Down Expand Up @@ -196,6 +196,10 @@ linters-settings:
# Default: false
custom-order: true

gosec:
excludes:
- G115 # Selectively disable G115 for cases where we've verified the conversions are safe

linters:
disable-all: true
enable:
Expand All @@ -217,9 +221,7 @@ linters:
- durationcheck # checks for two durations multiplied together
- errname # checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error
- errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13
- execinquery # checks query string in Query function which reads your Go src files and warning it finds
- exhaustive # checks exhaustiveness of enum switch statements
- exportloopref # checks for pointers to enclosing loop variables
- forbidigo # forbids identifiers
- funlen # tool for detection of long functions
- gocheckcompilerdirectives # validates go compiler directive comments (//go:)
Expand All @@ -232,7 +234,7 @@ linters:
- gocyclo # computes and checks the cyclomatic complexity of functions
#- godot # checks if comments end in a period
- goimports # in addition to fixing imports, goimports also formats your code in the same style as gofmt
- gomnd # detects magic numbers
- mnd # detects magic numbers
- gomoddirectives # manages the use of 'replace', 'retract', and 'excludes' directives in go.mod
#- gomodguard # allow and block lists linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations
- goprintffuncname # checks that printf-like functions are named with f at the end
Expand Down Expand Up @@ -324,6 +326,7 @@ issues:
- noctx
- wrapcheck
- perfsprint
- errcheck
# TODO: remove after PR is released https://github.com/golangci/golangci-lint/pull/4386
- text: "fmt.Sprintf can be replaced with string addition"
linters: [ perfsprint ]
4 changes: 2 additions & 2 deletions assert/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ go 1.22.1

require (
github.com/rotisserie/eris v0.5.4
github.com/stretchr/testify v1.9.0
github.com/stretchr/testify v1.10.0
gotest.tools/v3 v3.5.1
)

require (
github.com/kr/pretty v0.3.1 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/rogpeppe/go-internal v1.13.1 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
)

Expand Down
8 changes: 4 additions & 4 deletions assert/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsK
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
github.com/rotisserie/eris v0.5.4 h1:Il6IvLdAapsMhvuOahHWiBnl1G++Q0/L5UIkI5mARSk=
github.com/rotisserie/eris v0.5.4/go.mod h1:Z/kgYTJiJtocxCbFfvRmO+QejApzG6zpyky9G1A4g9s=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
Expand Down
4 changes: 0 additions & 4 deletions cardinal/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ var (
BaseShardSequencerAddress: DefaultBaseShardSequencerAddress,
BaseShardRouterKey: "",
TelemetryTraceEnabled: false,
TelemetryProfilerEnabled: false,
}
)

Expand Down Expand Up @@ -78,9 +77,6 @@ type WorldConfig struct {

// TelemetryTraceEnabled When true, Cardinal will collect OpenTelemetry traces
TelemetryTraceEnabled bool `mapstructure:"TELEMETRY_TRACE_ENABLED"`

// TelemetryProfilerEnabled When true, Cardinal will run Datadog continuous profiling
TelemetryProfilerEnabled bool `mapstructure:"TELEMETRY_PROFILER_ENABLED"`
}

func loadWorldConfig() (*WorldConfig, error) {
Expand Down
9 changes: 4 additions & 5 deletions cardinal/filter/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ type ComponentFilter interface {
MatchesComponents(components []types.Component) bool
}

// ComponentWrapper wraps a Component type for filtering purposes.
type ComponentWrapper struct {
Component types.Component
}

// Component is public but contains an unexported return type
// this is done with intent as the user should never use ComponentWrapper
// explicitly.
//
//revive:disable-next-line:unexported-return
// Component returns a ComponentWrapper for the given component type T.
// This function is intentionally designed to return an unexported type
// as ComponentWrapper should not be used directly.
func Component[T types.Component]() ComponentWrapper {
var x T
return ComponentWrapper{
Expand Down
13 changes: 5 additions & 8 deletions cardinal/gamestate/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/trace"
ddotel "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/opentelemetry"
ddtracer "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"

"pkg.world.dev/world-engine/cardinal/codec"
"pkg.world.dev/world-engine/cardinal/types"
Expand Down Expand Up @@ -126,7 +124,7 @@ func (r *RedisStorage) StartTransaction(_ context.Context) (Transaction[string],
}

func (r *RedisStorage) EndTransaction(ctx context.Context) error {
ctx, span := r.tracer.Start(ddotel.ContextWithStartOptions(ctx, ddtracer.Measured()), "redis.transaction.end")
ctx, span := r.tracer.Start(ctx, "redis.transaction.end")
defer span.End()

pipeline, ok := r.currentClient.(redis.Pipeliner)
Expand All @@ -150,7 +148,7 @@ func (r *RedisStorage) EndTransaction(ctx context.Context) error {
// makePipeOfRedisCommands return a pipeliner with all pending state changes to redis ready to be committed in an atomic
// transaction. If an error is returned, no redis changes will have been made.
func (m *EntityCommandBuffer) makePipeOfRedisCommands(ctx context.Context) (PrimitiveStorage[string], error) {
ctx, span := m.tracer.Start(ddotel.ContextWithStartOptions(ctx, ddtracer.Measured()), "ecb.tick.finalize.pipe_make")
ctx, span := m.tracer.Start(ctx, "ecb.tick.finalize.pipe_make")
defer span.End()

pipe, err := m.dbStorage.StartTransaction(ctx)
Expand Down Expand Up @@ -179,15 +177,14 @@ func (m *EntityCommandBuffer) makePipeOfRedisCommands(ctx context.Context) (Prim
}

for _, operation := range operations {
ctx, pipeSpan := m.tracer.Start(ddotel.ContextWithStartOptions(ctx, //nolint:spancheck // false positive
ddtracer.Measured()),
"tick.span.finalize.pipe_make."+operation.name)
ctx, pipeSpan := m.tracer.Start(ctx, "tick.span.finalize.pipe_make."+operation.name)
if err := operation.method(ctx, pipe); err != nil {
span.SetStatus(codes.Error, eris.ToString(err, true))
span.RecordError(err)
pipeSpan.SetStatus(codes.Error, eris.ToString(err, true))
pipeSpan.RecordError(err)
return nil, eris.Wrapf(err, "failed to run step %q", operation.name) //nolint:spancheck // false positive
pipeSpan.End()
return nil, eris.Wrapf(err, "failed to run step %q", operation.name)
}
pipeSpan.End()
}
Expand Down
4 changes: 1 addition & 3 deletions cardinal/gamestate/tick.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"github.com/redis/go-redis/v9"
"github.com/rotisserie/eris"
"go.opentelemetry.io/otel/codes"
ddotel "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/opentelemetry"
ddtracer "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
)

// The world tick must be updated in the same atomic transaction as all the state changes
Expand Down Expand Up @@ -37,7 +35,7 @@ func (m *EntityCommandBuffer) GetLastFinalizedTick() (uint64, error) {
// FinalizeTick combines all pending state changes into a single multi/exec redis transactions and commits them
// to the DB.
func (m *EntityCommandBuffer) FinalizeTick(ctx context.Context) error {
ctx, span := m.tracer.Start(ddotel.ContextWithStartOptions(ctx, ddtracer.Measured()), "ecb.tick.finalize")
ctx, span := m.tracer.Start(ctx, "ecb.tick.finalize")
defer span.End()

pipe, err := m.makePipeOfRedisCommands(ctx)
Expand Down
Loading

0 comments on commit a34f54f

Please sign in to comment.