Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge v1.1.0 beta candidate #1229

Merged
merged 69 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
5eaf784
save
anshalshukla Jun 21, 2024
a331222
save
anshalshukla Jun 24, 2024
a2e77bf
save
anshalshukla Jun 25, 2024
2938c32
save
anshalshukla Jun 25, 2024
fe2d715
save
anshalshukla Jun 25, 2024
72a9f21
save
anshalshukla Jun 25, 2024
3efe2b4
update: polyproto version
anshalshukla Sep 9, 2024
f8d873a
Update README.md
nnsW3 Oct 12, 2024
afdf820
Update README.md
nnsW3 Oct 12, 2024
bb9f904
Update README.md
nnsW3 Oct 12, 2024
2c9d511
Update README.md
nnsW3 Oct 12, 2024
90594e1
Update README.md
nnsW3 Oct 16, 2024
ce47a51
Merge pull request #1194 from nnsW3/docs-fix-spelling-issues
marcello33 Oct 16, 2024
db44f10
heimdallcli: Genesis export command optimization
avalkov Oct 15, 2024
f518a12
Merge pull request #1195 from maticnetwork/avalkov/Optimize-genesis-e…
avalkov Oct 29, 2024
4d660e3
chg: some sec fixes
marcello33 Oct 31, 2024
62cf332
chg: resolve dep cycle
marcello33 Oct 31, 2024
9994ce2
chg: sort imports
marcello33 Oct 31, 2024
331cec2
Merge pull request #1202 from maticnetwork/mardizzone/fixes
marcello33 Oct 31, 2024
93ca5a1
add: logs
marcello33 Nov 7, 2024
33842bd
chg: fix log
marcello33 Nov 7, 2024
0294a86
chg: fix logs and print blockNum
marcello33 Nov 7, 2024
b54d4e6
chg: fix NPEs
marcello33 Nov 7, 2024
dd5f06b
chg: add logs
marcello33 Nov 8, 2024
b450880
chg: add log
marcello33 Nov 8, 2024
35fd8f7
chg: fix functions' names
marcello33 Nov 8, 2024
58af0e2
chg: logs
marcello33 Nov 8, 2024
28fa236
add: some fixes
marcello33 Nov 8, 2024
ea727c8
add: debug log
marcello33 Nov 8, 2024
b02ebd8
add: debug log
marcello33 Nov 8, 2024
0a7a14e
chg: remove redundant logs
marcello33 Nov 8, 2024
ede8c7f
chg: sort imports
marcello33 Nov 8, 2024
e8352fd
Merge branch 'develop' of https://github.com/maticnetwork/heimdall in…
marcello33 Nov 8, 2024
075f5ce
add: deps
marcello33 Nov 8, 2024
b82ffe8
fix: lint
marcello33 Nov 8, 2024
9fbae2f
fix: lint
marcello33 Nov 8, 2024
da71fa1
fix: lint
marcello33 Nov 8, 2024
44f5c18
fix: lint
marcello33 Nov 8, 2024
da8919d
fix: address negative blockNumber
marcello33 Nov 11, 2024
ec7ac02
Merge pull request #1203 from maticnetwork/bor-grpc
marcello33 Nov 13, 2024
016f79a
chg: handle edge cases with string blockNumber
marcello33 Nov 13, 2024
c84b35b
chg: sort imports
marcello33 Nov 13, 2024
8c95b0e
cgh: fix rpc blockNumber and bash warnings
marcello33 Nov 13, 2024
b404196
cgh: sort imports
marcello33 Nov 13, 2024
6b147ec
cgh: remove unused fn
marcello33 Nov 13, 2024
dcc0097
chg: use decimals over hex and fix overflow
marcello33 Nov 13, 2024
474c4ad
chg: remove test
marcello33 Nov 13, 2024
e5c1066
chg: parallel tests
marcello33 Nov 13, 2024
0a52b7d
chg: parallel subtests
marcello33 Nov 13, 2024
57e6560
chg: fix lint
marcello33 Nov 13, 2024
8b52903
chg: fix LatestBlockNumber case
marcello33 Nov 13, 2024
cab287e
chg: fix negative blockNums
marcello33 Nov 13, 2024
1f535e5
chg: try blocks hex ecnoding
marcello33 Nov 14, 2024
d90fa7a
Enhance GetBridgeDBInstance: Add Error Handling for LevelDB Initializ…
vinayak0035 Nov 14, 2024
94f9809
chg: fix lint
marcello33 Nov 14, 2024
4cdde38
chg: bump polyproto
marcello33 Nov 14, 2024
ebeeb9e
Merge pull request #1204 from maticnetwork/mardizzone/grpc
marcello33 Nov 14, 2024
f2455ef
chg: DefaultBorGRPCUrl
marcello33 Nov 14, 2024
9f9a1b4
Merge pull request #1205 from maticnetwork/mardizzone/def_bor_grpc_url
marcello33 Nov 14, 2024
f0b7beb
chg: fix tests due to grpc hex enc/dec
marcello33 Nov 15, 2024
7ab304c
Merge pull request #1206 from maticnetwork/mardizzone/fix_grpc_test
marcello33 Nov 15, 2024
f6c0261
Change parameters for bor producer selection algorithm (#1208)
Raneet10 Nov 27, 2024
3d61143
V1.1.0 new span msg (#1213)
avalkov Dec 11, 2024
17d8d26
Fixes for profiles, removing some unecessary postinst file, update to…
djpolygon Dec 12, 2024
628f019
Merge pull request #1216 from maticnetwork/djpolygon/packaging_cleanu…
marcello33 Dec 18, 2024
58bd98e
Merge v1.1.0-new-span-msg (#1226)
Raneet10 Jan 16, 2025
3cde3f4
Tx decoder restrict new msgs before HF
avalkov Jan 22, 2025
be2fc35
Fixed type check in tx decoder
avalkov Jan 22, 2025
32e8586
set jorvik and danelaw HF height for mainnet
Raneet10 Jan 29, 2025
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
6 changes: 3 additions & 3 deletions .github/workflows/amoy_deb_profiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,19 @@ jobs:
run: cp -rp packaging/templates/package_scripts/preinst.${{ env.NETWORK }} packaging/deb/heimdall-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/preinst
env:
ARCH: all
NODE: sentry
NODE: validator
NETWORK: amoy
- name: Copying config for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/config/${{ env.NETWORK }}/heimdall-config.toml packaging/deb/heimdall-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/var/lib/heimdall/config/heimdall-config.toml
env:
ARCH: all
NODE: sentry
NODE: validator
NETWORK: amoy
- name: Copying config for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/config/${{ env.NETWORK }}/config.toml packaging/deb/heimdall-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/var/lib/heimdall/config/config.toml
env:
ARCH: all
NODE: sentry
NODE: validator
NETWORK: amoy
- name: Copying systemd file for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/systemd/heimdalld-amoy-validator.service packaging/deb/heimdall-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/lib/systemd/system/heimdalld.service
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/mainnet_deb_profiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,19 @@ jobs:
run: cp -rp packaging/templates/package_scripts/preinst.${{ env.NETWORK }} packaging/deb/heimdall-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/preinst
env:
ARCH: all
NODE: sentry
NODE: validator
NETWORK: mainnet
- name: Copying config for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/config/${{ env.NETWORK }}/heimdall-config.toml packaging/deb/heimdall-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/var/lib/heimdall/config/heimdall-config.toml
env:
ARCH: all
NODE: sentry
NODE: validator
NETWORK: mainnet
- name: Copying config for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/config/${{ env.NETWORK }}/config.toml packaging/deb/heimdall-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/var/lib/heimdall/config/config.toml
env:
ARCH: all
NODE: sentry
NODE: validator
NETWORK: mainnet
- name: Copying the postrm for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/postrm.profile packaging/deb/heimdall-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/postrm
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ clean:
tests:
# go test -v ./...

go test -v ./app/ ./auth/ ./clerk/ ./sidechannel/ ./bank/ ./chainmanager/ ./topup/ ./checkpoint/ ./staking/ -cover -coverprofile=cover.out -parallel 1
go test -v ./app/ ./auth/ ./clerk/ ./sidechannel/ ./bank/ ./chainmanager/ ./topup/ ./checkpoint/ ./staking/ ./gov/ -cover -coverprofile=cover.out -parallel 1

# make build
build: clean
Expand Down
10 changes: 7 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,12 @@ func NewHeimdallApp(logger log.Logger, db dbm.DB, baseAppOptions ...func(*bam.Ba
config := sdk.GetConfig()
config.Seal()

var app *HeimdallApp

// base app
bApp := bam.NewBaseApp(AppName, logger, db, authTypes.DefaultTxDecoder(cdc), baseAppOptions...)
bApp := bam.NewBaseApp(AppName, logger, db, authTypes.DefaultMainTxDecoder(cdc, func() int64 {
return app.LastBlockHeight()
}, helper.GetDanelawHeight, helper.GetJorvikHeight), baseAppOptions...)
bApp.SetCommitMultiStoreTracer(nil)
bApp.SetAppVersion(version.Version)

Expand All @@ -217,7 +221,7 @@ func NewHeimdallApp(logger log.Logger, db dbm.DB, baseAppOptions ...func(*bam.Ba
tkeys := sdk.NewTransientStoreKeys(paramsTypes.TStoreKey)

// create heimdall app
var app = &HeimdallApp{
app = &HeimdallApp{
cdc: cdc,
BaseApp: bApp,
keys: keys,
Expand Down Expand Up @@ -357,7 +361,7 @@ func NewHeimdallApp(logger log.Logger, db dbm.DB, baseAppOptions ...func(*bam.Ba
common.DefaultCodespace,
app.ChainKeeper,
app.StakingKeeper,
app.caller,
&app.caller,
)

app.ClerkKeeper = clerk.NewKeeper(
Expand Down
4 changes: 2 additions & 2 deletions auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ Fees serve two purposes for an operator of the network.

Fees limit the growth of the state stored by every full node and allow for general purpose censorship of transactions of little economic value. Fees are best suited as an anti-spam mechanism where validators are disinterested in the use of the network and identities of users.

Since Heimdall doesn't support custom contract or code for any transaction, it uses fixed cost transactions. For fixed cost transactions, the validator can top up their accounts on the Ethereum chain and get tokens on Heimdall using the Topup module.
Since Heimdall doesn't support custom contracts or code for any transaction, it uses fixed cost transactions. For fixed cost transactions, the validator can top up their accounts on the Ethereum chain and get tokens on Heimdall using the Topup module.

### Types

Besides accounts (specified in State), the types exposed by the auth module are StdSignature, the combination of an optional public key and a cryptographic signature as a byte array, StdTx, a struct that implements the sdk.Tx interface using StdSignature, and StdSignDoc, a replay-prevention structure for StdTx which transaction senders must sign over.

#### StdSignature

A StdSignature is the types of a byte array.
A StdSignature is the type of a byte array.
```
// StdSignature represents a sig
type StdSignature []byte
Expand Down
35 changes: 35 additions & 0 deletions auth/types/stdtx.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,41 @@ func (fee StdFee) GasPrices() sdk.DecCoins {
// Decoders
//

// DefaultMainTxDecoder logic for standard transaction decoding
func DefaultMainTxDecoder(cdc *codec.Codec, lastBlockHeight func() int64, getDanelawHeight func() int64, getJorvikHeight func() int64) sdk.TxDecoder {
return func(txBytes []byte) (sdk.Tx, sdk.Error) {
var tx = StdTx{}

if len(txBytes) == 0 {
return nil, sdk.ErrTxDecode("txBytes are empty")
}

currentHeight := lastBlockHeight() + 1
if currentHeight < getDanelawHeight() && getDanelawHeight() == getJorvikHeight() {
var hftx = StdTx{}
if err := cdc.UnmarshalBinaryLengthPrefixed(txBytes, &hftx); err != nil {
return nil, sdk.ErrTxDecode("error decoding transaction").TraceSDK(err.Error())
}

msgs := hftx.GetMsgs()
for _, msg := range msgs {
if msg.Route() == "bor" && msg.Type() == "propose-span-v2" {
return nil, sdk.ErrTxDecode("error decoding transaction")
}
}
}

// StdTx.Msg is an interface. The concrete types
// are registered by MakeTxCodec
err := cdc.UnmarshalBinaryLengthPrefixed(txBytes, &tx)
if err != nil {
return nil, sdk.ErrTxDecode("error decoding transaction").TraceSDK(err.Error())
}

return tx, nil
}
}

// DefaultTxDecoder logic for standard transaction decoding
func DefaultTxDecoder(cdc *codec.Codec) sdk.TxDecoder {
return func(txBytes []byte) (sdk.Tx, sdk.Error) {
Expand Down
4 changes: 2 additions & 2 deletions bor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

## Overview

The validators on bor chain produce blocks in sprints and spans. Hence, it is imperative for the protocol to formalise the validators who will be producers in a range of blocks (`span`). The `bor` module in heimdall facilitates this by pseudo-randomly selecting validators who will producing blocks (producers) from the current validator set. The bor chain fetches and persists this information before the next span begins. `bor` module is a crucial component in heimdall since the PoS chain "liveness" depends on it.
The validators on bor chain produce blocks in sprints and spans. Hence, it is imperative for the protocol to formalise the validators who will be producers in a range of blocks (`span`). The `bor` module in heimdall facilitates this by pseudo-randomly selecting validators who will be producing blocks (producers) from the current validator set. The bor chain fetches and persists this information before the next span begins. `bor` module is a crucial component in heimdall since the PoS chain "liveness" depends on it.

## How does it work

Expand Down Expand Up @@ -162,4 +162,4 @@ curl localhost:1317/bor/next-span-seed

```
curl "localhost:1317/bor/prepare-next-span?span_id=<SPAN_ID>&start_block=<BOR_START_BLOCK>&chain_id="<BOR_CHAIN_ID>""
```
```
91 changes: 70 additions & 21 deletions bor/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"

"github.com/ethereum/go-ethereum/common"

"github.com/maticnetwork/heimdall/bor/types"
hmClient "github.com/maticnetwork/heimdall/client"
"github.com/maticnetwork/heimdall/helper"
Expand Down Expand Up @@ -223,14 +221,28 @@ func GetSpanList(cdc *codec.Codec) *cobra.Command {

// GetNextSpanSeed implements the next span seed.
func GetNextSpanSeed(cdc *codec.Codec) *cobra.Command {
return &cobra.Command{
cmd := &cobra.Command{
Use: "next-span-seed",
Args: cobra.NoArgs,
Short: "show the next span seed",
RunE: func(cmd *cobra.Command, args []string) error {
cliCtx := context.NewCLIContext().WithCodec(cdc)

res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryNextSpanSeed), nil)
spanIDStr := viper.GetString(FlagSpanId)
if spanIDStr == "" {
return fmt.Errorf("span id cannot be empty")
}

spanID, err := strconv.ParseUint(spanIDStr, 10, 64)
if err != nil {
return err
}

seedQueryParams, err := cliCtx.Codec.MarshalJSON(types.NewQuerySpanParams(spanID))
if err != nil {
return err
}

res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryNextSpanSeed), seedQueryParams)
if err != nil {

fmt.Println("Error while fetching the span seed")
Expand All @@ -247,9 +259,17 @@ func GetNextSpanSeed(cdc *codec.Codec) *cobra.Command {

},
}

cmd.Flags().String(FlagSpanId, "", "--span-id=<span-id>")

if err := cmd.MarkFlagRequired(FlagSpanId); err != nil {
cliLogger.Error("GetNextSpanSeed | MarkFlagRequired | FlagSpanId", "Error", err)
}

return cmd
}

// PostSendProposeSpanTx send propose span transaction
// GetPreparedProposeSpan generates a propose span transaction
func GetPreparedProposeSpan(cdc *codec.Codec) *cobra.Command {
cmd := &cobra.Command{
Use: "propose-span",
Expand Down Expand Up @@ -291,6 +311,11 @@ func GetPreparedProposeSpan(cdc *codec.Codec) *cobra.Command {
return err
}

nodeStatus, err := helper.GetNodeStatus(cliCtx)
if err != nil {
return err
}

//
// Query data
//
Expand All @@ -309,7 +334,12 @@ func GetPreparedProposeSpan(cdc *codec.Codec) *cobra.Command {
return err
}

res, _, err = cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryNextSpanSeed), nil)
seedQueryParams, err := cliCtx.Codec.MarshalJSON(types.NewQuerySpanParams(spanID))
if err != nil {
return err
}

res, _, err = cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryNextSpanSeed), seedQueryParams)
if err != nil {
return err
}
Expand All @@ -318,23 +348,42 @@ func GetPreparedProposeSpan(cdc *codec.Codec) *cobra.Command {
return errors.New("next span seed not found")
}

var seed common.Hash
if err := jsoniter.Unmarshal(res, &seed); err != nil {
var seedResponse types.QuerySpanSeedResponse
if err := jsoniter.Unmarshal(res, &seedResponse); err != nil {
return err
}

msg := types.NewMsgProposeSpan(
spanID,
proposer,
startBlock,
startBlock+spanDuration-1,
borChainID,
seed,
)

result, err := jsoniter.Marshal(&msg)
if err != nil {
return err
var result []byte

if nodeStatus.SyncInfo.LatestBlockHeight < helper.GetDanelawHeight() {
msg := types.NewMsgProposeSpan(
spanID,
proposer,
startBlock,
startBlock+spanDuration-1,
borChainID,
seedResponse.Seed,
)

result, err = jsoniter.Marshal(&msg)
if err != nil {
return err
}
} else {
msg := types.NewMsgProposeSpanV2(
spanID,
proposer,
startBlock,
startBlock+spanDuration-1,
borChainID,
seedResponse.Seed,
seedResponse.SeedAuthor,
)

result, err = jsoniter.Marshal(&msg)
if err != nil {
return err
}
}

fmt.Println(string(result))
Expand Down
47 changes: 34 additions & 13 deletions bor/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"

"github.com/ethereum/go-ethereum/common"

"github.com/maticnetwork/heimdall/bor/types"
hmClient "github.com/maticnetwork/heimdall/client"
"github.com/maticnetwork/heimdall/helper"
Expand Down Expand Up @@ -84,6 +82,11 @@ func PostSendProposeSpanTx(cdc *codec.Codec) *cobra.Command {
return err
}

nodeStatus, err := helper.GetNodeStatus(cliCtx)
if err != nil {
return err
}

//
// Query data
//
Expand All @@ -102,7 +105,12 @@ func PostSendProposeSpanTx(cdc *codec.Codec) *cobra.Command {
return err
}

res, _, err = cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryNextSpanSeed), nil)
seedQueryParams, err := cliCtx.Codec.MarshalJSON(types.NewQuerySpanParams(spanID))
if err != nil {
return err
}

res, _, err = cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryNextSpanSeed), seedQueryParams)
if err != nil {
return err
}
Expand All @@ -111,19 +119,32 @@ func PostSendProposeSpanTx(cdc *codec.Codec) *cobra.Command {
return errors.New("next span seed not found")
}

var seed common.Hash
if err := jsoniter.ConfigFastest.Unmarshal(res, &seed); err != nil {
var seedResponse types.QuerySpanSeedResponse
if err := jsoniter.ConfigFastest.Unmarshal(res, &seedResponse); err != nil {
return err
}

msg := types.NewMsgProposeSpan(
spanID,
proposer,
startBlock,
startBlock+spanDuration-1,
borChainID,
seed,
)
var msg sdk.Msg
if nodeStatus.SyncInfo.LatestBlockHeight < helper.GetDanelawHeight() {
msg = types.NewMsgProposeSpan(
spanID,
proposer,
startBlock,
startBlock+spanDuration-1,
borChainID,
seedResponse.Seed,
)
} else {
msg = types.NewMsgProposeSpanV2(
spanID,
proposer,
startBlock,
startBlock+spanDuration-1,
borChainID,
seedResponse.Seed,
seedResponse.SeedAuthor,
)
}

return helper.BroadcastMsgsWithCLI(cliCtx, []sdk.Msg{msg})
},
Expand Down
Loading
Loading