Skip to content

Commit

Permalink
Merge pull request #373 from scrtlabs/make-rosetta-work
Browse files Browse the repository at this point in the history
Hardcode genesis block to make Rosetta shut up
  • Loading branch information
assafmo authored Jan 23, 2024
2 parents ea64f27 + fa873fa commit 49fc84d
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions server/rosetta/lib/internal/service/online.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,26 @@ package service

import (
"context"
"time"

"github.com/coinbase/rosetta-sdk-go/types"

crgerrs "github.com/cosmos/cosmos-sdk/server/rosetta/lib/errors"
crgtypes "github.com/cosmos/cosmos-sdk/server/rosetta/lib/types"
)

// genesisBlockFetchTimeout defines a timeout to fetch the genesis block
const genesisBlockFetchTimeout = 15 * time.Second

// NewOnlineNetwork builds a single network adapter.
// It will get the Genesis block on the beginning to avoid calling it everytime.
func NewOnlineNetwork(network *types.NetworkIdentifier, client crgtypes.Client) (crgtypes.API, error) {
ctx, cancel := context.WithTimeout(context.Background(), genesisBlockFetchTimeout)
defer cancel()

var genesisHeight int64 = -1 // to use initial_height in genesis.json
block, err := client.BlockByHeight(ctx, &genesisHeight)
if err != nil {
return OnlineNetwork{}, err
blockId := &types.BlockIdentifier{
Index: 813800,
Hash: "C168FE742EC3DCD6911B31CEE7F0C58EF7621EB85E87193875CD9C2C7E74473C",
}

return OnlineNetwork{
client: client,
network: network,
networkOptions: networkOptionsFromClient(client, block.Block),
genesisBlockIdentifier: block.Block,
networkOptions: networkOptionsFromClient(client, blockId),
genesisBlockIdentifier: blockId,
}, nil
}

Expand Down

0 comments on commit 49fc84d

Please sign in to comment.