Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.4.1 #37

Merged
merged 37 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
6b7a034
[abi] telemint: add ownership_assigned message with bid info
iam047801 Apr 12, 2024
8164c82
[parser] ability to parse both messages with the same operation id
iam047801 Apr 12, 2024
2b18e09
[abi] known: remove seqno method from highload_v2r2 wallet
iam047801 Apr 12, 2024
2d72a92
[abi/known] getgems: add fixed sale v3r3 contract
iam047801 Apr 15, 2024
e41d982
[abi/known] getgems fix price v3r3: fix get_fix_price_data method
iam047801 Apr 15, 2024
77f1fa8
[abi] add json schema
iam047801 Apr 24, 2024
8c93da9
[abi/known] stonfi: add contracts
iam047801 Apr 24, 2024
1260ece
[core] AccountState: remove omitempty from fake flag
iam047801 Apr 24, 2024
165addf
[abi/known] stonfi: add router address
iam047801 Apr 25, 2024
18853f0
[abi/known] stonfi: fix ref_address format in dex_payload_swap
iam047801 Apr 25, 2024
7be0dbd
[indexer] insertData: sort messages
iam047801 Apr 25, 2024
4d0b372
[parser] check validity of dedust and stonfi pools
iam047801 Apr 25, 2024
9c3b313
migrate to tonutils-go v1.9.5
iam047801 Apr 25, 2024
8dd139e
[abi/known] stonfi: add admin messages to router
iam047801 Apr 27, 2024
564a0d4
[parser] callPossibleGetMethods: check that dedust pool or stonfi poo…
iam047801 Apr 28, 2024
911ab3a
[repo] account.GetAllAccountStates: fix limitation
iam047801 Apr 28, 2024
5920a0c
README.md: add link to the telegram chat
iam047801 May 6, 2024
291b070
[core] remove raw account code and data from db tables, save it into …
iam047801 May 7, 2024
42a8763
[migrations] account states code data kv storage: fix empty query error
iam047801 May 7, 2024
f22a940
[repo] account.getCodeData: check hash length
iam047801 May 7, 2024
07cd3e7
[cmd] migrate: add subcommand for account states code and data migrat…
iam047801 May 8, 2024
9664896
[cmd] migrate.transferCodeData: remove 3 sec timeout
iam047801 May 8, 2024
33d1746
[repo] accounts filter: getCodeData in batches
iam047801 May 8, 2024
e9f0840
[repo] migrate.transferCodeData: check code and data length
iam047801 May 8, 2024
7b99199
[rescan] GetAllAccountStates: fix ordered lru fill, get code and data…
iam047801 May 9, 2024
c4559cd
[parser] callPossibleGetMethods: panic on GetMethodDescription error
iam047801 May 9, 2024
3087064
[migrations] code data kv storage: split queries
iam047801 May 9, 2024
e753a5d
[cmd] migrate: add command for removing code and data from postgresql…
iam047801 May 9, 2024
7122f67
[migrations] code data kv storage: fix insertion of data from old col…
iam047801 May 10, 2024
76ba89e
[cmd] indexer: insert known contract interfaces on the initial startup
iam047801 May 10, 2024
80a9b17
[app] indexer: remove panic on a message without source during the in…
iam047801 May 10, 2024
efdbbda
[migrations] fix pg empty query error
iam047801 May 10, 2024
f9db913
README.md: fix startup description
iam047801 May 10, 2024
99ace87
[app] parser: simplify callPossibleGetMethods
iam047801 May 10, 2024
64a5b32
[app] indexer: separate getMessageSource function
iam047801 May 10, 2024
f8c256d
[repo] account: fix filter tests, add nolint for getCodeData
iam047801 May 10, 2024
384bf40
[repo] account: add gocyclo nolint for getCodeData
iam047801 May 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Anton

This project is an open-source tool that extracts and organizes data from the TON blockchain,
efficiently storing it in PostgreSQL and ClickHouse databases.
efficiently storing it in PostgreSQL and ClickHouse databases.

If you have any questions, you can ask them in the [Telegram group](https://t.me/tonindexer_chat).

## Overview

Expand Down Expand Up @@ -157,10 +159,18 @@ docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d
```

To run Anton, you need at least one defined contract interface.
There are some known interfaces in the [abi/known](/abi/known) directory.
You can add them through this command:
You can find some known interfaces in the [abi/known](/abi/known) directory.
These can be added during the initial startup of the indexer:

```shell
docker compose exec rescan sh -c "anton contract addInterfaces /var/anton/known/*.json"
# If you are running the indexer without Docker,
# you need to specify the directory containing the known contracts:
anton indexer --contract-dir /root/anton/abi/known

# If you are running it using Docker,
# there is no need to specify the contracts directory,
# as they are already included in the container:
docker compose up -d indexer
```

### Database schema migration
Expand Down
245 changes: 245 additions & 0 deletions abi/abi.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://tvm.sh/abi.schema.json",
"type": "array",
"items": {
"type": "object",
"properties": {
"interface_name": {
"type": "string",
"pattern": "^([a-z0-9_]+)$"
},
"addresses": {
"type": "array",
"items": {
"type": "string"
}
},
"definitions": {
"type": "object",
"patternProperties": {
"^([a-z0-9_]+)\\.([a-z0-9_]+)\\.([a-z0-9_]+)$": {
"type": "array",
"items": {
"$ref": "#/$defs/tlb_value"
}
}
}
},
"code_boc": {
"type": "string"
},
"get_methods": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"arguments": {
"type": "array",
"items": {
"$ref": "#/$defs/vm_value"
}
},
"return_values": {
"type": "array",
"items": {
"$ref": "#/$defs/vm_value"
}
}
},
"required": [
"name",
"return_values"
],
"additionalProperties": false
}
},
"in_messages": {
"type": "array",
"items": {
"$ref": "#/$defs/message"
}
},
"out_messages": {
"type": "array",
"items": {
"$ref": "#/$defs/message"
}
}
},
"required": [
"interface_name"
],
"additionalProperties": false
},
"$defs": {
"vm_value": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"stack_type": {
"enum": [
"int",
"cell",
"slice"
]
},
"format": {
"enum": [
"bigInt",
"uint8",
"uint16",
"uint32",
"uint64",
"int8",
"int16",
"int32",
"int64",
"bool",
"bytes",
"cell",
"slice",
"string",
"addr",
"content",
"struct",
"asset",
"dedustAsset"
]
},
"struct_fields": {
"type": "array",
"items": {
"$ref": "#/$defs/tlb_value"
}
}
},
"required": [
"name",
"stack_type"
]
},
"tlb_value": {
"type": "object",
"properties": {
"name": {
"type": "string",
"pattern": "^[a-z0-9_]+$"
},
"tlb_type": {
"oneOf": [
{
"enum": [
".",
"^",
"bool",
"addr"
]
},
{
"type": "string",
"pattern": "^#[a-f0-9]+$"
},
{
"type": "string",
"pattern": "^\\[[^\\]]+\\]$"
},
{
"type": "string",
"pattern": "^\\$[01]+$"
},
{
"type": "string",
"pattern": "^(##|bits) \\d{1,3}$"
},
{
"type": "string",
"pattern": "^maybe (\\^)$"
},
{
"type": "string",
"pattern": "^either ([\\^.]) ([\\^.])$"
}
]
},
"format": {
"enum": [
"bool",
"int8",
"int16",
"int32",
"int64",
"uint8",
"uint16",
"uint32",
"uint64",
"bigInt",
"coins",
"bytes",
"string",
"addr",
"cell",
"dict",
"tag",
"telemintText",
"asset",
"struct",
"dedustAsset"
]
},
"struct_fields": {
"type": "array",
"items": {
"$ref": "#/$defs/tlb_value"
}
},
"optional": {
"type": "boolean"
}
},
"required": [
"name",
"tlb_type"
],
"additionalProperties": false
},
"message": {
"type": "object",
"properties": {
"op_name": {
"type": "string"
},
"op_code": {
"type": "string",
"pattern": "^0x([0-9a-f]{1,8})$"
},
"type": {
"enum": [
"INTERNAL",
"EXTERNAL_IN",
"EXTERNAL_OUT",
"internal",
"external_in",
"external_out"
]
},
"body": {
"type": "array",
"items": {
"$ref": "#/$defs/tlb_value"
}
}
},
"required": [
"op_name",
"op_code"
],
"additionalProperties": false
}
}
}
20 changes: 15 additions & 5 deletions abi/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,15 @@ func HasGetMethod(code *cell.Cell, getMethodName string) bool {
return false
}

if dict.GetByIntKey(big.NewInt(hash)) != nil {
return true
s, err := dict.LoadValueByIntKey(big.NewInt(hash))
if err != nil {
return false
}
if _, err := s.ToCell(); err != nil {
return false
}
return false

return true
}

func GetMethodHashes(code *cell.Cell) ([]int32, error) {
Expand All @@ -96,8 +101,13 @@ func GetMethodHashes(code *cell.Cell) ([]int32, error) {
return nil, errors.Wrap(err, "get methods dict")
}

for _, kv := range dict.All() {
i, err := kv.Key.BeginParse().LoadUInt(getMethodsDictKeySz)
dictKV, err := dict.LoadAll()
if err != nil {
return nil, errors.Wrapf(err, "dict load all")
}

for _, kv := range dictKV {
i, err := kv.Key.LoadUInt(getMethodsDictKeySz)
if err != nil {
return nil, errors.Wrap(err, "load uint")
}
Expand Down
27 changes: 24 additions & 3 deletions abi/get_emulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ func vmMakeValueInt(v *VmValue) (ret tlb.VmStackValue, _ error) {
case "int64":
ui, uok := v.Payload.(int64)
bi, ok = big.NewInt(ui), uok
case "bool":
b, uok := v.Payload.(bool)
ui := 0
if b {
ui = 1
}
bi, ok = big.NewInt(int64(ui)), uok
case "bytes":
ui, uok := v.Payload.([]byte)
bi, ok = new(big.Int).SetBytes(ui), uok
Expand Down Expand Up @@ -162,8 +169,16 @@ func vmMakeValueCell(v *VmValue) (tlb.VmStackValue, error) {
var err error
c, err = tutlb.ToCell(v.Payload)
if err != nil {
return tlb.VmStackValue{}, err
return tlb.VmStackValue{}, errors.Wrapf(err, "'%s' argument to cell", v.Name)
}
ok = true
default:
var err error
c, err = tutlb.ToCell(v.Payload)
if err != nil {
return tlb.VmStackValue{}, errors.Wrapf(err, "'%s' argument to cell with '%s' format", v.Name, v.Format)
}
ok = true
}
if !ok {
return tlb.VmStackValue{}, errors.Wrapf(ErrWrongValueFormat, "'%s' type with '%s' format", v.StackType, v.Format)
Expand Down Expand Up @@ -210,9 +225,15 @@ func vmMakeValueSlice(v *VmValue) (tlb.VmStackValue, error) {
case TLBStructCell:
c, err := tutlb.ToCell(v.Payload)
if err != nil {
return tlb.VmStackValue{}, err
return tlb.VmStackValue{}, errors.Wrapf(err, "'%s' argument to cell", v.Name)
}
s, ok = c.BeginParse(), true
default:
c, err := tutlb.ToCell(v.Payload)
if err != nil {
return tlb.VmStackValue{}, errors.Wrapf(err, "'%s' argument to cell with '%s' format", v.Name, v.Format)
}
s = c.BeginParse()
s, ok = c.BeginParse(), true
}
if !ok {
return tlb.VmStackValue{}, errors.Wrapf(ErrWrongValueFormat, "'%s' type with '%s' format", v.StackType, v.Format)
Expand Down
Loading
Loading