Skip to content

Commit

Permalink
Support of Nairobi protocol (#974)
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky authored May 4, 2023
1 parent a4330ba commit 2fa96e8
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 11 deletions.
5 changes: 2 additions & 3 deletions cmd/indexer/indexer/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func (bi *BlockchainIndexer) Index(ctx context.Context, head noderpc.Header) err
func (bi *BlockchainIndexer) handleBlock(ctx context.Context, block *Block) error {
return bi.StorageDB.DB.RunInTransaction(ctx,
func(tx *pg.Tx) error {
logger.Info().Str("network", bi.Network.String()).Msgf("indexing %7d block", block.Header.Level)
logger.Info().Str("network", bi.Network.String()).Int64("block", block.Header.Level).Msg("indexing")

if block.Header.Protocol != bi.currentProtocol.Hash || (bi.Network == types.Mainnet && block.Header.Level == 1) {
logger.Info().Str("network", bi.Network.String()).Msgf("New protocol detected: %s -> %s", bi.currentProtocol.Hash, block.Header.Protocol)
Expand Down Expand Up @@ -329,8 +329,7 @@ func (bi *BlockchainIndexer) process(ctx context.Context) error {
return errors.Errorf("Invalid chain_id: %s (state) != %s (head)", bi.state.Protocol.ChainID, head.ChainID)
}

logger.Info().Str("network", bi.Network.String()).Msgf("Current node state: %7d", head.Level)
logger.Info().Str("network", bi.Network.String()).Msgf("Current indexer state: %7d", bi.state.Level)
logger.Info().Str("network", bi.Network.String()).Int64("node", head.Level).Int64("indexer", bi.state.Level).Msg("current state")

switch {
case head.Level > bi.state.Level:
Expand Down
21 changes: 16 additions & 5 deletions configs/development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ rpc:
uri: https://rpc.tzkt.io/mumbainet
timeout: 20
requests_per_second: 20
nairobinet:
uri: https://rpc.tzkt.io/nairobinet
timeout: 20
requests_per_second: 20

tzkt:
mainnet:
Expand All @@ -23,6 +27,8 @@ services:
mempool: https://mempool.test.dipdup.net/v1/graphql
mumbainet:
mempool: https://mempool.test.dipdup.net/v1/graphql
nairobinet:
mempool: https://mempool.test.dipdup.net/v1/graphql

storage:
pg:
Expand Down Expand Up @@ -59,10 +65,12 @@ api:
mainnet: https://rpc.tzkt.io/mainnet
ghostnet: https://rpc.tzkt.io/ghostnet
mumbainet: https://rpc.tzkt.io/mumbainet
nairobinet: https://rpc.tzkt.io/nairobinet
networks:
- mainnet
- ghostnet
- mumbainet
- nairobinet
connections:
max: 50
idle: 50
Expand All @@ -71,11 +79,13 @@ indexer:
project_name: indexer
sentry_enabled: false
networks:
mainnet:
receiver_threads: 5
ghostnet:
receiver_threads: 10
mumbainet:
# mainnet:
# receiver_threads: 5
# ghostnet:
# receiver_threads: 10
# mumbainet:
# receiver_threads: 10
nairobinet:
receiver_threads: 10
connections:
max: 5
Expand All @@ -91,6 +101,7 @@ scripts:
- mainnet
- ghostnet
- mumbainet
- nairobinet
connections:
max: 5
idle: 5
11 changes: 11 additions & 0 deletions configs/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ rpc:
uri: https://rpc.tzkt.io/mumbainet
timeout: 20
requests_per_second: 20
nairobinet:
uri: https://rpc.tzkt.io/nairobinet
timeout: 20
requests_per_second: 20

tzkt:
mainnet:
Expand All @@ -24,6 +28,8 @@ services:
mempool: https://mempool.test.dipdup.net/v1/graphql
mumbainet:
mempool: https://mempool.test.dipdup.net/v1/graphql
nairobinet:
mempool: https://mempool.test.dipdup.net/v1/graphql

storage:
pg:
Expand Down Expand Up @@ -60,10 +66,12 @@ api:
mainnet: https://rpc.tzkt.io/mainnet
ghostnet: https://rpc.tzkt.io/ghostnet
mumbainet: https://rpc.tzkt.io/mumbainet
nairobinet: https://rpc.tzkt.io/nairobinet
networks:
- mainnet
- ghostnet
- mumbainet
- nairobinet
connections:
max: 50
idle: 10
Expand All @@ -78,6 +86,8 @@ indexer:
receiver_threads: ${TESTNET_THREADS:-1}
mumbainet:
receiver_threads: ${TESTNET_THREADS:-1}
nairobinet:
receiver_threads: ${TESTNET_THREADS:-1}
connections:
max: 5
idle: 5
Expand All @@ -92,6 +102,7 @@ scripts:
- mainnet
- ghostnet
- mumbainet
- nairobinet
connections:
max: 5
idle: 5
2 changes: 2 additions & 0 deletions internal/bcd/protocols.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ var symLinks = map[string]string{
"PtLimaPtLMwfNinJi9rCfDPWea8dFgTZ1MeJ9f1m2SRic6ayiwW": SymLinkJakarta, // Lima
"PtMumbaiiFFEGbew1rRjzSPyzRbA51Tm3RVZL5suHPxSZYDhCEc": SymLinkJakarta, // Mumbai
"PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1": SymLinkJakarta, // Mumbai 2
"PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf": SymLinkJakarta, // Nairobinet
}

// GetProtoSymLink -
Expand Down Expand Up @@ -69,4 +70,5 @@ var ChainID = map[string]string{
"NetXi2ZagzEsXbZ": "kathmandunet",
"NetXizpkH94bocH": "limanet",
"NetXQw6nWSnrJ5t": "mumbainet",
"NetXyuzvDo2Ugzb": "nairobinet",
}
3 changes: 3 additions & 0 deletions internal/models/types/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const (
Dailynet
Mumbainet
Rollupnet
Nairobinet
)

var networkNames = map[Network]string{
Expand All @@ -51,6 +52,7 @@ var networkNames = map[Network]string{
Dailynet: "dailynet",
Mumbainet: "mumbainet",
Rollupnet: "rollupnet",
Nairobinet: "nairobinet",
}

var namesToNetwork = map[string]Network{
Expand All @@ -72,6 +74,7 @@ var namesToNetwork = map[string]Network{
"dailynet": Dailynet,
"mumbainet": Mumbainet,
"rollupnet": Rollupnet,
"nairobinet": Nairobinet,
}

// String - convert enum to string for printing
Expand Down
3 changes: 2 additions & 1 deletion internal/parsers/operations/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ func (m Migration) Parse(data noderpc.Operation, operation *operation.Operation,
"PtKathmankSpLLDALzWw7CGD2j2MtyveTwboEYokqUCP4a1LxMg",
"PtLimaPtLMwfNinJi9rCfDPWea8dFgTZ1MeJ9f1m2SRic6ayiwW",
"PtMumbaiiFFEGbew1rRjzSPyzRbA51Tm3RVZL5suHPxSZYDhCEc",
"PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1":
"PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1",
"PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf":

return m.fromLazyStorageDiff(data, operation, store)
default:
Expand Down
6 changes: 4 additions & 2 deletions internal/parsers/protocols/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ func Get(ctx *config.Context, protocol string) (*Specific, error) {
"ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK",
"PtLimaPtLMwfNinJi9rCfDPWea8dFgTZ1MeJ9f1m2SRic6ayiwW",
"PtMumbaiiFFEGbew1rRjzSPyzRbA51Tm3RVZL5suHPxSZYDhCEc",
"PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1":
"PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1",
"PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf":
return &Specific{
StorageParser: storage.NewLazyBabylon(ctx.BigMapDiffs, ctx.Operations, ctx.Accounts),
ContractParser: contract.NewJakarta(ctx),
Expand Down Expand Up @@ -127,7 +128,8 @@ func NeedImplicitParsing(protocol string) bool {
"ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK",
"PtLimaPtLMwfNinJi9rCfDPWea8dFgTZ1MeJ9f1m2SRic6ayiwW",
"PtMumbaiiFFEGbew1rRjzSPyzRbA51Tm3RVZL5suHPxSZYDhCEc",
"PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1":
"PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1",
"PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf":
return true
}
return false
Expand Down

0 comments on commit 2fa96e8

Please sign in to comment.