Skip to content

Commit fcd2757

Browse files
authored
update feeder dependency (#364)
* update feeder dependency * exit feeder when node exits * update twap proto definition * update env example * update feeder dependency to v0.2.8 * update golang version in Dockerfile to 1.23 * update runtime alpine version * fix runtime alpine package version
1 parent c3fb131 commit fcd2757

File tree

11 files changed

+485
-79
lines changed

11 files changed

+485
-79
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
ALCHEMY_API_KEY=
2-
ANKR_API_KEY=
2+
BOOTSTRAP=

Dockerfile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ WORKDIR /go/src/github.com/imua-xyz/imuachain
66

77
COPY go.mod go.sum ./
88

9-
RUN apk add --no-cache ca-certificates=20241121-r1 build-base=0.5-r3 git=2.47.3-r0 linux-headers=6.6-r1
9+
RUN apk add --no-cache ca-certificates=~20241121 build-base=~0.5 git=~2.47.3 linux-headers=~6.6
1010

1111
RUN --mount=type=bind,target=. --mount=type=secret,id=GITHUB_TOKEN \
1212
git config --global url."https://$(cat /run/secrets/GITHUB_TOKEN)@github.com/".insteadOf "https://github.com/"; \
@@ -16,19 +16,19 @@ COPY . .
1616

1717
RUN make build && go install github.com/MinseokOh/toml-cli@latest
1818

19-
FROM alpine:3.19
19+
FROM alpine:3.21
2020

2121
WORKDIR /root
2222

2323
COPY --from=build-env /go/src/github.com/imua-xyz/imuachain/build/imuad /usr/bin/imuad
2424
COPY --from=build-env /go/bin/toml-cli /usr/bin/toml-cli
2525

2626
RUN apk add --no-cache \
27-
ca-certificates=20241121-r1 \
28-
libstdc++~=13.2 \
29-
jq~=1.7 \
30-
curl~=8.12.1-r0 \
31-
bash~=5.2 \
27+
ca-certificates=~20241121 \
28+
libstdc++=~14.2.0 \
29+
jq=~1.7.1 \
30+
curl=~8.12.1 \
31+
bash=~5.2.37 \
3232
&& addgroup -g 1000 imua \
3333
&& adduser -S -h /home/imua -D imua -u 1000 -G imua
3434

client/docs/swagger-ui/swagger.json

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19078,6 +19078,7 @@
1907819078
}
1907919079
},
1908019080
"accumulated_price": {
19081+
"title": "accumulated price of the token",
1908119082
"type": "object",
1908219083
"properties": {
1908319084
"price": {
@@ -19093,13 +19094,17 @@
1909319094
"type": "string",
1909419095
"title": "timestamp when the price is corresponded"
1909519096
},
19096-
"round_id": {
19097+
"last_round_id": {
1909719098
"type": "string",
1909819099
"format": "uint64",
1909919100
"title": "roundid of the price if the source is deteministic"
19101+
},
19102+
"start_round_id": {
19103+
"type": "string",
19104+
"format": "uint64",
19105+
"title": "start_round_id is used to indicate the round id of the first price in this accumulator"
1910019106
}
19101-
},
19102-
"title": "price with its specified timestamp and roundid(if from deteministic source)"
19107+
}
1910319108
}
1910419109
}
1910519110
}
@@ -43989,6 +43994,35 @@
4398943994
},
4399043995
"description": "Params defines the parameters for the module."
4399143996
},
43997+
"imuachain.oracle.v1.PriceAcc": {
43998+
"type": "object",
43999+
"properties": {
44000+
"price": {
44001+
"type": "string",
44002+
"title": "price"
44003+
},
44004+
"decimal": {
44005+
"type": "integer",
44006+
"format": "int32",
44007+
"title": "decimal of the corresponding price"
44008+
},
44009+
"timestamp": {
44010+
"type": "string",
44011+
"title": "timestamp when the price is corresponded"
44012+
},
44013+
"last_round_id": {
44014+
"type": "string",
44015+
"format": "uint64",
44016+
"title": "roundid of the price if the source is deteministic"
44017+
},
44018+
"start_round_id": {
44019+
"type": "string",
44020+
"format": "uint64",
44021+
"title": "start_round_id is used to indicate the round id of the first price in this accumulator"
44022+
}
44023+
},
44024+
"title": "PriceAcc is used for price accumulator, which is used to store the latest accumulated price"
44025+
},
4399244026
"imuachain.oracle.v1.PriceEpoch": {
4399344027
"type": "object",
4399444028
"properties": {
@@ -44178,6 +44212,7 @@
4417844212
}
4417944213
},
4418044214
"accumulated_price": {
44215+
"title": "accumulated price of the token",
4418144216
"type": "object",
4418244217
"properties": {
4418344218
"price": {
@@ -44193,13 +44228,17 @@
4419344228
"type": "string",
4419444229
"title": "timestamp when the price is corresponded"
4419544230
},
44196-
"round_id": {
44231+
"last_round_id": {
4419744232
"type": "string",
4419844233
"format": "uint64",
4419944234
"title": "roundid of the price if the source is deteministic"
44235+
},
44236+
"start_round_id": {
44237+
"type": "string",
44238+
"format": "uint64",
44239+
"title": "start_round_id is used to indicate the round id of the first price in this accumulator"
4420044240
}
44201-
},
44202-
"title": "price with its specified timestamp and roundid(if from deteministic source)"
44241+
}
4420344242
}
4420444243
},
4420544244
"title": "prices of all rounds of a specific token"
@@ -44743,6 +44782,7 @@
4474344782
}
4474444783
},
4474544784
"accumulated_price": {
44785+
"title": "accumulated price of the token",
4474644786
"type": "object",
4474744787
"properties": {
4474844788
"price": {
@@ -44758,13 +44798,17 @@
4475844798
"type": "string",
4475944799
"title": "timestamp when the price is corresponded"
4476044800
},
44761-
"round_id": {
44801+
"last_round_id": {
4476244802
"type": "string",
4476344803
"format": "uint64",
4476444804
"title": "roundid of the price if the source is deteministic"
44805+
},
44806+
"start_round_id": {
44807+
"type": "string",
44808+
"format": "uint64",
44809+
"title": "start_round_id is used to indicate the round id of the first price in this accumulator"
4476544810
}
44766-
},
44767-
"title": "price with its specified timestamp and roundid(if from deteministic source)"
44811+
}
4476844812
}
4476944813
}
4477044814
}

cmd/imuad/external.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import (
44
"fmt"
55
"os"
66
"os/exec"
7+
"os/signal"
78
"regexp"
89
"strconv"
910
"strings"
11+
"syscall"
1012
"time"
1113

1214
sdkserver "github.com/cosmos/cosmos-sdk/server"
@@ -148,6 +150,18 @@ func launchFeeder(configFile, sourcesConfPath, binPath, mnemonic string, logger
148150
cmd.Stdout = os.Stdout
149151
cmd.Stderr = os.Stderr
150152

153+
sig := make(chan os.Signal, 1)
154+
signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM)
155+
go func() {
156+
<-sig
157+
if cmd.Process != nil {
158+
if err := cmd.Process.Kill(); err != nil {
159+
logger.Error("failed to kill process", "pid", cmd.Process.Pid, "err", err)
160+
} else {
161+
logger.Info("feeder subprocess terminated by signal", "pid", cmd.Process.Pid)
162+
}
163+
}
164+
}()
151165
if err := cmd.Start(); err != nil {
152166
logger.Error("failed to start feeder subprocess", "err", err)
153167
return

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ require (
2323
github.com/gorilla/mux v1.8.1
2424
github.com/grpc-ecosystem/grpc-gateway v1.16.0
2525
github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3
26-
github.com/imua-xyz/price-feeder v0.0.0-00010101000000-000000000000
26+
github.com/imua-xyz/price-feeder v0.2.8
2727
github.com/onsi/ginkgo/v2 v2.15.0
2828
github.com/onsi/gomega v1.31.1
2929
github.com/pkg/errors v0.9.1
@@ -297,8 +297,6 @@ replace (
297297
// Security Advisory https://github.com/advisories/GHSA-h395-qcrw-5vmq
298298
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.1
299299

300-
github.com/imua-xyz/price-feeder => github.com/leonz789/price-feeder v0.0.0-20250629150533-749113c62e2a
301-
302300
// replace broken goleveldb
303301
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
304302
//fix cosmos-sdk error

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,6 +1176,8 @@ github.com/imua-xyz/cosmos-sdk v0.47.5-evmos.2.0.20250312095401-0035968c59f0 h1:
11761176
github.com/imua-xyz/cosmos-sdk v0.47.5-evmos.2.0.20250312095401-0035968c59f0/go.mod h1:EHwCeN9IXonsjKcjpS12MqeStdZvIdxt3VYXhus3G3c=
11771177
github.com/imua-xyz/evmos/v16 v16.0.3-0.20250515032007-e21b41cb9b20 h1:OvRREovoBRCGwSkaGiEzgpOSjLhGeldeWBPWcJH8oWA=
11781178
github.com/imua-xyz/evmos/v16 v16.0.3-0.20250515032007-e21b41cb9b20/go.mod h1:aPzVlrI2p5Jb0tETC15f4CVRYwzChGy+Wp6SebGc6tE=
1179+
github.com/imua-xyz/price-feeder v0.2.8 h1:fLxmtBN0zdpe0XpXu1zurCPP/nYCtGpc6PG3k1Q83RU=
1180+
github.com/imua-xyz/price-feeder v0.2.8/go.mod h1:z3oRSlLZ59UgzmlKr4Vhw9WGB42AOS8uXr6/bQ7UoVA=
11791181
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
11801182
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
11811183
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
@@ -1252,8 +1254,6 @@ github.com/ledgerwatch/erigon-lib v0.0.0-20230210071639-db0e7ed11263 h1:LGEzZvf3
12521254
github.com/ledgerwatch/erigon-lib v0.0.0-20230210071639-db0e7ed11263/go.mod h1:OXgMDuUo2lZ3NpH29ZvMYbk+LxFd5ffDl2Z2mGMuY/I=
12531255
github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
12541256
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
1255-
github.com/leonz789/price-feeder v0.0.0-20250629150533-749113c62e2a h1:2z/krlOqh/H3vsEjFiN9mCeD6zLEzOIx+rMV8M/ewiI=
1256-
github.com/leonz789/price-feeder v0.0.0-20250629150533-749113c62e2a/go.mod h1:z3oRSlLZ59UgzmlKr4Vhw9WGB42AOS8uXr6/bQ7UoVA=
12571257
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
12581258
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
12591259
github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8=

networks/local/imuachain/Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FROM golang:1.23.11-alpine3.21 AS build
2-
RUN apk add --no-cache build-base=0.5-r3 git=2.47.3-r0 linux-headers=6.6-r1
2+
RUN apk add --no-cache build-base=~0.5 git=~2.47.3 linux-headers=~6.6
33
# Set working directory for the build
44
WORKDIR /go/work
55
# Add source files
@@ -11,10 +11,10 @@ RUN LEDGER_ENABLED=false make build
1111
#####################################
1212
FROM alpine:3.21 AS run
1313
RUN apk add --no-cache \
14-
libstdc++=14.2.0-r4 \
15-
bash=5.2.37-r0 \
16-
curl=8.12.1-r1 \
17-
jq=1.7.1-r0 \
14+
libstdc++=~14.2.0 \
15+
bash=~5.2.37 \
16+
curl=~8.12.1 \
17+
jq=~1.7.1 \
1818
&& addgroup -g 1000 imua \
1919
&& adduser -S -h /home/imua -D imua -u 1000 -G imua
2020
EXPOSE 26656 26657 1317 9090 8545 8546

proto/imuachain/oracle/v1/price.proto

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,17 @@ message PriceEpoch {
5757
// timestamp when the price is corresponded
5858
string timestamp = 5;
5959
}
60+
61+
// PriceAcc is used for price accumulator, which is used to store the latest accumulated price
62+
message PriceAcc {
63+
// price
64+
string price = 1;
65+
// decimal of the corresponding price
66+
int32 decimal = 2;
67+
// timestamp when the price is corresponded
68+
string timestamp = 3;
69+
// roundid of the price if the source is deteministic
70+
uint64 last_round_id = 4 [(gogoproto.customname) = "LastRoundID"];
71+
// start_round_id is used to indicate the round id of the first price in this accumulator
72+
uint64 start_round_id = 5 [(gogoproto.customname) = "StartRoundID"];
73+
}

proto/imuachain/oracle/v1/prices.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ message Prices {
1717
// TWAP of the token
1818
PriceEpoch twap = 4;
1919
// accumulated price of the token
20-
PriceTimeRound accumulated_price = 5;
20+
PriceAcc accumulated_price = 5;
2121
}

0 commit comments

Comments
 (0)