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
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
all:

clone-injective-indexer:
git clone https://github.com/InjectiveLabs/injective-indexer.git -b v1.16.69 --depth 1 --single-branch
git clone https://github.com/InjectiveLabs/injective-indexer.git -b v1.16.91 --depth 1 --single-branch
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

🧩 Analysis chain

Version bump looks fine; consider pinning to a commit SHA and centralizing the version.

To prevent tag retargeting and ease future bumps, prefer a variable and/or a commit SHA.

Proposed Makefile snippet (outside this line range):

# At top
INDEXER_TAG ?= v1.16.91

clone-injective-indexer:
	git clone https://github.com/InjectiveLabs/injective-indexer.git -b $(INDEXER_TAG) --depth 1 --single-branch

Verify the tag exists and resolve its SHA:


🏁 Script executed:

#!/bin/bash
set -euo pipefail
gh api repos/InjectiveLabs/injective-indexer/git/ref/tags/v1.16.91 -q .object.sha

Length of output: 138


Pin upstream clone to an immutable ref and centralize the version — tag v1.16.91 not found

gh API returned 404 for refs/tags/v1.16.91; Makefile line 4 currently runs git clone ... -b v1.16.91 — this will fail or be unsafe. Replace the hardcoded tag with a variable and pin to a commit SHA (or fix the tag). Example:
INDEXER_TAG ?= v1.16.91
clone-injective-indexer:
git clone https://github.com/InjectiveLabs/injective-indexer.git -b $(INDEXER_TAG) --depth 1 --single-branch
For immutability prefer INDEXER_SHA and fetch+checkout that SHA instead of relying on a floating tag. Makefile:4

🤖 Prompt for AI Agents
Makefile lines ~4: the Makefile currently clones InjectiveLabs/injective-indexer
using a hardcoded tag v1.16.91 which 404s and is unsafe; replace the hardcoded
tag with a centralized variable (e.g., INDEXER_TAG or preferably INDEXER_SHA)
defined at the top of the Makefile, update the clone target to use that
variable, and if using a SHA perform a shallow clone or clone+fetch and then
checkout the specific SHA to ensure immutability; ensure the tag/sha is
documented in the variable comment so future updates are centralized.


clone-injective-core:
git clone https://github.com/InjectiveLabs/injective-core.git -b v1.16.3 --depth 1 --single-branch
git clone https://github.com/InjectiveLabs/injective-core.git -b v1.16.4 --depth 1 --single-branch

copy-exchange-client: clone-injective-indexer
rm -rf exchange/*
Expand Down Expand Up @@ -51,6 +51,12 @@ copy-chain-types: clone-injective-core
mkdir -p chain/auction/types && \
cp injective-core/injective-chain/modules/auction/types/*.pb.go chain/auction/types && \
cp injective-core/injective-chain/modules/auction/types/codec.go chain/auction/types
mkdir -p chain/downtime-detector/types && \
cp injective-core/injective-chain/modules/downtime-detector/types/*.pb.go chain/downtime-detector/types && \
cp injective-core/injective-chain/modules/downtime-detector/types/codec.go chain/downtime-detector/types && \
cp injective-core/injective-chain/modules/downtime-detector/types/constants.go chain/downtime-detector/types && \
cp injective-core/injective-chain/modules/downtime-detector/types/genesis.go chain/downtime-detector/types && \
cp injective-core/injective-chain/modules/downtime-detector/types/keys.go chain/downtime-detector/types
mkdir -p chain/erc20/types && \
cp injective-core/injective-chain/modules/erc20/types/*.pb.go chain/erc20/types && \
cp injective-core/injective-chain/modules/erc20/types/codec.go chain/erc20/types
Expand Down
146 changes: 107 additions & 39 deletions chain/auction/types/auction.pb.go

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

26 changes: 26 additions & 0 deletions chain/downtime-detector/types/codec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package types

import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
authzcdc "github.com/cosmos/cosmos-sdk/x/authz/codec"
)

func RegisterLegacyAminoCodec(*codec.LegacyAmino) {}

func RegisterInterfaces(types.InterfaceRegistry) {}

var (
ModuleCdc = codec.NewLegacyAmino()
)

func init() {
RegisterLegacyAminoCodec(ModuleCdc)
// Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be
// used to properly serialize MsgGrant and MsgExec instances
sdk.RegisterLegacyAminoCodec(ModuleCdc)
RegisterLegacyAminoCodec(authzcdc.Amino)

ModuleCdc.Seal()
}
83 changes: 83 additions & 0 deletions chain/downtime-detector/types/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package types

import (
"fmt"
"strings"
"time"

"github.com/tidwall/btree"
)

const (
// we don't use a `-` as RouterKey must be alphanumeric
ModuleName = "downtimedetector"
StoreKey = ModuleName
RouterKey = ModuleName

QuerierRoute = ModuleName
)

var (
DowntimeToDuration = btree.NewMap[Downtime, time.Duration](16)
DefaultLastDowntime = time.Unix(0, 0)
)

// init initializes the DowntimeToDuration map with mappings
// from the Duration enum values to their corresponding
// time.Duration values.
func init() {
DowntimeToDuration.Set(Downtime_DURATION_30S, 30*time.Second)
DowntimeToDuration.Set(Downtime_DURATION_1M, time.Minute)
DowntimeToDuration.Set(Downtime_DURATION_2M, 2*time.Minute)
DowntimeToDuration.Set(Downtime_DURATION_3M, 3*time.Minute)
DowntimeToDuration.Set(Downtime_DURATION_4M, 4*time.Minute)
DowntimeToDuration.Set(Downtime_DURATION_5M, 5*time.Minute)
DowntimeToDuration.Set(Downtime_DURATION_10M, 10*time.Minute)
DowntimeToDuration.Set(Downtime_DURATION_20M, 20*time.Minute)
DowntimeToDuration.Set(Downtime_DURATION_30M, 30*time.Minute)
DowntimeToDuration.Set(Downtime_DURATION_40M, 40*time.Minute)
DowntimeToDuration.Set(Downtime_DURATION_50M, 50*time.Minute)
DowntimeToDuration.Set(Downtime_DURATION_1H, time.Hour)
DowntimeToDuration.Set(Downtime_DURATION_1_5H, time.Hour+30*time.Minute)
DowntimeToDuration.Set(Downtime_DURATION_2H, 2*time.Hour)
DowntimeToDuration.Set(Downtime_DURATION_2_5H, 2*time.Hour+30*time.Minute)
DowntimeToDuration.Set(Downtime_DURATION_3H, 3*time.Hour)
DowntimeToDuration.Set(Downtime_DURATION_4H, 4*time.Hour)
DowntimeToDuration.Set(Downtime_DURATION_5H, 5*time.Hour)
DowntimeToDuration.Set(Downtime_DURATION_6H, 6*time.Hour)
DowntimeToDuration.Set(Downtime_DURATION_9H, 9*time.Hour)
DowntimeToDuration.Set(Downtime_DURATION_12H, 12*time.Hour)
DowntimeToDuration.Set(Downtime_DURATION_18H, 18*time.Hour)
DowntimeToDuration.Set(Downtime_DURATION_24H, 24*time.Hour)
DowntimeToDuration.Set(Downtime_DURATION_36H, 36*time.Hour)
DowntimeToDuration.Set(Downtime_DURATION_48H, 48*time.Hour)
}

func DowntimeStrings() []string {
arr := []string{}
DowntimeToDuration.Ascend(Downtime(0), func(_ Downtime, v time.Duration) bool {
s := strings.Replace(v.String(), "m0s", "m", 1)
s = strings.Replace(s, "h0m", "h", 1)
arr = append(arr, s)
return true
})
return arr
}

func DowntimeByDuration(duration time.Duration) (Downtime, error) {
var result Downtime
found := false
DowntimeToDuration.Ascend(Downtime(0), func(k Downtime, v time.Duration) bool {
if v == duration {
result = k
found = true
return false
}
return true
})
if found {
return result, nil
}
downtimeOptions := strings.Join(DowntimeStrings(), ", ")
return result, fmt.Errorf("downtime of %s does not exist. Chain-provided downtimes [%s]", duration.String(), downtimeOptions)
}
Loading