Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.24'
go-version: '1.25.3'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v8
with:
# Require: The version of golangci-lint to use.
version: v2.2.1
version: v2.10.1
args: --timeout=30m --issues-exit-code=0 --verbose

acceptance-test:
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
go-version: '1.25.3'

- name: Install Taskfile
uses: arduino/setup-task@v2
Expand Down Expand Up @@ -226,7 +226,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
go-version: '1.25.3'

- name: Install Taskfile
uses: arduino/setup-task@v2
Expand Down
23 changes: 14 additions & 9 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
version: "2"

output:
formats:
text:
path: stdout
colors: true

linters:
disable:
- errcheck
- staticcheck
- unused
- ineffassign
exclusions:
paths:
- deployments/infra/cdk.out
- vendor

run:
build-tags:
- kwiltest
output:
formats:
text:
path: stdout
colors: true
version: "2"
2 changes: 1 addition & 1 deletion deployments/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.24.3-alpine3.21 AS build
FROM golang:1.25.3-alpine3.21 AS build

# Use buildx automatic platform args
ARG TARGETOS=linux
Expand Down
2 changes: 1 addition & 1 deletion extensions/tn_settlement/settlement_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ func testLoadSettlementConfig(t *testing.T) func(context.Context, *kwilTesting.P
require.NoError(t, err)
require.True(t, enabled, "should be true (enabled by migration 041)")
require.Equal(t, "0,30 * * * *", schedule, "should be 30-minute schedule from migration 041")
require.Equal(t, 100, maxMarkets, "should be 100 from migration 041")
require.Equal(t, 1000, maxMarkets, "should be 1000 from migration 041")
require.Equal(t, 3, retries)

t.Logf("✅ LoadSettlementConfig loaded config from migration: enabled=%v, schedule=%s, max=%d, retries=%d",
Expand Down
26 changes: 0 additions & 26 deletions extensions/tn_utils/datapoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const dataPointTargetScale uint16 = 18
var (
dataPointsABIArgs gethAbi.Arguments
booleanABIArgs gethAbi.Arguments
queryComponentsABIArgs gethAbi.Arguments
)

func init() {
Expand All @@ -39,31 +38,6 @@ func init() {
booleanABIArgs = gethAbi.Arguments{
{Type: boolType},
}

// ABI types for query components: (address, bytes32, string, bytes)
addressType, err := gethAbi.NewType("address", "", nil)
if err != nil {
panic(fmt.Sprintf("tn_utils: failed to initialise address ABI type: %v", err))
}
bytes32Type, err := gethAbi.NewType("bytes32", "", nil)
if err != nil {
panic(fmt.Sprintf("tn_utils: failed to initialise bytes32 ABI type: %v", err))
}
stringType, err := gethAbi.NewType("string", "", nil)
if err != nil {
panic(fmt.Sprintf("tn_utils: failed to initialise string ABI type: %v", err))
}
bytesType, err := gethAbi.NewType("bytes", "", nil)
if err != nil {
panic(fmt.Sprintf("tn_utils: failed to initialise bytes ABI type: %v", err))
}

queryComponentsABIArgs = gethAbi.Arguments{
{Type: addressType, Name: "data_provider"},
{Type: bytes32Type, Name: "stream_id"},
{Type: stringType, Name: "action_id"},
{Type: bytesType, Name: "args"},
}
}

// EncodeDataPointsABI converts the canonical result serialization produced by
Expand Down
84 changes: 9 additions & 75 deletions extensions/tn_utils/precompiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import (
"math"
"math/big"

gethCommon "github.com/ethereum/go-ethereum/common"
"github.com/trufnetwork/kwil-db/common"
"github.com/trufnetwork/kwil-db/core/types"
"github.com/trufnetwork/kwil-db/extensions/precompiles"
"github.com/trufnetwork/sdk-go/core/contractsapi"
"github.com/trufnetwork/sdk-go/core/util"
)

// buildPrecompile groups all tn_utils methods into a single precompile bundle so
Expand All @@ -32,7 +33,6 @@ func buildPrecompile() precompiles.Precompile {
forceLastArgFalseMethod(),
parseAttestationBooleanMethod(),
computeAttestationHashMethod(),
decodeQueryComponentsMethod(),
},
}
}
Expand Down Expand Up @@ -720,84 +720,18 @@ func IsBinaryAction(actionID uint16) bool {
return actionID >= 6 && actionID <= 9
}

// decodeQueryComponentsMethod decodes ABI-encoded query components into its
// structured parts (dataProvider, streamID, actionID, args).
func decodeQueryComponentsMethod() precompiles.Method {
return precompiles.Method{
Name: "decode_query_components",
AccessModifiers: []precompiles.Modifier{precompiles.VIEW, precompiles.PUBLIC},
Parameters: []precompiles.PrecompileValue{
precompiles.NewPrecompileValue("query_components", types.ByteaType, false),
},
Returns: &precompiles.MethodReturn{
IsTable: true,
Fields: []precompiles.PrecompileValue{
precompiles.NewPrecompileValue("data_provider", types.ByteaType, false),
precompiles.NewPrecompileValue("stream_id", types.ByteaType, false),
precompiles.NewPrecompileValue("action_id", types.TextType, false),
precompiles.NewPrecompileValue("args", types.ByteaType, false),
},
},
Handler: decodeQueryComponentsHandler,
}
}

// decodeQueryComponentsHandler decodes ABI-encoded query components.
func decodeQueryComponentsHandler(ctx *common.EngineContext, app *common.App, inputs []any, resultFn func([]any) error) error {
queryComponents, err := toByteSliceAllowNil(inputs[0])
if err != nil {
return err
}

if len(queryComponents) == 0 {
return fmt.Errorf("query_components cannot be empty")
}

dataProvider, streamID, actionID, args, err := unpackQueryComponents(queryComponents)
if err != nil {
return err
}

return resultFn([]any{
dataProvider,
streamID,
actionID,
args,
})
}

// unpackQueryComponents extracts (dataProvider, streamID, actionID, args) from ABI-encoded bytes.
// This is a private helper used by computeAttestationHashHandler for consensus logic.
func unpackQueryComponents(data []byte) (dataProvider []byte, streamID []byte, actionID string, args []byte, err error) {
// Decode ABI using pre-initialised package-level args
decoded, err := queryComponentsABIArgs.Unpack(data)
dp, sid, aid, argBytes, err := contractsapi.DecodeQueryComponents(data)
if err != nil {
return nil, nil, "", nil, fmt.Errorf("failed to decode query_components: %w", err)
return nil, nil, "", nil, err
}

if len(decoded) != 4 {
return nil, nil, "", nil, fmt.Errorf("expected 4 components, got %d", len(decoded))
}

// Type assertions and shape conversions
dpAddr, ok := decoded[0].(gethCommon.Address)
if !ok {
return nil, nil, "", nil, fmt.Errorf("data_provider must be address, got %T", decoded[0])
}

sid, ok := decoded[1].([32]byte)
if !ok {
return nil, nil, "", nil, fmt.Errorf("stream_id must be bytes32, got %T", decoded[1])
}

aid, ok := decoded[2].(string)
if !ok {
return nil, nil, "", nil, fmt.Errorf("action_id must be string, got %T", decoded[2])
}

argBytes, ok := decoded[3].([]byte)
if !ok {
return nil, nil, "", nil, fmt.Errorf("args must be bytes, got %T", decoded[3])
addr, err := util.NewEthereumAddressFromString(dp)
if err != nil {
return nil, nil, "", nil, fmt.Errorf("invalid data_provider address: %w", err)
}

return dpAddr.Bytes(), sid[:], aid, argBytes, nil
return addr.Bytes(), []byte(sid), aid, argBytes, nil
Comment thread
MicBun marked this conversation as resolved.
}
69 changes: 0 additions & 69 deletions extensions/tn_utils/precompiles_decoding_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion extensions/tn_utils/precompiles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func TestComputeAttestationHash(t *testing.T) {
})

require.Error(t, err)
require.Contains(t, err.Error(), "failed to decode query_components")
require.Contains(t, err.Error(), "failed to ABI-decode query_components")
})

t.Run("UnknownActionID_ReturnsError", func(t *testing.T) {
Expand Down
Loading
Loading