Skip to content

Commit

Permalink
AvalancheGo@v1.9.14 (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhrubabasu authored Mar 23, 2023
1 parent 7121edd commit 640e3f8
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 39 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ DOCKER_ORG ?= avaplatform
DOCKER_IMAGE ?= ${DOCKER_ORG}/${PROJECT}
DOCKER_LABEL ?= latest
DOCKER_TAG ?= ${DOCKER_IMAGE}:${DOCKER_LABEL}
AVALANCHE_VERSION ?= v1.9.11
AVALANCHE_VERSION ?= v1.9.14

build:
export CGO_CFLAGS="-O -D__BLST_PORTABLE__" && go build -o ./rosetta-server ./cmd/server
Expand Down
2 changes: 1 addition & 1 deletion client/pchainclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ type pchainClient struct {
}

// NewPChainClient returns a new client for Avalanche APIs related to P-chain
func NewPChainClient(ctx context.Context, rpcBaseURL, indexerBaseURL string) PChainClient {
func NewPChainClient(_ context.Context, rpcBaseURL, indexerBaseURL string) PChainClient {
rpcBaseURL = strings.TrimSuffix(rpcBaseURL, "/")

return pchainClient{
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/ava-labs/avalanche-rosetta
go 1.19

require (
github.com/ava-labs/avalanchego v1.9.11
github.com/ava-labs/coreth v0.11.8-rc.3
github.com/ava-labs/avalanchego v1.9.14
github.com/ava-labs/coreth v0.11.9-rc.0
github.com/coinbase/rosetta-sdk-go v0.6.5
github.com/ethereum/go-ethereum v1.10.26
github.com/stretchr/testify v1.8.1
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/aristanetworks/goarista v0.0.0-20170210015632-ea17b1a17847/go.mod h1:D/tb0zPVXnP7fmsLZjtdUhSsumbK/ij54UXjjVgMGxQ=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/ava-labs/avalanchego v1.9.11 h1:5hXHJMvErfaolWD7Hw9gZaVylck2shBaV/2NTHA0BfA=
github.com/ava-labs/avalanchego v1.9.11/go.mod h1:nNc+4JCIJMaEt2xRmeMVAUyQwDIap7RvnMrfWD2Tpo8=
github.com/ava-labs/coreth v0.11.8-rc.3 h1:pS+OTFPc9edcFuCJIQGn5TdyAZncT9Hhs9jCcmm7+PM=
github.com/ava-labs/coreth v0.11.8-rc.3/go.mod h1:pc44yvJD4jTPIwkPI64pUXyJDvQ/UAqkbmhXOx78PXA=
github.com/ava-labs/avalanchego v1.9.14 h1:pMB3yLdBelSce+ye2sVq2mBTTAHluTOX/TDPt5HxNfs=
github.com/ava-labs/avalanchego v1.9.14/go.mod h1:Unm7ruhAvLSRP+7gIfwyHNf+wEehWLsFhY9yp10nDbw=
github.com/ava-labs/coreth v0.11.9-rc.0 h1:7oK5DWtvDEMKEaduw/34r5kdwUssRsFszCl1FFUvvPc=
github.com/ava-labs/coreth v0.11.9-rc.0/go.mod h1:y41I9mWK04s8oObvQeYjkdoidtPhkPqV8prRPN6zrd4=
github.com/aws/aws-sdk-go v1.25.48/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
Expand Down
2 changes: 0 additions & 2 deletions mapper/pchain/helper.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package pchain

import (
"github.com/ava-labs/avalanchego/codec"
"github.com/ava-labs/avalanchego/vms/platformvm/txs"
"github.com/coinbase/rosetta-sdk-go/types"
)

func ParseRosettaTxs(
parserCfg TxParserConfig,
c codec.Manager,
txs []*txs.Tx,
dependencyTxs BlockTxDependencies,
) ([]*types.Transaction, error) {
Expand Down
12 changes: 6 additions & 6 deletions service/backend/cchainatomictx/construction.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ var (
)

// ConstructionDerive implements /construction/derive endpoint for C-chain atomic transactions
func (b *Backend) ConstructionDerive(ctx context.Context, req *types.ConstructionDeriveRequest) (*types.ConstructionDeriveResponse, *types.Error) {
func (b *Backend) ConstructionDerive(_ context.Context, req *types.ConstructionDeriveRequest) (*types.ConstructionDeriveResponse, *types.Error) {
return common.DeriveBech32Address(b.fac, constants.CChain, req)
}

// ConstructionPreprocess implements /construction/preprocess endpoint for C-chain atomic transactions
func (b *Backend) ConstructionPreprocess(
ctx context.Context,
_ context.Context,
req *types.ConstructionPreprocessRequest,
) (*types.ConstructionPreprocessResponse, *types.Error) {
matches, err := common.MatchOperations(req.Operations)
Expand Down Expand Up @@ -202,7 +202,7 @@ func (b *Backend) calculateSuggestedFee(ctx context.Context, gasUsed *big.Int) (
}

// ConstructionPayloads implements /construction/payloads endpoint for C-chain atomic transactions
func (b *Backend) ConstructionPayloads(ctx context.Context, req *types.ConstructionPayloadsRequest) (*types.ConstructionPayloadsResponse, *types.Error) {
func (b *Backend) ConstructionPayloads(_ context.Context, req *types.ConstructionPayloadsRequest) (*types.ConstructionPayloadsResponse, *types.Error) {
builder := cAtomicTxBuilder{
avaxAssetID: b.avaxAssetID,
codec: b.codec,
Expand All @@ -212,7 +212,7 @@ func (b *Backend) ConstructionPayloads(ctx context.Context, req *types.Construct
}

// ConstructionParse implements /construction/parse endpoint for C-chain atomic transactions
func (b *Backend) ConstructionParse(ctx context.Context, req *types.ConstructionParseRequest) (*types.ConstructionParseResponse, *types.Error) {
func (b *Backend) ConstructionParse(_ context.Context, req *types.ConstructionParseRequest) (*types.ConstructionParseResponse, *types.Error) {
rosettaTx, err := b.parsePayloadTxFromString(req.Transaction)
if err != nil {
return nil, service.WrapError(service.ErrInvalidInput, err)
Expand Down Expand Up @@ -254,7 +254,7 @@ func (b *Backend) parsePayloadTxFromString(transaction string) (*common.RosettaT
}

// ConstructionCombine implements /construction/combine endpoint for C-chain atomic transactions
func (b *Backend) ConstructionCombine(ctx context.Context, req *types.ConstructionCombineRequest) (*types.ConstructionCombineResponse, *types.Error) {
func (b *Backend) ConstructionCombine(_ context.Context, req *types.ConstructionCombineRequest) (*types.ConstructionCombineResponse, *types.Error) {
rosettaTx, err := b.parsePayloadTxFromString(req.UnsignedTransaction)
if err != nil {
return nil, service.WrapError(service.ErrInvalidInput, err)
Expand Down Expand Up @@ -309,7 +309,7 @@ func getTxCreds(

// ConstructionHash implements /construction/hash endpoint for C-chain atomic transactions
func (b *Backend) ConstructionHash(
ctx context.Context,
_ context.Context,
req *types.ConstructionHashRequest,
) (*types.TransactionIdentifierResponse, *types.Error) {
rosettaTx, err := b.parsePayloadTxFromString(req.SignedTransaction)
Expand Down
11 changes: 3 additions & 8 deletions service/backend/pchain/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ package pchain
import (
"context"

"github.com/ava-labs/avalanchego/codec"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/vms/platformvm/blocks"
"github.com/ava-labs/avalanchego/vms/platformvm/txs"
"github.com/coinbase/rosetta-sdk-go/types"

Expand Down Expand Up @@ -50,7 +48,7 @@ func (b *Backend) Block(ctx context.Context, request *types.BlockRequest) (*type
if err != nil {
return nil, service.WrapError(service.ErrClientError, err)
}
rosettaTxs, err := pmapper.ParseRosettaTxs(b.txParserCfg, blocks.GenesisCodec, genesisTxs, nil)
rosettaTxs, err := pmapper.ParseRosettaTxs(b.txParserCfg, genesisTxs, nil)
if err != nil {
return nil, service.WrapError(service.ErrClientError, err)
}
Expand Down Expand Up @@ -80,7 +78,7 @@ func (b *Backend) Block(ctx context.Context, request *types.BlockRequest) (*type
return nil, service.WrapError(service.ErrInternalError, err)
}

rosettaTxs, err := pmapper.ParseRosettaTxs(b.txParserCfg, blocks.Codec, block.Txs, blkDeps)
rosettaTxs, err := pmapper.ParseRosettaTxs(b.txParserCfg, block.Txs, blkDeps)
if err != nil {
return nil, service.WrapError(service.ErrInternalError, err)
}
Expand Down Expand Up @@ -115,7 +113,6 @@ func (b *Backend) BlockTransaction(ctx context.Context, request *types.BlockTran
var (
targetTxs []*txs.Tx
dependencyTxs pmapper.BlockTxDependencies
targetCodec codec.Manager
)

isGenesisReq, err := b.isGenesisBlockRequest(request.BlockIdentifier.Index, request.BlockIdentifier.Hash)
Expand All @@ -132,7 +129,6 @@ func (b *Backend) BlockTransaction(ctx context.Context, request *types.BlockTran

targetTxs = genesisTxs
dependencyTxs = nil
targetCodec = blocks.GenesisCodec

default:
block, err := b.indexerParser.ParseNonGenesisBlock(ctx, request.BlockIdentifier.Hash, uint64(request.BlockIdentifier.Index))
Expand All @@ -146,10 +142,9 @@ func (b *Backend) BlockTransaction(ctx context.Context, request *types.BlockTran

targetTxs = block.Txs
dependencyTxs = deps
targetCodec = blocks.Codec
}

rosettaTxs, err := pmapper.ParseRosettaTxs(b.txParserCfg, targetCodec, targetTxs, dependencyTxs)
rosettaTxs, err := pmapper.ParseRosettaTxs(b.txParserCfg, targetTxs, dependencyTxs)
if err != nil {
return nil, service.WrapError(service.ErrInternalError, err)
}
Expand Down
12 changes: 6 additions & 6 deletions service/backend/pchain/construction.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ var (
)

// ConstructionDerive implements /construction/derive endpoint for P-chain
func (b *Backend) ConstructionDerive(ctx context.Context, req *types.ConstructionDeriveRequest) (*types.ConstructionDeriveResponse, *types.Error) {
func (b *Backend) ConstructionDerive(_ context.Context, req *types.ConstructionDeriveRequest) (*types.ConstructionDeriveResponse, *types.Error) {
return common.DeriveBech32Address(b.fac, constants.PChain, req)
}

// ConstructionPreprocess implements /construction/preprocess endpoint for P-chain
func (b *Backend) ConstructionPreprocess(
ctx context.Context,
_ context.Context,
req *types.ConstructionPreprocessRequest,
) (*types.ConstructionPreprocessResponse, *types.Error) {
matches, err := common.MatchOperations(req.Operations)
Expand Down Expand Up @@ -182,7 +182,7 @@ func (b *Backend) getBaseTxFee(ctx context.Context) (*types.Amount, error) {
}

// ConstructionPayloads implements /construction/payloads endpoint for P-chain
func (b *Backend) ConstructionPayloads(ctx context.Context, req *types.ConstructionPayloadsRequest) (*types.ConstructionPayloadsResponse, *types.Error) {
func (b *Backend) ConstructionPayloads(_ context.Context, req *types.ConstructionPayloadsRequest) (*types.ConstructionPayloadsResponse, *types.Error) {
builder := pTxBuilder{
avaxAssetID: b.avaxAssetID,
codec: b.codec,
Expand All @@ -192,7 +192,7 @@ func (b *Backend) ConstructionPayloads(ctx context.Context, req *types.Construct
}

// ConstructionParse implements /construction/parse endpoint for P-chain
func (b *Backend) ConstructionParse(ctx context.Context, req *types.ConstructionParseRequest) (*types.ConstructionParseResponse, *types.Error) {
func (b *Backend) ConstructionParse(_ context.Context, req *types.ConstructionParseRequest) (*types.ConstructionParseResponse, *types.Error) {
rosettaTx, err := b.parsePayloadTxFromString(req.Transaction)
if err != nil {
return nil, service.WrapError(service.ErrInvalidInput, err)
Expand All @@ -214,7 +214,7 @@ func (b *Backend) ConstructionParse(ctx context.Context, req *types.Construction
}

// ConstructionCombine implements /construction/combine endpoint for P-chain
func (b *Backend) ConstructionCombine(ctx context.Context, req *types.ConstructionCombineRequest) (*types.ConstructionCombineResponse, *types.Error) {
func (b *Backend) ConstructionCombine(_ context.Context, req *types.ConstructionCombineRequest) (*types.ConstructionCombineResponse, *types.Error) {
rosettaTx, err := b.parsePayloadTxFromString(req.UnsignedTransaction)
if err != nil {
return nil, service.WrapError(service.ErrInvalidInput, err)
Expand Down Expand Up @@ -283,7 +283,7 @@ func getTxInputs(

// ConstructionHash implements /construction/hash endpoint for P-chain
func (b *Backend) ConstructionHash(
ctx context.Context,
_ context.Context,
req *types.ConstructionHashRequest,
) (*types.TransactionIdentifierResponse, *types.Error) {
rosettaTx, err := b.parsePayloadTxFromString(req.SignedTransaction)
Expand Down
2 changes: 1 addition & 1 deletion service/backend/pchain/indexer/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (p *parser) GetPlatformHeight(ctx context.Context) (uint64, error) {
// GetGenesisBlock is called to initialize P-chain genesis information upon startup.
// GetGenesisBlock should not call the indexer, to ensure backward compatibility with
// previous installations which do no host a block indexer.
func (p *parser) GetGenesisBlock(ctx context.Context) (*ParsedGenesisBlock, error) {
func (p *parser) GetGenesisBlock(_ context.Context) (*ParsedGenesisBlock, error) {
bytes, _, err := genesis.FromConfig(genesis.GetConfig(p.networkID))
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions service/backend/pchain/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (b *Backend) NetworkIdentifier() *types.NetworkIdentifier {
}

// NetworkStatus implements /network/status endpoint for P-chain
func (b *Backend) NetworkStatus(ctx context.Context, req *types.NetworkRequest) (*types.NetworkStatusResponse, *types.Error) {
func (b *Backend) NetworkStatus(ctx context.Context, _ *types.NetworkRequest) (*types.NetworkStatusResponse, *types.Error) {
// Fetch peers
infoPeers, err := b.pClient.Peers(ctx)
if err != nil {
Expand Down Expand Up @@ -62,7 +62,7 @@ func (b *Backend) NetworkStatus(ctx context.Context, req *types.NetworkRequest)
}

// NetworkOptions implements /network/options endpoint for P-chain
func (b *Backend) NetworkOptions(ctx context.Context, request *types.NetworkRequest) (*types.NetworkOptionsResponse, *types.Error) {
func (b *Backend) NetworkOptions(_ context.Context, _ *types.NetworkRequest) (*types.NetworkOptionsResponse, *types.Error) {
return &types.NetworkOptionsResponse{
Version: &types.Version{
RosettaVersion: types.RosettaAPIVersion,
Expand Down
2 changes: 1 addition & 1 deletion service/rosetta.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ var NodeVersion = fmt.Sprintf(
)

const (
MiddlewareVersion = "0.1.27"
MiddlewareVersion = "0.1.28"
BlockchainName = "Avalanche"
)
6 changes: 3 additions & 3 deletions service/service_mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func NewMempoolService(config *Config, client client.Client) server.MempoolAPISe
// Mempool implements the /mempool endpoint
func (s MempoolService) Mempool(
ctx context.Context,
req *types.NetworkRequest,
_ *types.NetworkRequest,
) (*types.MempoolResponse, *types.Error) {
if s.config.IsOfflineMode() {
return nil, ErrUnavailableOffline
Expand All @@ -48,8 +48,8 @@ func (s MempoolService) Mempool(

// MempoolTransaction implements the /mempool/transaction endpoint
func (s MempoolService) MempoolTransaction(
ctx context.Context,
req *types.MempoolTransactionRequest,
_ context.Context,
_ *types.MempoolTransactionRequest,
) (*types.MempoolTransactionResponse, *types.Error) {
return nil, ErrNotImplemented
}
4 changes: 2 additions & 2 deletions service/service_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ func NewNetworkService(

// NetworkList implements the /network/list endpoint
func (s *NetworkService) NetworkList(
ctx context.Context,
request *types.MetadataRequest,
_ context.Context,
_ *types.MetadataRequest,
) (*types.NetworkListResponse, *types.Error) {
return &types.NetworkListResponse{
NetworkIdentifiers: []*types.NetworkIdentifier{
Expand Down

0 comments on commit 640e3f8

Please sign in to comment.