Skip to content

Commit

Permalink
Merge pull request #1062 from maticnetwork/v1.0.0-beta-candidate
Browse files Browse the repository at this point in the history
Merge v1.0.0-beta-candidate to master
  • Loading branch information
VAIBHAVJINDAL3012 committed Sep 20, 2023
2 parents 8e5a165 + 5a89c28 commit fe19017
Show file tree
Hide file tree
Showing 83 changed files with 4,935 additions and 534 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
file: ./cover.out


integration-tests:
e2e-tests:
if: (github.event.action != 'closed' || github.event.pull_request.merged == true)
strategy:
matrix:
Expand Down Expand Up @@ -129,7 +129,7 @@ jobs:
cd matic-cli/devnet/code/contracts
npm run truffle exec scripts/deposit.js -- --network development $(jq -r .root.tokens.MaticToken contractAddresses.json) 100000000000000000000
cd -
timeout 20m bash heimdall/integration-tests/smoke_test.sh
timeout 60m bash heimdall/integration-tests/smoke_test.sh
- name: Upload logs
if: always()
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/packager.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ on:

jobs:
build:
runs-on:
group: ubuntu-runners
labels: 18.04RunnerT2Large
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ jobs:
days-before-pr-stale: 21
days-before-issue-close: 14
days-before-pr-close: 14
exempt-draft-pr: true

9 changes: 9 additions & 0 deletions .synk
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.25.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
'SNYK-GOLANG-GOLANGORGXNETHTTP2-3160322':
- '*':
reason: 'grpc working on a release to fix the issue'
created: 2022-12-12T06:50:00.000Z
patch: {}
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,19 @@ release:
-w /go/src/$(PACKAGE_NAME) \
goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
--rm-dist --skip-validate

.PHONY: help
help:
@echo "Available targets:"
@echo " clean - Removes the build directory."
@echo " tests - Runs Go tests on specific packages."
@echo " build - Compiles the Heimdall binaries."
@echo " install - Installs the Heimdall binaries."
@echo " contracts - Generates Go bindings for Ethereum contracts."
@echo " build-arm - Compiles the Heimdall binaries for ARM64 architecture."
@echo " lint - Runs the GolangCI-Lint tool on the codebase."
@echo " build-docker - Builds a Docker image for the latest Git tag."
@echo " push-docker - Pushes the Docker image for the latest Git tag."
@echo " build-docker-develop- Builds a Docker image for the development branch."
@echo " release-dry-run - Performs a dry run of the release process."
@echo " release - Executes the actual release process."
8 changes: 6 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ func NewHeimdallApp(logger log.Logger, db dbm.DB, baseAppOptions ...func(*bam.Ba
app.subspaces[borTypes.ModuleName] = app.ParamsKeeper.Subspace(borTypes.DefaultParamspace)
app.subspaces[clerkTypes.ModuleName] = app.ParamsKeeper.Subspace(clerkTypes.DefaultParamspace)
app.subspaces[topupTypes.ModuleName] = app.ParamsKeeper.Subspace(topupTypes.DefaultParamspace)

//
// Contract caller
//
Expand Down Expand Up @@ -597,8 +598,11 @@ func (app *HeimdallApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) ab
return abci.ResponseEndBlock{}
}

// increment proposer priority
currentValidatorSet.IncrementProposerPriority(1)
//Hardfork to remove the rotation of validator list on stake update
if ctx.BlockHeight() < helper.GetAalborgHardForkHeight() {
// increment proposer priority
currentValidatorSet.IncrementProposerPriority(1)
}

// validator set change
logger.Debug("[ENDBLOCK] Updated current validator set", "proposer", currentValidatorSet.GetProposer())
Expand Down
2 changes: 1 addition & 1 deletion app/side_tx_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func (app *HeimdallApp) runTx(ctx sdk.Context, txBytes []byte, sideTxResult abci
return
}

// / runMsgs iterates through all the messages and executes them.
// runMsgs iterates through all the messages and executes them.
func (app *HeimdallApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, sideTxResult abci.SideTxResultType) sdk.Result {
data := make([]byte, 0, len(msgs))

Expand Down
2 changes: 1 addition & 1 deletion app/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type App interface {
Name() string

// The application types codec.
// NOTE: This shoult be sealed before being returned.
// NOTE: This should not be sealed before being returned.
Codec() *codec.Codec

// Application updates every begin block.
Expand Down
7 changes: 7 additions & 0 deletions auth/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

authTypes "github.com/maticnetwork/heimdall/auth/types"
"github.com/maticnetwork/heimdall/chainmanager"
checkpointTypes "github.com/maticnetwork/heimdall/checkpoint/types"
"github.com/maticnetwork/heimdall/helper"
"github.com/maticnetwork/heimdall/types"
)
Expand Down Expand Up @@ -83,6 +84,12 @@ func NewAnteHandler(
return newCtx, sdk.ErrInternal("tx must be StdTx").Result(), true
}

//Check whether the chain has reached the hard fork length to execute milestone msgs
if ctx.BlockHeight() < helper.GetAalborgHardForkHeight() && (stdTx.Msg.Type() == checkpointTypes.EventTypeMilestone || stdTx.Msg.Type() == checkpointTypes.EventTypeMilestoneTimeout) {
newCtx = SetGasMeter(simulate, ctx, 0)
return newCtx, sdk.ErrTxDecode("error decoding transaction").Result(), true
}

// get account params
params := ak.GetParams(ctx)

Expand Down
75 changes: 75 additions & 0 deletions auth/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,53 @@ func (suite *AnteTestSuite) TestFees() {
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInsufficientFunds)
}

func (suite *AnteTestSuite) TestMilestoneHardFork() {
t, happ, ctx, anteHandler := suite.T(), suite.app, suite.ctx, suite.anteHandler
ctx = ctx.WithBlockHeight(1)

// keys and addresses
priv1, _, addr1 := sdkAuth.KeyTestPubAddr()

// set the accounts
acc1 := happ.AccountKeeper.NewAccountWithAddress(ctx, hmTypes.AccAddressToHeimdallAddress(addr1))
amt1, _ := sdk.NewIntFromString(authTypes.DefaultTxFees + "0")
err := acc1.SetCoins(sdk.NewCoins(sdk.NewCoin(authTypes.FeeToken, amt1)))
require.NoError(t, err)
happ.AccountKeeper.SetAccount(ctx, acc1)
acc1 = happ.AccountKeeper.GetAccount(ctx, acc1.GetAddress()) // get stored account

var tx sdk.Tx

// checkpoint msg
msg := TestMilestoneMsg{*sdkAuth.NewTestMsg(addr1)}
msgTimeout := TestMilestoneTimeoutMsg{*sdkAuth.NewTestMsg(addr1)}

//Setting block height to -1 t0 check for the hard fork
ctx = ctx.WithBlockHeight(int64(-1))
// test good tx from one signer
tx = types.NewTestTx(ctx, sdk.Msg(&msgTimeout), priv1, acc1.GetAccountNumber(), uint64(0))
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeTxDecode)

acc1 = happ.AccountKeeper.GetAccount(ctx, acc1.GetAddress())
require.Equal(t, amt1, (acc1.GetCoins()).AmountOf(authTypes.FeeToken))

ctx = ctx.WithBlockHeight(int64(1))

tx = types.NewTestTx(ctx, sdk.Msg(&msg), priv1, acc1.GetAccountNumber(), uint64(0))
checkValidTx(t, anteHandler, ctx, tx, false)

acc1 = happ.AccountKeeper.GetAccount(ctx, acc1.GetAddress())
require.NotEqual(t, amt1, (acc1.GetCoins()).AmountOf(authTypes.FeeToken))

amt1 = (acc1.GetCoins()).AmountOf(authTypes.FeeToken)

tx = types.NewTestTx(ctx, sdk.Msg(&msgTimeout), priv1, acc1.GetAccountNumber(), uint64(1))
checkValidTx(t, anteHandler, ctx, tx, false)

acc1 = happ.AccountKeeper.GetAccount(ctx, acc1.GetAddress())
require.NotEqual(t, amt1, (acc1.GetCoins()).AmountOf(authTypes.FeeToken))
}

//
// utils
//
Expand Down Expand Up @@ -458,3 +505,31 @@ type TestCheckpointMsg struct {

func (msg *TestCheckpointMsg) Route() string { return testCheckpointMsgVal }
func (msg *TestCheckpointMsg) Type() string { return testCheckpointMsgVal }

//
// Test checkpoint
//

const testMilestoneMsgVal = "milestone"

var _ sdk.Msg = (*TestMilestoneMsg)(nil)

// msg type for testing
type TestMilestoneMsg struct {
sdk.TestMsg
}

func (msg *TestMilestoneMsg) Route() string { return testMilestoneMsgVal }
func (msg *TestMilestoneMsg) Type() string { return testMilestoneMsgVal }

const testMilestoneTimeoutMsgVal = "milestone-timeout"

var _ sdk.Msg = (*TestMilestoneTimeoutMsg)(nil)

// msg type for testing
type TestMilestoneTimeoutMsg struct {
sdk.TestMsg
}

func (msg *TestMilestoneTimeoutMsg) Route() string { return testMilestoneTimeoutMsgVal }
func (msg *TestMilestoneTimeoutMsg) Type() string { return testMilestoneTimeoutMsgVal }
7 changes: 7 additions & 0 deletions bor/beginblocker.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ import (
hmTypes "github.com/maticnetwork/heimdall/types"
)

// ResponseWithHeight defines a response object type that wraps an original
// response with a height.
type ResponseWithHeight struct {
Height string `json:"height"`
Result jsoniter.RawMessage `json:"result"`
}

func BeginBlocker(ctx sdk.Context, _ abci.RequestBeginBlock, k Keeper) {
if ctx.BlockHeight() == helper.GetSpanOverrideHeight() {
k.Logger(ctx).Info("overriding span BeginBlocker", "height", ctx.BlockHeight())
Expand Down
8 changes: 8 additions & 0 deletions bor/client/rest/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,14 @@ func paramsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
}
}

// ResponseWithHeight defines a response object type that wraps an original
// response with a height.
// TODO:Link it with bor
type ResponseWithHeight struct {
Height string `json:"height"`
Result jsoniter.RawMessage `json:"result"`
}

func loadSpanOverrides() {
spanOverrides = map[uint64]*HeimdallSpanResultWithHeight{}

Expand Down
3 changes: 3 additions & 0 deletions bridge/setu/listener/rootchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ type RootChainListener struct {

stakingInfoAbi *abi.ABI
stateSenderAbi *abi.ABI

// For self-heal, Will be only initialised if sub_graph_url is provided
subGraphClient *subGraphClient
}

const (
Expand Down

0 comments on commit fe19017

Please sign in to comment.