Skip to content

Commit 45e2d2a

Browse files
authored
Merge pull request #5649 from urvisavla/release-horizon-v22.0.3
services/horizon: Fix operations participants logic to include SAC (#5574)
2 parents 425a97f + d17ff95 commit 45e2d2a

File tree

25 files changed

+243
-30
lines changed

25 files changed

+243
-30
lines changed

.github/actions/setup-go/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ runs:
3232
run: echo 'PREFIX=${{ github.workflow }}-${{ github.job }}-${{ runner.os }}-${{ inputs.go-version }}-matrix(${{ join(matrix.*,'|') }})' >> $GITHUB_ENV
3333

3434
# Cache the Go Modules downloaded during the job.
35-
- uses: actions/cache@v2
35+
- uses: actions/cache@v4
3636
with:
3737
path: ~/go/pkg/mod
3838
key: ${{ env.PREFIX }}-go-mod-${{ hashFiles('**/go.sum') }}
3939
restore-keys: ${{ env.PREFIX }}-go-mod-
4040

4141
# Cache any build and test artifacts during the job, which will speed up
4242
# rebuilds and cause test runs to skip tests that have no reason to rerun.
43-
- uses: actions/cache@v2
43+
- uses: actions/cache@v4
4444
with:
4545
path: ~/.cache/go-build
4646
key: ${{ env.PREFIX }}-go-build-${{ github.ref }}-${{ hashFiles('**', '!.git') }}

.github/workflows/galexie-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88

99
publish-docker:
1010
name: Test and push docker image
11-
runs-on: ubuntu-latest
11+
runs-on: ubuntu-22.04
1212
env:
1313
GALEXIE_INTEGRATION_TESTS_ENABLED: "true"
1414
GALEXIE_INTEGRATION_TESTS_CAPTIVE_CORE_BIN: /usr/bin/stellar-core

.github/workflows/galexie.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
jobs:
99
galexie:
1010
name: Test
11-
runs-on: ubuntu-latest
11+
runs-on: ubuntu-22.04
1212
env:
1313
CAPTIVE_CORE_DEBIAN_PKG_VERSION: 22.0.0-2138.721fd0a65.focal
1414
GALEXIE_INTEGRATION_TESTS_ENABLED: "true"

.github/workflows/go.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
matrix:
2020
os: [ubuntu-22.04]
21-
go: ["1.22.1"]
21+
go: ["1.23"]
2222
runs-on: ${{ matrix.os }}
2323
steps:
2424
- uses: actions/checkout@v3
@@ -38,7 +38,7 @@ jobs:
3838
strategy:
3939
matrix:
4040
os: [ubuntu-22.04]
41-
go: ["1.21", "1.22"]
41+
go: ["1.22", "1.23"]
4242
runs-on: ${{ matrix.os }}
4343
steps:
4444
- uses: actions/checkout@v3
@@ -56,7 +56,7 @@ jobs:
5656
strategy:
5757
matrix:
5858
os: [ubuntu-22.04]
59-
go: ["1.21", "1.22"]
59+
go: ["1.22", "1.23"]
6060
pg: [12, 16]
6161
runs-on: ${{ matrix.os }}
6262
services:

.github/workflows/horizon-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222

2323
- uses: ./.github/actions/setup-go
2424
with:
25-
go-version: "1.22"
25+
go-version: "1.23"
2626

2727
- name: Check dependencies
2828
run: ./gomod.sh

.github/workflows/horizon.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
matrix:
1313
os: [ubuntu-20.04, ubuntu-22.04]
14-
go: ["1.21", "1.22"]
14+
go: ["1.22", "1.23"]
1515
pg: [12, 16]
1616
protocol-version: [21, 22]
1717
runs-on: ${{ matrix.os }}
@@ -126,6 +126,7 @@ jobs:
126126
name: Test (and push) verify-range image
127127
runs-on: ubuntu-22.04
128128
env:
129+
GO_VERSION: 1.23.4
129130
STELLAR_CORE_VERSION: 21.3.1-2007.4ede19620.focal
130131
CAPTIVE_CORE_STORAGE_PATH: /tmp
131132
steps:
@@ -136,7 +137,7 @@ jobs:
136137

137138
- name: Build and test the Verify Range Docker image
138139
run: |
139-
docker build --build-arg="GO_VERSION=$(sed -En 's/^toolchain[[:space:]]+go([[:digit:].]+)$/\1/p' go.mod)" -f services/horizon/docker/verify-range/Dockerfile -t stellar/horizon-verify-range services/horizon/docker/verify-range/
140+
docker build --build-arg="GO_VERSION=$GO_VERSION" -f services/horizon/docker/verify-range/Dockerfile -t stellar/horizon-verify-range services/horizon/docker/verify-range/
140141
# Any range should do for basic testing, this range was chosen pretty early in history so that it only takes a few mins to run
141142
docker run -e BRANCH=$(git rev-parse HEAD) -e FROM=10000063 -e TO=10000127 stellar/horizon-verify-range
142143

exp/services/recoverysigner/docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.22-bullseye as build
1+
FROM golang:1.23-bullseye as build
22

33
ADD . /src/recoverysigner
44
WORKDIR /src/recoverysigner

exp/services/webauth/docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.22-bullseye as build
1+
FROM golang:1.23-bullseye as build
22

33
ADD . /src/webauth
44
WORKDIR /src/webauth

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module github.com/stellar/go
22

3-
go 1.22
4-
5-
toolchain go1.22.1
3+
go 1.23
64

75
require (
86
cloud.google.com/go/firestore v1.15.0 // indirect

ingest/ledgerbackend/toml.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ func (c *CaptiveCoreToml) unmarshal(data []byte, strict bool) error {
303303
return err
304304
} else if err = toml.NewDecoder(bytes.NewReader(withoutPlaceHolders)).Strict(strict).Decode(&body); err != nil {
305305
if message := err.Error(); strings.HasPrefix(message, "undecoded keys") {
306-
return fmt.Errorf(strings.Replace(
306+
return errors.New(strings.Replace(
307307
message,
308308
"undecoded keys",
309309
"these fields are not supported by captive core",

services/friendbot/docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.22-bullseye as build
1+
FROM golang:1.23-bullseye as build
22

33
ADD . /src/friendbot
44
WORKDIR /src/friendbot

services/galexie/docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.22-bookworm AS builder
1+
FROM golang:1.23-bookworm AS builder
22

33
WORKDIR /go/src/github.com/stellar/go
44

services/horizon/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
All notable changes to this project will be documented in this
44
file. This project adheres to [Semantic Versioning](http://semver.org/).
55

6+
7+
## 22.0.3
8+
9+
### Fixed
10+
- Fix the account operations endpoint to include InvokeHostFunction operations. The fix ensures that all account operations will be listed going forward. However, it will not retroactively include these operations for previously ingested ledgers; reingesting the historical data is required to address that. ([5574](https://github.com/stellar/go/pull/5574)).
11+
612
## 22.0.2
713

814
### Fixed

services/horizon/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ binary-build:
1111
--pull always \
1212
--env CGO_ENABLED=0 \
1313
--env GOFLAGS="-ldflags=-X=github.com/stellar/go/support/app.version=$(VERSION_STRING)" \
14-
golang:1.22-bullseye \
14+
golang:1.23-bullseye \
1515
/bin/bash -c '\
1616
git config --global --add safe.directory /go/src/github.com/stellar/go && \
1717
cd /go/src/github.com/stellar/go && \

services/horizon/docker/Dockerfile.dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.22-bookworm AS builder
1+
FROM golang:1.23-bookworm AS builder
22

33
ARG VERSION="devel"
44
WORKDIR /go/src/github.com/stellar/go

services/horizon/docker/verify-range/dependencies

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#! /usr/bin/env bash
22
set -e
3+
set -o xtrace
4+
35

46
apt-get update
57
apt-get install -y curl git libpq-dev libsqlite3-dev libsasl2-dev postgresql-client postgresql postgresql-contrib sudo vim zlib1g-dev wget gnupg2 lsb-release

services/horizon/internal/ingest/processor_runner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func (s *ProcessorRunner) buildTransactionProcessor(ledgersProcessor *processors
151151
processors.NewOperationProcessor(s.historyQ.NewOperationBatchInsertBuilder(), s.config.NetworkPassphrase),
152152
tradeProcessor,
153153
processors.NewParticipantsProcessor(accountLoader,
154-
s.historyQ.NewTransactionParticipantsBatchInsertBuilder(), s.historyQ.NewOperationParticipantBatchInsertBuilder()),
154+
s.historyQ.NewTransactionParticipantsBatchInsertBuilder(), s.historyQ.NewOperationParticipantBatchInsertBuilder(), s.config.NetworkPassphrase),
155155
processors.NewTransactionProcessor(s.historyQ.NewTransactionBatchInsertBuilder(), s.config.SkipTxmeta),
156156
processors.NewClaimableBalancesTransactionProcessor(cbLoader,
157157
s.historyQ.NewTransactionClaimableBalanceBatchInsertBuilder(), s.historyQ.NewOperationClaimableBalanceBatchInsertBuilder()),

services/horizon/internal/ingest/processors/operations_processor.go

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,31 @@ func (operation *transactionOperationWrapper) Participants() ([]xdr.AccountId, e
10471047
case xdr.OperationTypeLiquidityPoolWithdraw:
10481048
// the only direct participant is the source_account
10491049
case xdr.OperationTypeInvokeHostFunction:
1050-
// the only direct participant is the source_account
1050+
if changes, err := operation.transaction.GetOperationChanges(operation.index); err != nil {
1051+
return participants, err
1052+
} else {
1053+
for _, change := range changes {
1054+
var data xdr.LedgerEntryData
1055+
switch {
1056+
case change.Post != nil:
1057+
data = change.Post.Data
1058+
case change.Pre != nil:
1059+
data = change.Pre.Data
1060+
default:
1061+
log.Errorf("Change Type %s with no pre or post", change.Type.String())
1062+
continue
1063+
}
1064+
if ledgerKey, err := data.LedgerKey(); err == nil {
1065+
participants = append(participants, getLedgerKeyParticipants(ledgerKey)...)
1066+
}
1067+
}
1068+
}
1069+
if diagnosticEvents, err := operation.transaction.GetDiagnosticEvents(); err != nil {
1070+
return participants, err
1071+
} else {
1072+
participants = append(participants, getParticipantsFromSACEvents(filterEvents(diagnosticEvents), operation.network)...)
1073+
}
1074+
10511075
case xdr.OperationTypeExtendFootprintTtl:
10521076
// the only direct participant is the source_account
10531077
case xdr.OperationTypeRestoreFootprint:
@@ -1067,6 +1091,48 @@ func (operation *transactionOperationWrapper) Participants() ([]xdr.AccountId, e
10671091
return dedupeParticipants(participants), nil
10681092
}
10691093

1094+
func getParticipantsFromSACEvents(contractEvents []xdr.ContractEvent, network string) []xdr.AccountId {
1095+
var participants []xdr.AccountId
1096+
1097+
for _, contractEvent := range contractEvents {
1098+
if sacEvent, err := contractevents.NewStellarAssetContractEvent(&contractEvent, network); err == nil {
1099+
// 'to' and 'from' fields in the events can be either a Contract address or an Account address. We're
1100+
// only interested in account addresses and will skip Contract addresses.
1101+
switch sacEvent.GetType() {
1102+
case contractevents.EventTypeTransfer:
1103+
var transferEvt *contractevents.TransferEvent
1104+
transferEvt = sacEvent.(*contractevents.TransferEvent)
1105+
var from, to xdr.AccountId
1106+
if from, err = xdr.AddressToAccountId(transferEvt.From); err == nil {
1107+
participants = append(participants, from)
1108+
}
1109+
if to, err = xdr.AddressToAccountId(transferEvt.To); err == nil {
1110+
participants = append(participants, to)
1111+
}
1112+
case contractevents.EventTypeMint:
1113+
mintEvt := sacEvent.(*contractevents.MintEvent)
1114+
var to xdr.AccountId
1115+
if to, err = xdr.AddressToAccountId(mintEvt.To); err == nil {
1116+
participants = append(participants, to)
1117+
}
1118+
case contractevents.EventTypeClawback:
1119+
clawbackEvt := sacEvent.(*contractevents.ClawbackEvent)
1120+
var from xdr.AccountId
1121+
if from, err = xdr.AddressToAccountId(clawbackEvt.From); err == nil {
1122+
participants = append(participants, from)
1123+
}
1124+
case contractevents.EventTypeBurn:
1125+
burnEvt := sacEvent.(*contractevents.BurnEvent)
1126+
var from xdr.AccountId
1127+
if from, err = xdr.AddressToAccountId(burnEvt.From); err == nil {
1128+
participants = append(participants, from)
1129+
}
1130+
}
1131+
}
1132+
}
1133+
return participants
1134+
}
1135+
10701136
// dedupeParticipants remove any duplicate ids from `in`
10711137
func dedupeParticipants(in []xdr.AccountId) []xdr.AccountId {
10721138
if len(in) <= 1 {
@@ -1090,7 +1156,7 @@ func dedupeParticipants(in []xdr.AccountId) []xdr.AccountId {
10901156
}
10911157

10921158
// OperationsParticipants returns a map with all participants per operation
1093-
func operationsParticipants(transaction ingest.LedgerTransaction, sequence uint32) (map[int64][]xdr.AccountId, error) {
1159+
func operationsParticipants(transaction ingest.LedgerTransaction, sequence uint32, network string) (map[int64][]xdr.AccountId, error) {
10941160
participants := map[int64][]xdr.AccountId{}
10951161

10961162
for opi, op := range transaction.Envelope.Operations() {
@@ -1099,6 +1165,7 @@ func operationsParticipants(transaction ingest.LedgerTransaction, sequence uint3
10991165
transaction: transaction,
11001166
operation: op,
11011167
ledgerSequence: sequence,
1168+
network: network,
11021169
}
11031170

11041171
p, err := operation.Participants()

services/horizon/internal/ingest/processors/participants_processor.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,21 @@ type ParticipantsProcessor struct {
1919
accountLoader *history.AccountLoader
2020
txBatch history.TransactionParticipantsBatchInsertBuilder
2121
opBatch history.OperationParticipantBatchInsertBuilder
22+
network string
2223
}
2324

2425
func NewParticipantsProcessor(
2526
accountLoader *history.AccountLoader,
2627
txBatch history.TransactionParticipantsBatchInsertBuilder,
2728
opBatch history.OperationParticipantBatchInsertBuilder,
29+
network string,
30+
2831
) *ParticipantsProcessor {
2932
return &ParticipantsProcessor{
3033
accountLoader: accountLoader,
3134
txBatch: txBatch,
3235
opBatch: opBatch,
36+
network: network,
3337
}
3438
}
3539

@@ -129,7 +133,7 @@ func (p *ParticipantsProcessor) addOperationsParticipants(
129133
sequence uint32,
130134
transaction ingest.LedgerTransaction,
131135
) error {
132-
participants, err := operationsParticipants(transaction, sequence)
136+
participants, err := operationsParticipants(transaction, sequence, p.network)
133137
if err != nil {
134138
return errors.Wrap(err, "could not determine operation participants")
135139
}

services/horizon/internal/ingest/processors/participants_processor_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ func (s *ParticipantsProcessorTestSuiteLedger) SetupTest() {
9696
s.accountLoader,
9797
s.mockBatchInsertBuilder,
9898
s.mockOperationsBatchInsertBuilder,
99+
networkPassphrase,
99100
)
100101

101102
s.txs = []ingest.LedgerTransaction{

0 commit comments

Comments
 (0)