Skip to content

Commit

Permalink
merge qa to develop (maticnetwork#877)
Browse files Browse the repository at this point in the history
* task delay change

* fix

* add checks in clu

* remove cli checks

* add testcase

* Set default max number of open files for heimdall service

* Add 'heimdall' user during package installation

* Fixed helper.UnpackLog function call in the self-healing process (maticnetwork#853)

* Add linter to CI pipeline  (maticnetwork#844)

* Remove dependency on mainnet.toml and mumbai.toml

In new CLI, a single binary should work for both mainnet and testnet. This change will remove the dependency on
mainnet.toml and mumbai.toml in build time so we won't need to build two different binaries for each network.

* fix: remove duplicate import

Co-authored-by: Arpit Temani <[email protected]>
Co-authored-by: Jerry <[email protected]>
Co-authored-by: Roman Behma <[email protected]>
  • Loading branch information
4 people authored Sep 22, 2022
1 parent 8bb0a64 commit 7df0380
Show file tree
Hide file tree
Showing 21 changed files with 158 additions and 166 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ jobs:
with:
go-version: 1.18.x

- name: "Generate Heimdall Params"
run: go run helper/heimdall-params.template.go $(network)

- name: "Run linter"
run: make lint

Expand All @@ -54,9 +51,6 @@ jobs:
with:
go-version: 1.18.x

- name: "Generate Heimdall Params"
run: go run helper/heimdall-params.template.go $(network)

- name: "Run tests"
run: make tests

Expand Down
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@ tests:

# make build
build: clean
go run helper/heimdall-params.template.go $(network)
mkdir -p build
go build -o build/heimdalld ./cmd/heimdalld
go build -o build/heimdallcli ./cmd/heimdallcli
@echo "====================================================\n==================Build Successful==================\n===================================================="

# make install
install:
go run helper/heimdall-params.template.go $(network)
go install $(BUILD_FLAGS) ./cmd/heimdalld
go install $(BUILD_FLAGS) ./cmd/heimdallcli

Expand Down
2 changes: 1 addition & 1 deletion bor/beginblocker.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

func BeginBlocker(ctx sdk.Context, _ abci.RequestBeginBlock, k Keeper) {
if ctx.BlockHeight() == int64(helper.SpanOverrideBlockHeight) {
if ctx.BlockHeight() == helper.GetSpanOverrideHeight() {
k.Logger(ctx).Info("overriding span BeginBlocker", "height", ctx.BlockHeight())

j, ok := rest.SPAN_OVERRIDES[helper.GenesisDoc.ChainID]
Expand Down
48 changes: 30 additions & 18 deletions bor/client/rest/query.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
// Package classification HiemdallRest API
// Schemes: http
// BasePath: /
// Version: 0.0.1
// title: Heimdall APIs
// Consumes:
// - application/json
// Host:localhost:1317
// - application/json
//
// Schemes: http
// BasePath: /
// Version: 0.0.1
// title: Heimdall APIs
// Consumes:
// - application/json
// Host:localhost:1317
// - application/json
//
// nolint
//
//swagger:meta
//nolint
package rest

import (
Expand Down Expand Up @@ -65,7 +68,8 @@ type validatorSet struct {
Proposer validator `json:"Proposer"`
}

//It represents the list of spans
// It represents the list of spans
//
//swagger:response borSpanListResponse
type borSpanListResponse struct {
//in:body
Expand All @@ -77,7 +81,8 @@ type borSpanList struct {
Result []span `json:"result"`
}

//It represents the span
// It represents the span
//
//swagger:response borSpanResponse
type borSpanResponse struct {
//in:body
Expand All @@ -89,7 +94,8 @@ type borSpan struct {
Result span `json:"result"`
}

//It represents the bor span parameters
// It represents the bor span parameters
//
//swagger:response borSpanParamsResponse
type borSpanParamsResponse struct {
//in:body
Expand All @@ -111,7 +117,8 @@ type spanParams struct {
ProducerCount int64 `json:"producer_count"`
}

//It represents the next span seed
// It represents the next span seed
//
//swagger:response borNextSpanSeedRespose
type borNextSpanSeedRespose struct {
//in:body
Expand Down Expand Up @@ -188,7 +195,8 @@ type borSpanListParam struct {
// swagger:route GET /bor/span/list bor borSpanList
// It returns the list of Bor Span
// responses:
// 200: borSpanListResponse
//
// 200: borSpanListResponse
func spanListHandlerFn(
cliCtx context.CLIContext,
) http.HandlerFunc {
Expand Down Expand Up @@ -247,7 +255,8 @@ type borSpanById struct {
// swagger:route GET /bor/span/{id} bor borSpanById
// It returns the span based on ID
// responses:
// 200: borSpanResponse
//
// 200: borSpanResponse
func spanHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r)
Expand Down Expand Up @@ -307,7 +316,8 @@ func spanHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
// swagger:route GET /bor/latest-span bor borSpanLatest
// It returns the latest-span
// responses:
// 200: borSpanResponse
//
// 200: borSpanResponse
func latestSpanHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r)
Expand Down Expand Up @@ -358,7 +368,8 @@ type borPrepareNextSpanParam struct {
// swagger:route GET /bor/prepare-next-span bor borPrepareNextSpan
// It returns the prepared next span
// responses:
// 200: borSpanResponse
//
// 200: borSpanResponse
func prepareNextSpanHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r)
Expand Down Expand Up @@ -493,7 +504,8 @@ func prepareNextSpanHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
// swagger:route GET /bor/params bor borSpanParams
// It returns the span parameters
// responses:
// 200: borSpanParamsResponse
//
// 200: borSpanParamsResponse
func paramsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r)
Expand Down
5 changes: 3 additions & 2 deletions bor/client/rest/tx.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//nolint
// nolint
package rest

import (
Expand All @@ -19,7 +19,8 @@ import (
"github.com/maticnetwork/heimdall/types/rest"
)

//It represents Propose Span msg.
// It represents Propose Span msg.
//
//swagger:response borProposeSpanResponse
type borProposeSpanResponse struct {
//in:body
Expand Down
4 changes: 2 additions & 2 deletions bridge/setu/listener/rootchain_selfheal.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ import (
var (
stateSyncedCounter = promauto.NewCounterVec(prometheus.CounterOpts{
Namespace: "self_healing",
Subsystem: helper.NetworkName,
Subsystem: helper.GetConfig().Chain,
Name: "StateSynced",
Help: "The total number of missing StateSynced events",
}, []string{"id", "contract_address", "block_number", "tx_hash"})

stakeUpdateCounter = promauto.NewCounterVec(prometheus.CounterOpts{
Namespace: "self_healing",
Subsystem: helper.NetworkName,
Subsystem: helper.GetConfig().Chain,
Name: "StakeUpdate",
Help: "The total number of missing StakeUpdate events",
}, []string{"id", "nonce", "contract_address", "block_number", "tx_hash"})
Expand Down
2 changes: 1 addition & 1 deletion bridge/setu/processor/clerk.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (cp *ClerkProcessor) sendStateSyncedToHeimdall(eventName string, logBytes s
"blockNumber", vLog.BlockNumber,
)

if util.GetBlockHeight(cp.cliCtx) > helper.SpanOverrideBlockHeight && len(event.Data) > helper.MaxStateSyncSize {
if util.GetBlockHeight(cp.cliCtx) > helper.GetSpanOverrideHeight() && len(event.Data) > helper.MaxStateSyncSize {
cp.Logger.Info(`Data is too large to process, Resetting to ""`, "data", hex.EncodeToString(event.Data))
event.Data = hmTypes.HexToHexBytes("")
} else if len(event.Data) > helper.LegacyMaxStateSyncSize {
Expand Down
10 changes: 5 additions & 5 deletions bridge/setu/processor/slashing.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ func (sp *SlashingProcessor) sendTickToHeimdall(eventBytes string, blockHeight i
}

/*
sendTickToRootchain - create and submit tick tx to rootchain to slashing faulty validators
1. Fetch sigs from heimdall using txHash
2. Fetch slashing info from heimdall via Rest call
3. Verify if this tick tx is already submitted to rootchain using nonce data
4. create tick tx and submit to rootchain
sendTickToRootchain - create and submit tick tx to rootchain to slashing faulty validators
1. Fetch sigs from heimdall using txHash
2. Fetch slashing info from heimdall via Rest call
3. Verify if this tick tx is already submitted to rootchain using nonce data
4. create tick tx and submit to rootchain
*/
func (sp *SlashingProcessor) sendTickToRootchain(eventBytes string, blockHeight int64) (err error) {
sp.Logger.Info("Recevied sendTickToRootchain request", "eventBytes", eventBytes, "blockHeight", blockHeight)
Expand Down
56 changes: 38 additions & 18 deletions checkpoint/client/rest/query.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//nolint
// nolint
package rest

import (
Expand All @@ -22,7 +22,8 @@ import (
hmRest "github.com/maticnetwork/heimdall/types/rest"
)

//It represents the checkpoint parameters
// It represents the checkpoint parameters
//
//swagger:response checkpointParamsResponse
type checkpointParamsResponse struct {
//in:body
Expand All @@ -41,7 +42,8 @@ type params struct {
ChildChainBlockInterval int `json:"child_chain_block_interval"`
}

//It represents the checkpoint
// It represents the checkpoint
//
//swagger:response checkpointResponse
type checkpointResponse struct {
//in:body
Expand All @@ -61,7 +63,8 @@ type checkpoint struct {
Timestamp int64 `json:"timestamp"`
}

//It represents the checkpoint prepare
// It represents the checkpoint prepare
//
//swagger:response checkpointPrepareResponse
type checkpointPrepareResponse struct {
//in:body
Expand All @@ -80,7 +83,8 @@ type prepareCheckpoint struct {
RootHash string `json:"root_hash"`
}

//It represents the checkpoint list
// It represents the checkpoint list
//
//swagger:response checkpointListResponse
type checkpointListResponse struct {
//in:body
Expand All @@ -92,7 +96,8 @@ type checkpointListStructure struct {
Result []checkpoint `json:"result"`
}

//It represents the last-no-ack
// It represents the last-no-ack
//
//swagger:response lastNoAckResponse
type lastNoAckResponse struct {
//in:body
Expand All @@ -108,7 +113,8 @@ type lastNoAck struct {
Result int64 `json:"result"`
}

//It represents the checkpoint count
// It represents the checkpoint count
//
//swagger:response checkpointCountResponse
type checkpointCountResponse struct {
//in:body
Expand All @@ -124,7 +130,8 @@ type checkpointCount struct {
Result int64 `json:"result"`
}

//It represents the overview
// It represents the overview
//
//swagger:response overviewResponse
type overviewResponse struct {
//in:body
Expand Down Expand Up @@ -185,7 +192,9 @@ func registerQueryRoutes(cliCtx context.CLIContext, r *mux.Router) {
// swagger:route GET /checkpoints/params checkpoint checkpointParams
// It returns the checkpoint parameters
// responses:
// 200: checkpointParamsResponse
//
// 200: checkpointParamsResponse
//
// HTTP request handler to query the auth params values
func paramsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
Expand All @@ -210,7 +219,8 @@ func paramsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
// swagger:route GET /checkpoints/buffer checkpoint checkpointBuffer
// It returns the checkpoint buffer
// responses:
// 200: checkpointResponse
//
// 200: checkpointResponse
func checkpointBufferHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r)
Expand All @@ -233,7 +243,8 @@ func checkpointBufferHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
// swagger:route GET /checkpoints/count checkpoint checkpointCount
// It returns the checkpoint counts
// responses:
// 200: checkpointCountResponse
//
// 200: checkpointCountResponse
func checkpointCountHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r)
Expand Down Expand Up @@ -290,7 +301,8 @@ type checkpointPrepareParams struct {
// swagger:route GET /checkpoints/prepare checkpoint checkpointPrepare
// It returns the prepared checkpoint
// responses:
// 200: checkpointPrepareResponse
//
// 200: checkpointPrepareResponse
func prepareCheckpointHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r)
Expand Down Expand Up @@ -406,7 +418,8 @@ type HeaderBlockResult struct {
// swagger:route GET /checkpoints/last-no-ack checkpoint checkpointLastNoAck
// It returns the last no ack
// responses:
// 200: lastNoAckResponse
//
// 200: lastNoAckResponse
func noackHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r)
Expand Down Expand Up @@ -455,7 +468,9 @@ type stateDump struct {
// swagger:route GET /overview checkpoint overview
// It returns the complete overview
// responses:
// 200: overviewResponse
//
// 200: overviewResponse
//
// get all state-dump of heimdall
func overviewHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -560,7 +575,9 @@ func overviewHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
// swagger:route GET /checkpoints/latest checkpoint checkpointLatest
// It returns the last checkpoint from the store
// responses:
// 200: checkpointResponse
//
// 200: checkpointResponse
//
// get last checkpoint from store
func latestCheckpointHandlerFunc(cliCtx context.CLIContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -645,7 +662,7 @@ func latestCheckpointHandlerFunc(cliCtx context.CLIContext) http.HandlerFunc {
}
}

//Temporary Checkpoint struct to store the Checkpoint ID
// Temporary Checkpoint struct to store the Checkpoint ID
type CheckpointWithID struct {
ID uint64 `json:"id"`
Proposer hmTypes.HeimdallAddress `json:"proposer"`
Expand All @@ -668,7 +685,9 @@ type checkpointID struct {
// swagger:route GET /checkpoints/{id} checkpoint checkpointById
// It returns the checkpoint by ID
// responses:
// 200: checkpointResponse
//
// 200: checkpointResponse
//
// get checkpoint by checkppint number from store
func checkpointByNumberHandlerFunc(cliCtx context.CLIContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -747,7 +766,8 @@ type checkpointListParams struct {
// swagger:route GET /checkpoints/list checkpoint checkpointList
// It returns the checkpoints list
// responses:
// 200: checkpointListResponse
//
// 200: checkpointListResponse
func checkpointListhandlerFn(
cliCtx context.CLIContext,
) http.HandlerFunc {
Expand Down
Loading

0 comments on commit 7df0380

Please sign in to comment.