Skip to content

Commit

Permalink
Merge pull request #1189 from maticnetwork/v1.0.9-beta-candidate
Browse files Browse the repository at this point in the history
v1.0.9
  • Loading branch information
marcello33 authored Oct 8, 2024
2 parents b0c4a07 + ba12942 commit ee258e0
Show file tree
Hide file tree
Showing 33 changed files with 1,548 additions and 266 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ jobs:
- name: Upload logs
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4.4.0
with:
name: logs_${{ github.run_id }}
path: |
Expand All @@ -154,7 +154,7 @@ jobs:
- name: Upload code and chain data
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4.4.0
with:
name: code_${{ github.run_id }}
path: code.tar.gz
2 changes: 1 addition & 1 deletion .github/workflows/govuln.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
fail-on-vuln: true

- name: Upload govulncheck report
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4.4.0
with:
name: raw-report
path: raw-report.json
18 changes: 11 additions & 7 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import (
dbm "github.com/tendermint/tm-db"

authTypes "github.com/maticnetwork/heimdall/auth/types"
"github.com/maticnetwork/heimdall/helper"

hmTypes "github.com/maticnetwork/heimdall/types"
)

// Setup initializes a new App. A Nop logger is set in App.
func Setup(isCheckTx bool) *HeimdallApp {
func Setup(isCheckTx bool, testOpts ...*helper.TestOpts) *HeimdallApp {
db := dbm.NewMemDB()
app := NewHeimdallApp(log.NewNopLogger(), db)

Expand All @@ -26,12 +27,15 @@ func Setup(isCheckTx bool) *HeimdallApp {
}

// Initialize the chain
app.InitChain(
abci.RequestInitChain{
Validators: []abci.ValidatorUpdate{},
AppStateBytes: stateBytes,
},
)
req := abci.RequestInitChain{
Validators: []abci.ValidatorUpdate{},
AppStateBytes: stateBytes,
}

if len(testOpts) > 0 && testOpts[0] != nil {
req.ChainId = testOpts[0].GetChainId()
}
app.InitChain(req)
}

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

const maxSpanListLimit = 150 // a span is ~6 KB => we can fit 150 spans in 1 MB response

var (
LastSpanIDKey = []byte{0x35} // Key to store last span start block
SpanPrefixKey = []byte{0x36} // prefix key to store span
Expand Down Expand Up @@ -153,8 +155,8 @@ func (k *Keeper) GetSpanList(ctx sdk.Context, page uint64, limit uint64) ([]hmTy
store := ctx.KVStore(k.storeKey)

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

// get paginated iterator
Expand Down
14 changes: 7 additions & 7 deletions bridge/setu/broadcaster/broadcaster.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func NewTxBroadcaster(cdc *codec.Codec) *TxBroadcaster {
}

// BroadcastToHeimdall broadcast to heimdall
func (tb *TxBroadcaster) BroadcastToHeimdall(msg sdk.Msg, event interface{}) error {
func (tb *TxBroadcaster) BroadcastToHeimdall(msg sdk.Msg, event interface{}, testOpts ...*helper.TestOpts) (sdk.TxResponse, error) {
tb.heimdallMutex.Lock()
defer tb.heimdallMutex.Unlock()
defer util.LogElapsedTimeForStateSyncedEvent(event, "BroadcastToHeimdall", time.Now())
Expand All @@ -75,9 +75,9 @@ func (tb *TxBroadcaster) BroadcastToHeimdall(msg sdk.Msg, event interface{}) err
WithSequence(tb.lastSeqNo).
WithChainID(chainID)

txResponse, err := helper.BuildAndBroadcastMsgs(tb.CliCtx, txBldr, []sdk.Msg{msg})
if err != nil {
tb.logger.Error("Error while broadcasting the heimdall transaction", "error", err)
txResponse, err := helper.BuildAndBroadcastMsgs(tb.CliCtx, txBldr, []sdk.Msg{msg}, testOpts...)
if err != nil || txResponse.Code != uint32(sdk.CodeOK) {
tb.logger.Error("Error while broadcasting the heimdall transaction", "error", err, "txResponse", txResponse.Code)

// current address
address := hmTypes.BytesToHeimdallAddress(helper.GetAddress())
Expand All @@ -86,13 +86,13 @@ func (tb *TxBroadcaster) BroadcastToHeimdall(msg sdk.Msg, event interface{}) err
account, errAcc := util.GetAccount(tb.CliCtx, address)
if errAcc != nil {
tb.logger.Error("Error fetching account from rest-api", "url", helper.GetHeimdallServerEndpoint(fmt.Sprintf(util.AccountDetailsURL, helper.GetAddress())))
return errAcc
return txResponse, errAcc
}

// update seqNo for safety
tb.lastSeqNo = account.GetSequence()

return err
return txResponse, err
}

txHash := txResponse.TxHash
Expand All @@ -102,7 +102,7 @@ func (tb *TxBroadcaster) BroadcastToHeimdall(msg sdk.Msg, event interface{}) err
// increment account sequence
tb.lastSeqNo += 1

return nil
return txResponse, nil
}

// BroadcastToMatic broadcast to matic
Expand Down
Loading

0 comments on commit ee258e0

Please sign in to comment.