Skip to content

Commit

Permalink
chore: initial taqueria-2 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
GImbrailo committed Jan 5, 2023
1 parent 8b11ebf commit bc897dc
Show file tree
Hide file tree
Showing 191 changed files with 17,590 additions and 1,541 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dockerhub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Dockerhub
on:
push:
branches:
- 'taqueria'
- 'taqueria-2'

jobs:
push_to_registry:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ghcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ name: Build
on:
push:
branches:
- 'taqueria'
- 'taqueria-2'
tags:
- 'v*.*.*'
pull_request:
branches:
- 'taqueria'
- 'taqueria-2'

jobs:
build:
Expand Down
40 changes: 20 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ init:
docker-compose exec -T db createdb -U tzkt -T template0 tzkt_db
docker-compose exec -T db apt update
docker-compose exec -T db apt install -y wget
docker-compose exec -T db wget "https://snapshots.tzkt.io/tzkt_v1.10_mainnet.backup" -O tzkt_db.backup
docker-compose exec -T db wget "https://snapshots.tzkt.io/tzkt_v1.11_mainnet.backup" -O tzkt_db.backup
docker-compose exec -T db pg_restore -U tzkt -O -x -v -d tzkt_db -e -j 4 tzkt_db.backup
docker-compose exec -T db rm tzkt_db.backup
docker-compose exec -T db apt autoremove --purge -y wget
Expand Down Expand Up @@ -52,7 +52,7 @@ ghost-init:
docker-compose -f docker-compose.ghost.yml exec -T ghost-db createdb -U tzkt -T template0 tzkt_db
docker-compose -f docker-compose.ghost.yml exec -T ghost-db apt update
docker-compose -f docker-compose.ghost.yml exec -T ghost-db apt install -y wget
docker-compose -f docker-compose.ghost.yml exec -T ghost-db wget "https://snapshots.tzkt.io/tzkt_v1.10_ghostnet.backup" -O tzkt_db.backup
docker-compose -f docker-compose.ghost.yml exec -T ghost-db wget "https://snapshots.tzkt.io/tzkt_v1.11_ghostnet.backup" -O tzkt_db.backup
docker-compose -f docker-compose.ghost.yml exec -T ghost-db pg_restore -U tzkt -O -x -v -d tzkt_db -e -j 4 tzkt_db.backup
docker-compose -f docker-compose.ghost.yml exec -T ghost-db rm tzkt_db.backup
docker-compose -f docker-compose.ghost.yml exec -T ghost-db apt autoremove --purge -y wget
Expand All @@ -67,27 +67,27 @@ ghost-stop:
ghost-db-start:
docker-compose -f docker-compose.ghost.yml up -d ghost-db

jakarta-init:
docker-compose -f docker-compose.jakarta.yml up -d jakarta-db
docker-compose -f docker-compose.jakarta.yml exec -T jakarta-db psql -U tzkt postgres -c '\l'
docker-compose -f docker-compose.jakarta.yml exec -T jakarta-db dropdb -U tzkt --if-exists tzkt_db
docker-compose -f docker-compose.jakarta.yml exec -T jakarta-db createdb -U tzkt -T template0 tzkt_db
docker-compose -f docker-compose.jakarta.yml exec -T jakarta-db apt update
docker-compose -f docker-compose.jakarta.yml exec -T jakarta-db apt install -y wget
docker-compose -f docker-compose.jakarta.yml exec -T jakarta-db wget "https://snapshots.tzkt.io/tzkt_v1.10_jakartanet.backup" -O tzkt_db.backup
docker-compose -f docker-compose.jakarta.yml exec -T jakarta-db pg_restore -U tzkt -O -x -v -d tzkt_db -e -j 4 tzkt_db.backup
docker-compose -f docker-compose.jakarta.yml exec -T jakarta-db rm tzkt_db.backup
docker-compose -f docker-compose.jakarta.yml exec -T jakarta-db apt autoremove --purge -y wget
lima-init:
docker-compose -f docker-compose.lima.yml up -d lima-db
docker-compose -f docker-compose.lima.yml exec -T lima-db psql -U tzkt postgres -c '\l'
docker-compose -f docker-compose.lima.yml exec -T lima-db dropdb -U tzkt --if-exists tzkt_db
docker-compose -f docker-compose.lima.yml exec -T lima-db createdb -U tzkt -T template0 tzkt_db
docker-compose -f docker-compose.lima.yml exec -T lima-db apt update
docker-compose -f docker-compose.lima.yml exec -T lima-db apt install -y wget
docker-compose -f docker-compose.lima.yml exec -T lima-db wget "https://snapshots.tzkt.io/tzkt_v1.11_limanet.backup" -O tzkt_db.backup
docker-compose -f docker-compose.lima.yml exec -T lima-db pg_restore -U tzkt -O -x -v -d tzkt_db -e -j 4 tzkt_db.backup
docker-compose -f docker-compose.lima.yml exec -T lima-db rm tzkt_db.backup
docker-compose -f docker-compose.lima.yml exec -T lima-db apt autoremove --purge -y wget
docker-compose pull

jakarta-start:
docker-compose -f docker-compose.jakarta.yml up -d
lima-start:
docker-compose -f docker-compose.lima.yml up -d

jakarta-stop:
docker-compose -f docker-compose.jakarta.yml down
lima-stop:
docker-compose -f docker-compose.lima.yml down

jakarta-db-start:
docker-compose -f docker-compose.jakarta.yml up -d jakarta-db
lima-db-start:
docker-compose -f docker-compose.lima.yml up -d lima-db

kathmandu-init:
docker-compose -f docker-compose.kathmandu.yml up -d kathmandu-db
Expand All @@ -96,7 +96,7 @@ kathmandu-init:
docker-compose -f docker-compose.kathmandu.yml exec -T kathmandu-db createdb -U tzkt -T template0 tzkt_db
docker-compose -f docker-compose.kathmandu.yml exec -T kathmandu-db apt update
docker-compose -f docker-compose.kathmandu.yml exec -T kathmandu-db apt install -y wget
docker-compose -f docker-compose.kathmandu.yml exec -T kathmandu-db wget "https://snapshots.tzkt.io/tzkt_v1.10_kathmandunet.backup" -O tzkt_db.backup
docker-compose -f docker-compose.kathmandu.yml exec -T kathmandu-db wget "https://snapshots.tzkt.io/tzkt_v1.11_kathmandunet.backup" -O tzkt_db.backup
docker-compose -f docker-compose.kathmandu.yml exec -T kathmandu-db pg_restore -U tzkt -O -x -v -d tzkt_db -e -j 4 tzkt_db.backup
docker-compose -f docker-compose.kathmandu.yml exec -T kathmandu-db rm tzkt_db.backup
docker-compose -f docker-compose.kathmandu.yml exec -T kathmandu-db apt autoremove --purge -y wget
Expand Down
49 changes: 24 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ make stop

## Installation (from source)

This is the preferred way, because you have more control over each TzKT component (database, indexer, API). This guide is for Ubuntu 20.04, but if you are using a different OS, the installation process will probably differ only in the "Install packages" step.
This is the preferred way, because you have more control over each TzKT component (database, indexer, API). This guide is for Ubuntu 22.04, but if you are using a different OS, the installation process will probably differ only in the "Install packages" step.

### Install packages

Expand All @@ -50,25 +50,22 @@ sudo apt update
sudo apt install git
````

#### Install .NET 5.0 SDK
#### Install .NET

````
wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt update
sudo apt install -y apt-transport-https
sudo apt update
sudo apt install -y dotnet-sdk-5.0
sudo apt install -y dotnet-sdk-7.0
````

#### Install Postgresql 13
#### Install Postgresql

````
wget -q -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
sudo apt update
sudo apt -y install postgresql-13 postgresql-client-13
sudo apt -y install postgresql postgresql-contrib
````

## Install Tzkt Indexer and API for mainnet
Expand All @@ -89,7 +86,7 @@ postgres=# \q
#### Download fresh snapshot

````c
wget "https://snapshots.tzkt.io/tzkt_v1.10_mainnet.backup" -O /tmp/tzkt_db.backup
wget "https://snapshots.tzkt.io/tzkt_v1.11_mainnet.backup" -O /tmp/tzkt_db.backup
````

#### Restore database from the snapshot
Expand Down Expand Up @@ -131,30 +128,30 @@ Like this:
"Diagnostics": false,
"Validation": true
},

"TezosNode": {
"Endpoint": "https://rpc.tzkt.io/mainnet/",
"Timeout": 60
},

"Quotes": {
"Async": true,
"Provider": {
"Name": "TzktQuotes"
}
},

"ConnectionStrings": {
"DefaultConnection": "host=localhost;port=5432;database=tzkt_db;username=tzkt;password=qwerty;command timeout=600;"
},

"HealthChecks": {
"Enabled": true,
"Delay": 10,
"Period": 10,
"FilePath": "sync.health"
},

"Domains": {
"Enabled": false,
"NameRegistry": "KT1GBZmSxmnKJXGMdMLbugPfLyUPmuLSMwKS",
"PeriodSec": 30
},
"TokenMetadata": {
"Enabled": false,
"BatchSize": 100,
Expand All @@ -177,7 +174,6 @@ Like this:
}
]
},

"Logging": {
"LogLevel": {
"Default": "Information",
Expand Down Expand Up @@ -221,7 +217,7 @@ dotnet Tzkt.Sync.dll
// ....
````

That's it. If you want to run the indexer as a daemon, take a look at this guide: https://docs.microsoft.com/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-3.1#create-the-service-file.
That's it. If you want to run the indexer as a daemon, take a look at this guide: https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-7.0#create-the-service-file.

### Build, configure and run Tzkt API for the mainnet indexer

Expand All @@ -245,17 +241,20 @@ Like this:
"Cache": {
"LoadRate": 0.75,
"MaxAccounts": 32000
},
"ResponseCache": {
"CacheSize": 256
},

"Websocket": {
"Enabled": true,
"MaxConnections": 1000,
"MaxOperationSubscriptions": 50,
"MaxBigMapSubscriptions": 50,
"MaxEventSubscriptions": 50,
"MaxAccountsSubscriptions": 50,
"MaxTokenBalancesSubscriptions": 50,
"MaxTokenTransfersSubscriptions": 50
},

"ConnectionStrings": {
"DefaultConnection": "host=localhost;port=5432;database=tzkt_db;username=tzkt;password=qwerty;command timeout=600;"
},
Expand Down Expand Up @@ -321,14 +320,14 @@ That's it. By default API is available on ports 5000 (HTTP) and 5001 (HTTPS). If

In general the steps are the same as for the mainnet, you just need to use different RPC endpoint and DB snapshot. Here are some presets for testnets:
- Ghostnet:
- Snapshot: https://snapshots.tzkt.io/tzkt_v1.10_ghostnet.backup
- Snapshot: https://snapshots.tzkt.io/tzkt_v1.11_ghostnet.backup
- RPC node: https://rpc.tzkt.io/ghostnet/
- Jakartanet:
- Snapshot: https://snapshots.tzkt.io/tzkt_v1.10_jakartanet.backup
- RPC node: https://rpc.tzkt.io/jakartanet/
- Kathmandunet:
- Snapshot: https://snapshots.tzkt.io/tzkt_v1.10_kathmandunet.backup
- Snapshot: https://snapshots.tzkt.io/tzkt_v1.11_kathmandunet.backup
- RPC node: https://rpc.tzkt.io/kathmandunet/
- Limanet:
- Snapshot: https://snapshots.tzkt.io/tzkt_v1.11_limanet.backup
- RPC node: https://rpc.tzkt.io/limanet/

### Testnet installation using docker containers

Expand Down
6 changes: 3 additions & 3 deletions Tzkt.Api.Tests/Auth/AuthServiceTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using Netezos.Encoding;
using Netezos.Keys;
using Netezos.Utils;
Expand Down
13 changes: 6 additions & 7 deletions Tzkt.Api.Tests/Tzkt.Api.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>

<LangVersion>10</LangVersion>
<AssemblyVersion>1.11.0</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<PackageReference Include="coverlet.collector" Version="3.2.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
26 changes: 14 additions & 12 deletions Tzkt.Api/Controllers/AccountsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public AccountsController(AccountRepository accounts, BalanceHistoryRepository h
/// Returns a list of accounts.
/// </remarks>
/// <param name="id">Filters by internal id.</param>
/// <param name="address">Filters by address.</param>
/// <param name="type">Filters accounts by type (`user`, `delegate`, `contract`, `ghost`).</param>
/// <param name="kind">Filters accounts by contract kind (`delegator_contract` or `smart_contract`)</param>
/// <param name="delegate">Filters accounts by delegate. Allowed fields for `.eqx` mode: none.</param>
Expand All @@ -53,6 +54,7 @@ public AccountsController(AccountRepository accounts, BalanceHistoryRepository h
[HttpGet]
public async Task<ActionResult<IEnumerable<Account>>> Get(
Int32Parameter id,
AddressParameter address,
AccountTypeParameter type,
ContractKindParameter kind,
AccountParameter @delegate,
Expand Down Expand Up @@ -87,7 +89,7 @@ public async Task<ActionResult<IEnumerable<Account>>> Get(
#endregion

var query = ResponseCacheService.BuildKey(Request.Path.Value,
("id", id), ("type", type), ("kind", kind), ("delegate", @delegate), ("balance", balance), ("staked", staked),
("id", id), ("address", address), ("type", type), ("kind", kind), ("delegate", @delegate), ("balance", balance), ("staked", staked),
("lastActivity", lastActivity), ("select", select), ("sort", sort), ("offset", offset), ("limit", limit));

if (ResponseCache.TryGet(query, out var cached))
Expand All @@ -96,25 +98,25 @@ public async Task<ActionResult<IEnumerable<Account>>> Get(
object res;
if (select == null)
{
res = await Accounts.Get(id, type, kind, @delegate, balance, staked, lastActivity, sort, offset, limit);
res = await Accounts.Get(id, address, type, kind, @delegate, balance, staked, lastActivity, sort, offset, limit);
}
else if (select.Values != null)
{
if (select.Values.Length == 1)
res = await Accounts.Get(id, type, kind, @delegate, balance, staked, lastActivity, sort, offset, limit, select.Values[0]);
res = await Accounts.Get(id, address, type, kind, @delegate, balance, staked, lastActivity, sort, offset, limit, select.Values[0]);
else
res = await Accounts.Get(id, type, kind, @delegate, balance, staked, lastActivity, sort, offset, limit, select.Values);
res = await Accounts.Get(id, address, type, kind, @delegate, balance, staked, lastActivity, sort, offset, limit, select.Values);
}
else
{
if (select.Fields.Length == 1)
res = await Accounts.Get(id, type, kind, @delegate, balance, staked, lastActivity, sort, offset, limit, select.Fields[0]);
res = await Accounts.Get(id, address, type, kind, @delegate, balance, staked, lastActivity, sort, offset, limit, select.Fields[0]);
else
{
res = new SelectionResponse
{
Cols = select.Fields,
Rows = await Accounts.Get(id, type, kind, @delegate, balance, staked, lastActivity, sort, offset, limit, select.Fields)
Rows = await Accounts.Get(id, address, type, kind, @delegate, balance, staked, lastActivity, sort, offset, limit, select.Fields)
};
}
}
Expand Down Expand Up @@ -276,9 +278,9 @@ public async Task<ActionResult<IEnumerable<Delegator>>> GetDelegators(
/// <param name="address">Account address (starting with tz or KT)</param>
/// <param name="type">Comma separated list of operation types to return (`endorsement`, `preendorsement`, `ballot`, `proposal`, `activation`, `double_baking`,
/// `double_endorsing`, `double_preendorsing`, `nonce_revelation`, `vdf_revelation`, `delegation`, `origination`, `transaction`, `reveal`, `register_constant`,
/// `set_deposits_limit`, `increase_paid_storage`, 'tx_rollup_origination', 'tx_rollup_submit_batch', 'tx_rollup_commit', 'tx_rollup_return_bond',
/// 'tx_rollup_finalize_commitment', 'tx_rollup_remove_commitment', 'tx_rollup_rejection', 'tx_rollup_dispatch_tickets', 'transfer_ticket', `migration`,
/// `revelation_penalty`, `baking`, `endorsing_reward`). If not specified then the default set will be returned.</param>
/// `set_deposits_limit`, `increase_paid_storage`, `tx_rollup_origination`, `tx_rollup_submit_batch`, `tx_rollup_commit`, `tx_rollup_return_bond`,
/// `tx_rollup_finalize_commitment`, `tx_rollup_remove_commitment`, `tx_rollup_rejection`, `tx_rollup_dispatch_tickets`, `transfer_ticket`, `migration`,
/// `update_consensus_key`, `drain_delegate`, `revelation_penalty`, `baking`, `endorsing_reward`). If not specified then the default set will be returned.</param>
/// <param name="initiator">Filters transactions, delegations and originations by initiator. Allowed fields for `.eqx` mode: none.</param>
/// <param name="sender">Filters transactions, delegations, originations, reveals and seed nonce revelations by sender. Allowed fields for `.eqx` mode: none.</param>
/// <param name="target">Filters transactions by target. Allowed fields for `.eqx` mode: none.</param>
Expand Down Expand Up @@ -566,7 +568,7 @@ public async Task<ActionResult<long>> GetBalanceAtDate(
if (ResponseCache.TryGet(query, out var cached))
return this.Bytes(cached);

var res = await History.Get(address, datetime.DateTime);
var res = await History.Get(address, datetime.UtcDateTime);
cached = ResponseCache.Set(query, res);
return this.Bytes(cached);
}
Expand Down Expand Up @@ -704,8 +706,8 @@ public async Task<ActionResult> GetBalanceReport(
};
#endregion

var _from = from?.DateTime ?? DateTime.MinValue;
var _to = to?.DateTime ?? DateTime.MaxValue;
var _from = (from ?? DateTimeOffset.MinValue).UtcDateTime;
var _to = (to ?? DateTimeOffset.MaxValue).UtcDateTime;

var stream = new MemoryStream();
var csv = new StreamWriter(stream);
Expand Down
4 changes: 2 additions & 2 deletions Tzkt.Api/Controllers/BlocksController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public Task<Block> GetByDate(
MichelineFormat micheline = MichelineFormat.Json,
Symbols quote = Symbols.None)
{
var level = Time.FindLevel(timestamp.DateTime, SearchMode.ExactOrLower);
var level = Time.FindLevel(timestamp.UtcDateTime, SearchMode.ExactOrLower);
return Blocks.Get(level, operations, micheline, quote);
}

Expand All @@ -233,7 +233,7 @@ public Task<Block> GetByDate(
[HttpGet("{timestamp:DateTime}/level")]
public int GetByDate(DateTimeOffset timestamp)
{
return Time.FindLevel(timestamp.DateTime, SearchMode.ExactOrLower);
return Time.FindLevel(timestamp.UtcDateTime, SearchMode.ExactOrLower);
}

// BCD bootstrap
Expand Down
Loading

0 comments on commit bc897dc

Please sign in to comment.