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

chore: fix wrong function name in go docs #1221

Closed
wants to merge 11 commits into from
Closed
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
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
8 changes: 6 additions & 2 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
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
56 changes: 39 additions & 17 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 @@ -271,7 +269,7 @@ func GetNextSpanSeed(cdc *codec.Codec) *cobra.Command {
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 @@ -313,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 Down Expand Up @@ -345,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
40 changes: 28 additions & 12 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 Down Expand Up @@ -116,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
45 changes: 32 additions & 13 deletions bor/client/rest/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ import (
"github.com/gorilla/mux"
jsoniter "github.com/json-iterator/go"

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

"github.com/maticnetwork/heimdall/bor/types"
restClient "github.com/maticnetwork/heimdall/client/rest"
"github.com/maticnetwork/heimdall/helper"
hmTypes "github.com/maticnetwork/heimdall/types"
"github.com/maticnetwork/heimdall/types/rest"
)
Expand Down Expand Up @@ -163,20 +162,40 @@ func postProposeSpanHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return
}

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
}

// draft a propose span message
msg := types.NewMsgProposeSpan(
req.ID,
hmTypes.HexToHeimdallAddress(req.BaseReq.From),
req.StartBlock,
req.StartBlock+spanDuration-1,
req.BorChainID,
seed,
)
nodeStatus, err := helper.GetNodeStatus(cliCtx)
if err != nil {
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
return
}

var msg sdk.Msg
if nodeStatus.SyncInfo.LatestBlockHeight < helper.GetDanelawHeight() {
// draft a propose span message
msg = types.NewMsgProposeSpan(
req.ID,
hmTypes.HexToHeimdallAddress(req.BaseReq.From),
req.StartBlock,
req.StartBlock+spanDuration-1,
req.BorChainID,
seedResponse.Seed,
)
} else {
// draft a propose span v2 message
msg = types.NewMsgProposeSpanV2(
req.ID,
hmTypes.HexToHeimdallAddress(req.BaseReq.From),
req.StartBlock,
req.StartBlock+spanDuration-1,
req.BorChainID,
seedResponse.Seed,
seedResponse.SeedAuthor,
)
}

// send response
restClient.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg})
Expand Down
Loading