Skip to content

Commit

Permalink
upgrade to 2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
javiersuweijie committed Sep 12, 2023
1 parent 524144f commit 70d4e3a
Show file tree
Hide file tree
Showing 45 changed files with 608 additions and 605 deletions.
4 changes: 2 additions & 2 deletions block_feed/helpers.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package block_feed

import (
abci "github.com/tendermint/tendermint/abci/types"
tmjson "github.com/tendermint/tendermint/libs/json"
abci "github.com/cometbft/cometbft/abci/types"
tmjson "github.com/cometbft/cometbft/libs/json"
)

func extractBlockFromWSResponse(message []byte) (*BlockResult, error) {
Expand Down
6 changes: 3 additions & 3 deletions block_feed/types.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package block_feed

import (
tendermint "github.com/tendermint/tendermint/types"
cometbfttypes "github.com/cometbft/cometbft/types"
)

// BlockFeed is a standard interface to provide subscription over blocks
Expand All @@ -16,6 +16,6 @@ type BlockFeed interface {
}

type BlockResult struct {
BlockID *tendermint.BlockID `json:"block_id"`
Block *tendermint.Block `json:"block"`
BlockID *cometbfttypes.BlockID `json:"block_id"`
Block *cometbfttypes.Block `json:"block"`
}
2 changes: 1 addition & 1 deletion block_feed/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (ws *WSSubscription) Subscribe(rpcIndex int) (chan *BlockResult, error) {
},
}

log.Print("Subscribing to tendermint rpc...")
log.Print("Subscribing to cometbft rpc...")

// should not fail here
if err := ws.ws.WriteJSON(request); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion db/heleveldb/leveldb_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package heleveldb
import (
"fmt"

tmdb "github.com/tendermint/tm-db"
tmdb "github.com/cometbft/cometbft-db"
"github.com/terra-money/mantlemint/db/hld"
"github.com/terra-money/mantlemint/db/rollbackable"
)
Expand Down
2 changes: 1 addition & 1 deletion db/heleveldb/leveldb_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"math"

tmdb "github.com/tendermint/tm-db"
tmdb "github.com/cometbft/cometbft-db"
"github.com/terra-money/mantlemint/db/hld"
"github.com/terra-money/mantlemint/lib"
)
Expand Down
2 changes: 1 addition & 1 deletion db/heleveldb/leveldb_iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package heleveldb
import (
"bytes"

tmdb "github.com/tendermint/tm-db"
tmdb "github.com/cometbft/cometbft-db"
"github.com/terra-money/mantlemint/db/hld"
)

Expand Down
2 changes: 1 addition & 1 deletion db/hld/height_limited_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/terra-money/mantlemint/lib"

tmdb "github.com/tendermint/tm-db"
tmdb "github.com/cometbft/cometbft-db"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion db/hld/height_limited_iterator.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package hld

import tmdb "github.com/tendermint/tm-db"
import tmdb "github.com/cometbft/cometbft-db"

var _ tmdb.Iterator = (*HeightLimitedDBIterator)(nil)

Expand Down
2 changes: 1 addition & 1 deletion db/hld/types.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package hld

import (
tmdb "github.com/tendermint/tm-db"
tmdb "github.com/cometbft/cometbft-db"
)

type HLD interface {
Expand Down
2 changes: 1 addition & 1 deletion db/rollbackable/rollbackable_batch.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package rollbackable

import (
tmdb "github.com/tendermint/tm-db"
tmdb "github.com/cometbft/cometbft-db"
)

type HasRollbackBatch interface {
Expand Down
2 changes: 1 addition & 1 deletion db/safe_batch/safe_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package safe_batch
import (
"fmt"

tmdb "github.com/tendermint/tm-db"
tmdb "github.com/cometbft/cometbft-db"
"github.com/terra-money/mantlemint/db/rollbackable"
)

Expand Down
2 changes: 1 addition & 1 deletion db/safe_batch/safe_batch_nullify.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package safe_batch

import tmdb "github.com/tendermint/tm-db"
import tmdb "github.com/cometbft/cometbft-db"

var _ tmdb.Batch = (*SafeBatchNullified)(nil)

Expand Down
2 changes: 1 addition & 1 deletion db/snappy/snappy_batch.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package snappy

import (
tmdb "github.com/cometbft/cometbft-db"
"github.com/golang/snappy"
tmdb "github.com/tendermint/tm-db"
)

var _ tmdb.Batch = (*SnappyBatch)(nil)
Expand Down
2 changes: 1 addition & 1 deletion db/snappy/snappy_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package snappy

import (
"encoding/json"
tmdb "github.com/cometbft/cometbft-db"
"github.com/golang/snappy"
"github.com/pkg/errors"
tmdb "github.com/tendermint/tm-db"
"sync"
)

Expand Down
8 changes: 4 additions & 4 deletions db/snappy/snappy_db_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package snappy

import (
db "github.com/cometbft/cometbft-db"
tmjson "github.com/cometbft/cometbft/libs/json"
cometbfttypes "github.com/cometbft/cometbft/types"
"github.com/stretchr/testify/assert"
tmjson "github.com/tendermint/tendermint/libs/json"
tendermint "github.com/tendermint/tendermint/types"
db "github.com/tendermint/tm-db"
"io/ioutil"
"os"
"testing"
Expand Down Expand Up @@ -81,7 +81,7 @@ func TestSnappyDBCompat(t *testing.T) {
}

func indexSampleTx(mdb db.DB, key []byte) {
block := &tendermint.Block{}
block := &cometbfttypes.Block{}
blockFile, _ := os.Open("../../indexer/fixtures/block_4814775.json")
blockJSON, _ := ioutil.ReadAll(blockFile)
if err := tmjson.Unmarshal(blockJSON, block); err != nil {
Expand Down
17 changes: 10 additions & 7 deletions export/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@ import (
"strings"
"time"

tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
sdktypes "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
distrikeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
"github.com/cosmos/cosmos-sdk/x/distribution/types"
distrotypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
terra "github.com/terra-money/core/v2/app"
app "github.com/terra-money/core/v2/app"
)

var IsAccountExportWorkerRunning = false

func ExportAllAccounts(app *terra.TerraApp) error {
func ExportAllAccounts(app *app.TerraApp) error {
if IsAccountExportWorkerRunning {
return fmt.Errorf("exporting is still running")
}
Expand All @@ -27,11 +28,12 @@ func ExportAllAccounts(app *terra.TerraApp) error {
return nil
}

func ExportCirculatingSupply(app *terra.TerraApp) (sdktypes.Int, error) {
func ExportCirculatingSupply(app *app.TerraApp) (sdktypes.Int, error) {
height := app.LastBlockHeight()
ctx := app.NewContext(true, tmproto.Header{Height: height})
time := time.Now()
totalVesting := sdktypes.NewInt(0)
distQuerier := distrikeeper.NewQuerier(app.DistrKeeper)
app.AccountKeeper.IterateAccounts(ctx, func(account authtypes.AccountI) (stop bool) {
switch account.(type) {
case *vestingtypes.PeriodicVestingAccount:
Expand All @@ -58,7 +60,7 @@ func ExportCirculatingSupply(app *terra.TerraApp) (sdktypes.Int, error) {
return sdktypes.Int{}, err
}
lunaTotalSupply := totalSupply.Amount.Amount
communityPool, err := app.DistrKeeper.CommunityPool(sdktypes.WrapSDKContext(ctx), &distrotypes.QueryCommunityPoolRequest{})
communityPool, err := distQuerier.CommunityPool(sdktypes.WrapSDKContext(ctx), &distrotypes.QueryCommunityPoolRequest{})
if err != nil {
return sdktypes.Int{}, err
}
Expand All @@ -67,17 +69,18 @@ func ExportCirculatingSupply(app *terra.TerraApp) (sdktypes.Int, error) {
return lunaTotalSupply.Sub(lunaCommunityPool).Sub(totalVesting), nil
}

func runAccountExportWorker(app *terra.TerraApp) {
func runAccountExportWorker(app *app.TerraApp) {
app.Logger().Info("[export] exporting accounts")
height := app.LastBlockHeight()
ctx := app.NewContext(true, tmproto.Header{Height: height})
// Should use lastest block time
time := time.Now()
var accounts []string
count := 0
distQuerier := distrikeeper.NewQuerier(app.DistrKeeper)
app.AccountKeeper.IterateAccounts(ctx, func(account authtypes.AccountI) (stop bool) {
balance := app.BankKeeper.GetBalance(ctx, account.GetAddress(), "uluna").Amount
delegationRewards, err := app.DistrKeeper.DelegationTotalRewards(sdktypes.WrapSDKContext(ctx), &types.QueryDelegationTotalRewardsRequest{
delegationRewards, err := distQuerier.DelegationTotalRewards(sdktypes.WrapSDKContext(ctx), &types.QueryDelegationTotalRewardsRequest{
DelegatorAddress: account.GetAddress().String(),
})
if err != nil {
Expand Down
Loading

0 comments on commit 70d4e3a

Please sign in to comment.