Skip to content

Commit

Permalink
Merge pull request #1167 from maticnetwork/v1.0.7-beta-candidate
Browse files Browse the repository at this point in the history
Merge v1.0.7 to master
  • Loading branch information
marcello33 authored Jun 5, 2024
2 parents f42d25c + 521c1c6 commit b0c4a07
Show file tree
Hide file tree
Showing 60 changed files with 728 additions and 641 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
- uses: actions/checkout@v3

- name: Install Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: 1.20.x
go-version: 1.22.x

- name: "Build binaries"
run: make build
Expand All @@ -33,9 +33,9 @@ jobs:
- uses: actions/checkout@v3

- name: Install Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: 1.20.x
go-version: 1.22.x

- name: "Run linter"
run: make lint
Expand All @@ -47,9 +47,9 @@ jobs:
- uses: actions/checkout@v3

- name: Install Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: 1.20.x
go-version: 1.22.x

- name: "Run tests"
run: make tests
Expand All @@ -71,9 +71,9 @@ jobs:
with:
path: heimdall

- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: 1.20.x
go-version: 1.22.x

- name: Checkout matic-cli
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
uses: actions/checkout@v3

- name: Install Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: go.mod

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/govuln.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
env:
DEBUG: "true"
with:
go-version: 1.21
go-version: 1.22
package: ./...
github-token: ${{ secrets.GITHUB_TOKEN }}
fail-on-vuln: true
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/packager.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@master
with:
go-version: 1.20.x
go-version: 1.22.x
- name: Adding TAG to ENV
run: echo "GIT_TAG=`echo $(git describe --tags --abbrev=0)`" >> $GITHUB_ENV

Expand Down Expand Up @@ -95,7 +95,7 @@ jobs:
env:
ARCH: amd64
NODE: sentry
NETWORK: amoy
NETWORK: amoy
- name: Copying over the postinst file for for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/postinst.profile.amoy packaging/deb/heimdalld-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/postinst
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@master
with:
go-version: 1.20.x
go-version: 1.22.x

- name: Prepare
id: prepare
Expand Down
3 changes: 1 addition & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file configures github.com/golangci/golangci-lint.

run:
go: '1.20'
go: '1.22'
timeout: 20m
tests: true
# default is true. Enables skipping of directories:
Expand Down Expand Up @@ -52,7 +52,6 @@ linters:
- tparallel
- unconvert
- unparam
- wsl
#- errorlint causes stack overflow. TODO: recheck after each golangci update

linters-settings:
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ build-arm: clean
LINT_COMMAND := $(shell command -v golangci-lint 2> /dev/null)
lint:
ifndef LINT_COMMAND
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.3
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.56.2
endif
golangci-lint run --config ./.golangci.yml

Expand All @@ -82,7 +82,7 @@ build-docker-develop:
.PHONY: contracts build

PACKAGE_NAME := github.com/maticnetwork/heimdall
GOLANG_CROSS_VERSION ?= v1.20.5
GOLANG_CROSS_VERSION ?= v1.22.1

.PHONY: release-dry-run
release-dry-run:
Expand Down
Binary file added audit/audit-feature-milestones.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion bank/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type HandlerTestSuite struct {
contractCaller mocks.IContractCaller
}

// SetupTest setup all necessary things for querier tesing
// SetupTest setup all necessary things for querier testing
func (suite *HandlerTestSuite) SetupTest() {
suite.app, suite.ctx = createTestApp(false)

Expand Down
6 changes: 3 additions & 3 deletions bor/client/rest/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ type spanParams struct {

// It represents the next span seed
//
//swagger:response borNextSpanSeedRespose
type borNextSpanSeedRespose struct {
//swagger:response borNextSpanSeedResponse
type borNextSpanSeedResponse struct {
//in:body
Output spanSeed `json:"output"`
}
Expand All @@ -142,7 +142,7 @@ func registerQueryRoutes(cliCtx context.CLIContext, r *mux.Router) {
// swagger:route GET /bor/next-span-seed bor borNextSpanSeed
// It returns the seed for the next span
// responses:
// 200: borNextSpanSeedRespose
// 200: borNextSpanSeedResponse

func fetchNextSpanSeedHandlerFn(
cliCtx context.CLIContext,
Expand Down
6 changes: 3 additions & 3 deletions bridge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Bridge module is responsible for listening to multiple chains and processing the

In order to process the events emitted by the chains, bridge module uses `processor` component, which is responsible for processing the events emitted by the chains. For example `processor/clerk.go` is responsible for processing the events related to clerk module, `processor/staking.go` is responsible for processing the events related to staking module and so on.

Other components of the bridge module includes `queue` which is used for queuing the messages between listner and processors, `broadcaster` which is responsible for broadcasting the messages to the heimdall chain.
Other components of the bridge module includes `queue` which is used for queuing the messages between listener and processors, `broadcaster` which is responsible for broadcasting the messages to the heimdall chain.

Polygon PoS bridge provides a bridging mechanism that is near-instant, low-cost, and quite flexible.

Expand All @@ -25,9 +25,9 @@ There is no change to the circulating supply of your token when it crosses the b

## Listener

The bridge module has a `BaseListner` which is extended by `RootChainListener`, `MaticChainListener` and `HeimdallListener`. It has all the methods required to start polling, listening to incoming headers(blocks) and stopping the process if required. All the 3 listneres uses these properties with their individual implementations on how to handle the incoming header once received.
The bridge module has a `BaseListener` which is extended by `RootChainListener`, `MaticChainListener` and `HeimdallListener`. It has all the methods required to start polling, listening to incoming headers(blocks) and stopping the process if required. All the 3 listneres uses these properties with their individual implementations on how to handle the incoming header once received.

For example in `RootChainListner` the incoming header is used to determine the current height of root chain and calculate the `from` and `to` block numbers using which the events are fetched from the root chain. These events are then sent to `handleLog` where based on their event signature they are added to queue as tasks for further processing by their respective processors.
For example in `RootChainListener` the incoming header is used to determine the current height of root chain and calculate the `from` and `to` block numbers using which the events are fetched from the root chain. These events are then sent to `handleLog` where based on their event signature they are added to queue as tasks for further processing by their respective processors.

## Processor

Expand Down
4 changes: 2 additions & 2 deletions bridge/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,13 @@ func GetStartCmd() *cobra.Command {
logger.Error("GetStartCmd | BindPFlag | logLevel", "Error", err)
}

startCmd.Flags().Bool("all", false, "start all bridge services")
startCmd.Flags().Bool("all", false, "Start all bridge services")

if err := viper.BindPFlag("all", startCmd.Flags().Lookup("all")); err != nil {
logger.Error("GetStartCmd | BindPFlag | all", "Error", err)
}

startCmd.Flags().StringSlice("only", []string{}, "comma separated bridge services to start")
startCmd.Flags().StringSlice("only", []string{}, "Comma separated bridge services to start")

if err := viper.BindPFlag("only", startCmd.Flags().Lookup("only")); err != nil {
logger.Error("GetStartCmd | BindPFlag | only", "Error", err)
Expand Down
2 changes: 1 addition & 1 deletion bridge/setu/listener/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
httpClient "github.com/tendermint/tendermint/rpc/client"
)

// Listener defines a block header listerner for Rootchain, Maticchain, Heimdall
// Listener defines a block header listener for Rootchain, Maticchain, Heimdall
type Listener interface {
Start() error

Expand Down
2 changes: 1 addition & 1 deletion bridge/setu/listener/heimdall.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (hl *HeimdallListener) Start() error {
headerCtx, cancelHeaderProcess := context.WithCancel(context.Background())
hl.cancelHeaderProcess = cancelHeaderProcess

// Heimdall pollIntervall = (minimal pollInterval of rootchain and matichain)
// Heimdall pollInterval = (minimal pollInterval of rootchain and matichain)
pollInterval := helper.GetConfig().SyncerPollInterval
if helper.GetConfig().CheckpointerPollInterval < helper.GetConfig().SyncerPollInterval {
pollInterval = helper.GetConfig().CheckpointerPollInterval
Expand Down
2 changes: 1 addition & 1 deletion bridge/setu/processor/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/maticnetwork/heimdall/helper"
)

// Processor defines a block header listerner for Rootchain, Maticchain, Heimdall
// Processor defines a block header listener for Rootchain, Maticchain, Heimdall
type Processor interface {
Start() error

Expand Down
6 changes: 3 additions & 3 deletions bridge/setu/processor/checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -692,16 +692,16 @@ func (cp *CheckpointProcessor) shouldSendCheckpoint(checkpointContext *Checkpoin

shouldSend := false
// validate if checkpoint needs to be pushed to rootchain and submit
cp.Logger.Info("Validating if checkpoint needs to be pushed", "commitedLastBlock", currentChildBlock, "startBlock", start)
cp.Logger.Info("Validating if checkpoint needs to be pushed", "committedLastBlock", currentChildBlock, "startBlock", start)
// check if we need to send checkpoint or not
if ((currentChildBlock + 1) == start) || (currentChildBlock == 0 && start == 0) {
cp.Logger.Info("Checkpoint Valid", "startBlock", start)

shouldSend = true
} else if currentChildBlock > start {
cp.Logger.Info("Start block does not match, checkpoint already sent", "commitedLastBlock", currentChildBlock, "startBlock", start)
cp.Logger.Info("Start block does not match, checkpoint already sent", "committedLastBlock", currentChildBlock, "startBlock", start)
} else if currentChildBlock > end {
cp.Logger.Info("Checkpoint already sent", "commitedLastBlock", currentChildBlock, "startBlock", start)
cp.Logger.Info("Checkpoint already sent", "committedLastBlock", currentChildBlock, "startBlock", start)
} else {
cp.Logger.Info("No need to send checkpoint")
}
Expand Down
2 changes: 1 addition & 1 deletion bridge/setu/processor/milestone.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func (mp *MilestoneProcessor) checkAndProposeMilestoneTimeout() (err error) {
return nil
}

// sendMilestoneTimoutToHeimdall - creates milestone-timeout msg and broadcasts to heimdall
// sendMilestoneTimeoutToHeimdall - creates milestone-timeout msg and broadcasts to heimdall
func (mp *MilestoneProcessor) createAndSendMilestoneTimeoutToHeimdall() error {
mp.Logger.Debug("Initiating milestone timeout to Heimdall")

Expand Down
2 changes: 1 addition & 1 deletion bridge/setu/processor/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func NewProcessorService(
}

if len(processorService.processors) == 0 {
panic("No processors selected. Use --all or --only <coma-seprated processors>")
panic("No processors selected. Use --all or --only <coma-separated processors>")
}

return processorService
Expand Down
2 changes: 1 addition & 1 deletion chainmanager/client/rest/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type chainManager struct {
}

type ContractAddresses struct {
BorChainId string `josn:"bor_chain_id"`
BorChainId string `json:"bor_chain_id"`
MaticChainAddress string `json:"matic_token_address"`
StalkingManagerAddress string `json:"staking_manager_address"`
SlashManagerAddress string `json:"slash_manager_address"`
Expand Down
2 changes: 1 addition & 1 deletion chainmanager/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type QuerierTestSuite struct {
querier sdk.Querier
}

// SetupTest setup all necessary things for querier tesing
// SetupTest setup all necessary things for querier testing
func (suite *QuerierTestSuite) SetupTest() {
suite.app, suite.ctx = createTestApp(false)
suite.querier = chainmanager.NewQuerier(suite.app.ChainKeeper)
Expand Down
4 changes: 2 additions & 2 deletions checkpoint/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func handleMsgCheckpointAck(ctx sdk.Context, msg types.MsgCheckpointAck, k Keepe
"endExpected", headerBlock.EndBlock,
"endReceived", msg.StartBlock,
"rootExpected", headerBlock.RootHash.String(),
"rootRecieved", msg.RootHash.String(),
"rootReceived", msg.RootHash.String(),
)

return common.ErrBadAck(k.Codespace()).Result()
Expand Down Expand Up @@ -264,7 +264,7 @@ func handleMsgCheckpointNoAck(ctx sdk.Context, msg types.MsgCheckpointNoAck, k K
return common.ErrInvalidNoACK(k.Codespace()).Result()
}

//Hardfork to check the validaty of the NoAckProposer
//Hardfork to check the validity of the NoAckProposer
if ctx.BlockHeight() >= helper.GetAalborgHardForkHeight() {
timeDiff := currentTime.Sub(lastCheckpointTime)

Expand Down
6 changes: 4 additions & 2 deletions checkpoint/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import (
hmTypes "github.com/maticnetwork/heimdall/types"
)

const maxCheckpointListLimit = 10_000 // a checkpoint is ~100 bytes => can fit 10k in 1 MB response

var (
DefaultValue = []byte{0x01} // Value to store in CacheCheckpoint and CacheCheckpointACK & ValidatorSetChange Flag

Expand Down Expand Up @@ -145,8 +147,8 @@ func (k *Keeper) GetCheckpointList(ctx sdk.Context, page uint64, limit uint64) (
var checkpoints []hmTypes.Checkpoint

// have max limit
if limit > 20 {
limit = 20
if limit > maxCheckpointListLimit {
limit = maxCheckpointListLimit
}

// get paginated iterator
Expand Down
2 changes: 1 addition & 1 deletion checkpoint/keeper_milestone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func (suite *KeeperTestSuite) TestLastNoAckMilestone() {
require.Equal(t, val, milestoneID)
}

func (suite *KeeperTestSuite) TestGetMilestoneTimout() {
func (suite *KeeperTestSuite) TestGetMilestoneTimeout() {
t, app, ctx := suite.T(), suite.app, suite.ctx
keeper := app.CheckpointKeeper

Expand Down
2 changes: 1 addition & 1 deletion checkpoint/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type QuerierTestSuite struct {
contractCaller mocks.IContractCaller
}

// SetupTest setup all necessary things for querier tesing
// SetupTest setup all necessary things for querier testing
func (suite *QuerierTestSuite) SetupTest() {
suite.app, suite.ctx, suite.cliCtx = createTestApp(false)
suite.contractCaller = mocks.IContractCaller{}
Expand Down
2 changes: 1 addition & 1 deletion checkpoint/side_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ func PostHandleMsgCheckpointAck(ctx sdk.Context, k Keeper, msg types.MsgCheckpoi
"endExpected", checkpointObj.EndBlock,
"endReceived", msg.StartBlock,
"rootExpected", checkpointObj.RootHash.String(),
"rootRecieved", msg.RootHash.String(),
"rootReceived", msg.RootHash.String(),
)

return common.ErrBadAck(k.Codespace()).Result()
Expand Down
2 changes: 1 addition & 1 deletion checkpoint/simulation/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

// GenRandCheckpoint return headers
func GenRandCheckpoint(start uint64, headerSize uint64, maxCheckpointLenght uint64) (headerBlock types.Checkpoint, err error) {
func GenRandCheckpoint(start uint64, headerSize uint64, maxCheckpointLength uint64) (headerBlock types.Checkpoint, err error) {
end := start + headerSize
borChainID := "1234"
rootHash := types.HexToHeimdallHash("123")
Expand Down
2 changes: 1 addition & 1 deletion clerk/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type QuerierTestSuite struct {
contractCaller mocks.IContractCaller
}

// SetupTest setup all necessary things for querier tesing
// SetupTest setup all necessary things for querier testing
func (suite *QuerierTestSuite) SetupTest() {
suite.app, suite.ctx = createTestApp(false)
suite.contractCaller = mocks.IContractCaller{}
Expand Down
Loading

0 comments on commit b0c4a07

Please sign in to comment.