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

v1.9 #173

Merged
merged 92 commits into from
Mar 18, 2024
Merged

v1.9 #173

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
8eebb08
Better LS connection pool balancer
xssnick Oct 12, 2023
ec14b0d
tlb: register type with custom name
iam047801 Oct 13, 2023
4f085f4
Merge pull request #136 from iam047801/tlb-register-with-name
xssnick Oct 13, 2023
5d66868
tlb: load dictionary into the map
iam047801 Oct 15, 2023
db292e6
tlb: dictionary to cell from the map
iam047801 Oct 15, 2023
8d07daf
Merge branch 'tlb-register-with-name' into dict-to-map
iam047801 Oct 15, 2023
6d3e063
Merge pull request #138 from iam047801/dict-to-map
xssnick Oct 16, 2023
bf36199
TLB Map loader tests adjustments
xssnick Oct 17, 2023
f75303c
Measure matrix size
jokly Oct 23, 2023
5f638ee
Implement matrix GF2 as slice of bytes
jokly Oct 30, 2023
d4ced7e
Use PlainMatrixGF2 in computations
jokly Oct 30, 2023
aedac62
Implement PlainOffsetMatrixGF2
jokly Oct 31, 2023
b28ac00
Use PlainOffsetMatrixGF2 in computations
jokly Oct 31, 2023
20baa14
PlainOffsetMatrixGF2 store data in one dimension slice
jokly Nov 1, 2023
37320fb
Refactor
jokly Nov 1, 2023
997ec3b
Merge pull request #141 from jokly/matrix-gf2
xssnick Nov 1, 2023
1e22488
Get next node on update
jokly Nov 7, 2023
56ae7bb
Merge pull request #144 from jokly/fix-find-value
xssnick Nov 13, 2023
46204ba
JSON unmarshal of Address
jokly Nov 22, 2023
f463181
JSON unmarshal of Coins
jokly Nov 22, 2023
5efcdc2
Merge pull request #145 from jokly/unmarshal-json
xssnick Nov 22, 2023
5acd2f0
Better TL-B Either serialization logic & fixed transaction interface …
xssnick Nov 28, 2023
df992fc
Octet AddMul optimization
andreypfau Nov 28, 2023
2518be1
Merge branch 'dev-v19' into add_mul_optimizations
andreypfau Nov 28, 2023
70ce427
Merge pull request #147 from andreypfau/add_mul_optimizations
xssnick Nov 28, 2023
3141054
Heavy add/mul/addmul optimizations
andreypfau Nov 29, 2023
bd4f1f4
Merge pull request #148 from andreypfau/oct_neon
xssnick Nov 29, 2023
17dded5
DHT weight logic changed to distance
xssnick Dec 1, 2023
8c9f56e
Fix address unmarshal JSON
jokly Dec 2, 2023
e971922
dht-v2
andreypfau Dec 3, 2023
39872ea
Fixed no active connections panic in liteclient
xssnick Dec 4, 2023
418f059
Cell index serialization improved to visit only unique cells
xssnick Dec 4, 2023
9687272
Marshal Ext and Var addresses to hex
jokly Dec 5, 2023
6b8e36a
Merge pull request #150 from jokly/fix-address-json
xssnick Dec 5, 2023
a055e4c
Merge branch 'dev-v19' into master-repair
xssnick Dec 5, 2023
c884d70
Merge pull request #154 from xssnick/master-repair
xssnick Dec 5, 2023
4750e9a
Fixed panic in SubscribeOnTransactions method
pr0n1x Nov 28, 2023
45e5514
Cell index serialization improved to visit only unique cells
xssnick Dec 4, 2023
8afbbcf
Fixed no active connections panic in liteclient
xssnick Dec 7, 2023
e34f8df
Updated coverage badge
Dec 4, 2023
c88e233
DHT weight logic changed to distance
xssnick Dec 1, 2023
b580276
Fix address unmarshal JSON
jokly Dec 2, 2023
a5e33a1
Marshal Ext and Var addresses to hex
jokly Dec 5, 2023
4a54c9c
Parallel DHT FindValue
xssnick Dec 7, 2023
728bc1a
Merge branch 'dev-v19' into andreypfau-dht-v2
xssnick Dec 7, 2023
6860e0c
Merge pull request #158 from xssnick/andreypfau-dht-v2
xssnick Dec 7, 2023
a402511
Merge pull request #159 from xssnick/master
xssnick Dec 7, 2023
6864fad
Better DHT node status control
xssnick Dec 8, 2023
ad1977b
Add timeout lite client
jokly Dec 12, 2023
456aeca
Refactor retry client
jokly Dec 12, 2023
ea5824f
Merge pull request #161 from jokly/timeout-liteclient
xssnick Dec 12, 2023
7c2cc26
Bump golang.org/x/crypto
dependabot[bot] Dec 18, 2023
aa2fce3
Merge pull request #162 from xssnick/dependabot/go_modules/golang.org…
xssnick Dec 21, 2023
caafa16
Fixed potential DHT memory leak
xssnick Dec 30, 2023
4694873
Bump tj-actions/verify-changed-files in /.github/workflows
dependabot[bot] Jan 2, 2024
20aa120
Merge pull request #163 from xssnick/dependabot/github_actions/dot-gi…
xssnick Jan 3, 2024
7addb28
feat: cell depth getter
krigga Jan 4, 2024
fe21b32
Merge pull request #164 from krigga/cell-depth-getter
xssnick Jan 6, 2024
dc56809
Update retrier.go
logvik Jan 10, 2024
1ba635a
Merge pull request #165 from logvik/patch-1
xssnick Jan 11, 2024
e1c7abf
Better ADNL UDP packet resend & DHT list length tunning
xssnick Jan 11, 2024
4f28a5a
Fixed DHT Store and priority list building
xssnick Jan 11, 2024
c9e88e9
Fixed block header proof parse with pruned after merge part & minor f…
xssnick Jan 12, 2024
e61f229
Cell hashes precalc
xssnick Jan 24, 2024
287eff1
Recalc hashes after UnsafeModify
xssnick Jan 25, 2024
86af89e
Fixed DHT affinity calculation
xssnick Jan 25, 2024
e63b82c
Dict reimplemented to ondemand parsing
xssnick Feb 1, 2024
98a23b6
Coins Nano bigint copy
xssnick Feb 4, 2024
a28d6e0
Fixed empty dict find value panic
xssnick Feb 4, 2024
a6437ee
Bump tj-actions/verify-changed-files in /.github/workflows
dependabot[bot] Feb 13, 2024
7f5e3a6
Merge pull request #171 from xssnick/dependabot/github_actions/dot-gi…
xssnick Feb 13, 2024
5629f87
ADNL TCP Server & optimizations
xssnick Feb 14, 2024
bc91382
Proof builder & Multi-level proofs & Dict proofs & Added new LS Types
xssnick Feb 20, 2024
0fec25b
Dict LoadValueWithProof
xssnick Feb 20, 2024
9f517fa
Fixed adnl tcp client ip of server
xssnick Feb 21, 2024
f597f66
Proof sceleton SetRecursive method
xssnick Feb 21, 2024
e22b86d
Connection hooks of server changed
xssnick Feb 22, 2024
aae3cd5
Liteserver added client port
xssnick Feb 22, 2024
dd67285
Fixed port in liteserver
xssnick Feb 22, 2024
16c9f09
Fixed init c7 run method parse
xssnick Feb 22, 2024
44e0e7b
RunMethodResult optional result support
xssnick Feb 22, 2024
a4c472a
Stack tuple serialization support
xssnick Feb 24, 2024
d62c903
Block payload as raw bytes
xssnick Feb 28, 2024
f245242
Block header raw data proof
xssnick Feb 28, 2024
5d22810
Fixed GetBlockHeader tl struct fields order
xssnick Feb 28, 2024
95e33e7
Fixed multi-root index parsing from boc
xssnick Mar 4, 2024
334b66b
Optional Transactions cell in BlockTransactionsExt
xssnick Mar 5, 2024
195c218
Fixed backward proofs validation after boc deserialization change
xssnick Mar 15, 2024
0ea2a6b
Minor coverage increase
xssnick Mar 18, 2024
9197039
No cache for TestAPIClient_WithRetry test
xssnick Mar 18, 2024
99e59c1
Merge 919703925740367bc04277a70fe957294e2f2bbd into 9893120b71d1ddca3…
xssnick Mar 18, 2024
8f955e0
Updated coverage badge
Mar 18, 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
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
filename: coverage.out

- name: Verify Changed files
uses: tj-actions/verify-changed-files@v9.1
uses: tj-actions/verify-changed-files@v17
id: verify-changed-files
with:
files: README.md
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<img align="right" width="425px" src="https://github.com/xssnick/props/blob/master/logoimg.png?raw=true">

[![Based on TON][ton-svg]][ton]
![Coverage](https://img.shields.io/badge/Coverage-73.3%25-brightgreen)
![Coverage](https://img.shields.io/badge/Coverage-74.3%25-brightgreen)

Golang library for interacting with TON blockchain.

Expand Down
76 changes: 73 additions & 3 deletions address/addr.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package address
import (
"encoding/base64"
"encoding/binary"
"encoding/hex"
"errors"
"fmt"

Expand Down Expand Up @@ -93,10 +94,22 @@ func (a *Address) String() string {
binary.BigEndian.PutUint16(address[34:], crc16.Checksum(address[:34], crcTable))
return base64.RawURLEncoding.EncodeToString(address[:])
case ExtAddress:
// TODO support readable serialization
return "EXT_ADDRESS"
address := make([]byte, 1+4+len(a.data))

address[0] = a.FlagsToByte()
binary.BigEndian.PutUint32(address[1:], uint32(a.bitsLen))
copy(address[5:], a.data)

return fmt.Sprintf("EXT:%s", hex.EncodeToString(address))
case VarAddress:
return "VAR_ADDRESS"
address := make([]byte, 1+4+4+len(a.data))

address[0] = a.FlagsToByte()
binary.BigEndian.PutUint32(address[1:], uint32(a.workchain))
binary.BigEndian.PutUint32(address[5:], uint32(a.bitsLen))
copy(address[9:], a.data)

return fmt.Sprintf("VAR:%s", hex.EncodeToString(address))
default:
return "NOT_SUPPORTED"
}
Expand Down Expand Up @@ -128,6 +141,63 @@ func (a *Address) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf("%q", a.String())), nil
}

func (a *Address) UnmarshalJSON(data []byte) error {
if len(data) < 2 || data[0] != '"' || data[len(data)-1] != '"' {
return fmt.Errorf("invalid data")
}

data = data[1 : len(data)-1]
strData := string(data)

var (
addr *Address
err error
)

if strData == "NONE" {
addr = NewAddressNone()
} else if strData == "NOT_SUPPORTED" {
return fmt.Errorf("not supported address")
} else if len(strData) >= 9 && strData[:4] == "EXT:" {
strData = strData[4:]

b, err := hex.DecodeString(strData)
if err != nil {
return err
}

addr = NewAddressExt(
b[0],
uint(binary.BigEndian.Uint32(b[1:5])),
b[5:],
)

} else if len(strData) >= 13 && strData[:4] == "VAR:" {
strData = strData[4:]

b, err := hex.DecodeString(strData)
if err != nil {
return err
}

addr = NewAddressVar(
b[0],
int32(binary.BigEndian.Uint32(b[1:5])),
uint(binary.BigEndian.Uint32(b[5:9])),
b[9:],
)
} else {
addr, err = ParseAddr(strData)
if err != nil {
return err
}
}

*a = *addr

return nil
}

func MustParseAddr(addr string) *Address {
a, err := ParseAddr(addr)
if err != nil {
Expand Down
226 changes: 226 additions & 0 deletions address/addr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,3 +461,229 @@ func TestParseflags(t *testing.T) {
})
}
}

func TestAddress_MarshalJSON(t *testing.T) {
tests := []struct {
name string
address *Address
want string
wantErr bool
}{
{
name: "none",
address: NewAddressNone(),
want: "\"NONE\"",
wantErr: false,
},
{
name: "std address",
address: MustParseAddr("EQCTDVUzmAq6EfzYGEWpVOv16yo-H5Vw3B0rktcidz_ULOUj"),
want: "\"EQCTDVUzmAq6EfzYGEWpVOv16yo-H5Vw3B0rktcidz_ULOUj\"",
wantErr: false,
},
{
name: "ext address",
address: &Address{
flags: flags{
bounceable: true,
testnet: false,
},
addrType: ExtAddress,
workchain: 0,
bitsLen: 256,
data: []byte{1, 2, 3},
},
want: "\"EXT:1100000100010203\"",
wantErr: false,
},
{
name: "ext address with empty data",
address: &Address{
flags: flags{
bounceable: true,
testnet: false,
},
addrType: ExtAddress,
workchain: 0,
bitsLen: 256,
data: nil,
},
want: "\"EXT:1100000100\"",
wantErr: false,
},
{
name: "var address",
address: &Address{
flags: flags{
bounceable: true,
testnet: true,
},
addrType: VarAddress,
workchain: -1,
bitsLen: 256,
data: []byte{4, 5, 6},
},
want: "\"VAR:91ffffffff00000100040506\"",
wantErr: false,
},
{
name: "var address with empty data",
address: &Address{
flags: flags{
bounceable: true,
testnet: true,
},
addrType: VarAddress,
workchain: -1,
bitsLen: 256,
data: nil,
},
want: "\"VAR:91ffffffff00000100\"",
wantErr: false,
},
{
name: "not supported type",
address: &Address{addrType: 5},
want: "\"NOT_SUPPORTED\"",
wantErr: false,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := tt.address.MarshalJSON()
if (err != nil) != tt.wantErr {
t.Errorf("MarshalJSON() error = %v, wantErr %v", err, tt.wantErr)
return
}

wantBytes := []byte(tt.want)
if !reflect.DeepEqual(got, wantBytes) {
t.Errorf("MarshalJSON() got = %v, want %v", string(got), tt.want)
}
})
}
}

func TestAddress_UnmarshalJSON(t *testing.T) {
tests := []struct {
name string
address string
want Address
wantErr bool
}{
{
name: "invalid empty",
address: "",
want: Address{},
wantErr: true,
},
{
name: "empty",
address: "\"\"",
want: Address{},
wantErr: true,
},
{
name: "valid",
address: "\"EQC6KV4zs8TJtSZapOrRFmqSkxzpq-oSCoxekQRKElf4nC1I\"",
want: Address{
addrType: StdAddress,
bitsLen: 256,
flags: flags{bounceable: true, testnet: false},
workchain: 0,
data: []byte{186, 41, 94, 51, 179, 196, 201, 181, 38, 90, 164, 234, 209, 22, 106, 146, 147, 28, 233, 171, 234, 18, 10, 140, 94, 145, 4, 74, 18, 87, 248, 156},
},
wantErr: false,
},
{
name: "invalid",
address: "\"AQCTDVUzmAq6EfzYGEWpVOv16yo-H5Vw3B0rktcidz_ULOUj\"",
want: Address{},
wantErr: true,
},
{
name: "none address",
address: "\"NONE\"",
want: Address{
addrType: NoneAddress,
},
wantErr: false,
},
{
name: "ext address",
address: "\"EXT:1100000100010203\"",
want: Address{
flags: flags{
bounceable: true,
testnet: false,
},
addrType: ExtAddress,
workchain: 0,
bitsLen: 256,
data: []byte{1, 2, 3},
},
wantErr: false,
},
{
name: "ext address with empty data",
address: "\"EXT:1100000100\"",
want: Address{
flags: flags{
bounceable: true,
testnet: false,
},
addrType: ExtAddress,
workchain: 0,
bitsLen: 256,
data: []byte{},
},
wantErr: false,
},
{
name: "var address",
address: "\"VAR:91ffffffff00000100040506\"",
want: Address{
flags: flags{
bounceable: true,
testnet: true,
},
addrType: VarAddress,
workchain: -1,
bitsLen: 256,
data: []byte{4, 5, 6},
},
wantErr: false,
},
{
name: "var address with empty data",
address: "\"VAR:91ffffffff00000100\"",
want: Address{
flags: flags{
bounceable: true,
testnet: true,
},
addrType: VarAddress,
workchain: -1,
bitsLen: 256,
data: []byte{},
},
wantErr: false,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
var a Address

err := a.UnmarshalJSON([]byte(tt.address))
if (err != nil) != tt.wantErr {
t.Errorf("UnmarshalJSON() error = %v, wantErr %v", err, tt.wantErr)
}

if !reflect.DeepEqual(a, tt.want) {
t.Errorf("UnmarshalJSON() got = %v, want %v", a, tt.want)
}
})
}
}
Loading