diff --git a/address/src/test/java/org/ton/java/address/TestAddress.java b/address/src/test/java/org/ton/java/address/TestAddress.java index 93e86d8a..ceabcbea 100644 --- a/address/src/test/java/org/ton/java/address/TestAddress.java +++ b/address/src/test/java/org/ton/java/address/TestAddress.java @@ -14,121 +14,128 @@ @RunWith(JUnit4.class) public class TestAddress { - public static final String TEST_ADDRESS_0 = "0QAs9VlT6S776tq3unJcP5Ogsj-ELLunLXuOb1EKcOQi4-QO"; - public static final String TEST_ADDRESS_1 = "kQAs9VlT6S776tq3unJcP5Ogsj-ELLunLXuOb1EKcOQi47nL"; - public static final String TEST_ADDRESS_3 = "0:2cf55953e92efbeadab7ba725c3f93a0b23f842cbba72d7b8e6f510a70e422e3"; - public static final String TEST_ADDRESS_4 = "kf_8uRo6OBbQ97jCx2EIuKm8Wmt6Vb15-KsQHFLbKSMiYIny"; - - public static final String TEST_ADDRESS_5 = "-1:cdff07eb154c2e595930a6a9a4451608251cc1c894686c4c110894de43c96ad3"; - - - @Test - public void testAddress() { - - Address address03 = Address.of(TEST_ADDRESS_3); - assertThat(address03.toRaw()).isEqualTo(TEST_ADDRESS_3); - - Address address04 = Address.of(TEST_ADDRESS_0); - assertThat(address04.toString(true, true, false)).isEqualTo("0QAs9VlT6S776tq3unJcP5Ogsj-ELLunLXuOb1EKcOQi4-QO"); - assertThat(address04.isBounceable).isFalse(); - - Address address05 = Address.of(TEST_ADDRESS_0); - assertThat(address05.toString(true, true, true)).isEqualTo(TEST_ADDRESS_1); - assertThat(address05.isBounceable).isFalse(); - - Address address06 = Address.of(TEST_ADDRESS_0); - assertThat(address06.toString(false)).isEqualTo(TEST_ADDRESS_3); - assertThat(address06.isBounceable).isFalse(); - - Address address07 = Address.of(TEST_ADDRESS_1); - assertThat(address07.toString(true, true, false)).isEqualTo("0QAs9VlT6S776tq3unJcP5Ogsj-ELLunLXuOb1EKcOQi4-QO"); - assertThat(address07.isBounceable).isTrue(); - - Address address08 = Address.of(TEST_ADDRESS_1); - assertThat(address08.toString(true, true, true)).isEqualTo(TEST_ADDRESS_1); - assertThat(address08.isBounceable).isTrue(); - - Address address09 = Address.of(TEST_ADDRESS_1); - assertThat(address09.toString(false)).isEqualTo(TEST_ADDRESS_3); - assertThat(address09.isBounceable).isTrue(); - - Address address10 = Address.of(TEST_ADDRESS_3); - assertThat(address10.toString(true, true, false, true)).isEqualTo("0QAs9VlT6S776tq3unJcP5Ogsj-ELLunLXuOb1EKcOQi4-QO"); - - Address address11 = Address.of(TEST_ADDRESS_3); - assertThat(address11.toString(true, true, true, true)).isEqualTo(TEST_ADDRESS_1); - - Address address12 = Address.of(TEST_ADDRESS_3); - assertThat(address12.toString(false)).isEqualTo(TEST_ADDRESS_3); - - Address address13 = Address.of("-1:3333333333333333333333333333333333333333333333333333333333333333"); - assertThat(address13.toString(true, false, true, false)).isEqualTo("Ef8zMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzM0vF"); - assertThat(address13.toString(true, false, false, false)).isEqualTo("Uf8zMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMxYA"); - assertThat(Utils.bytesToHex(address13.hashPart)).isEqualTo("3333333333333333333333333333333333333333333333333333333333333333"); - assertThat(address13.hashPart.length).isEqualTo(32); - assertThat(address13.wc).isEqualTo((byte) -1); - - Address address14 = Address.of(TEST_ADDRESS_4); - assertThat(address14.isTestOnly).isTrue(); - - assertThat(Address.isValid(TEST_ADDRESS_0)).isTrue(); - assertThat(Address.isValid(TEST_ADDRESS_1)).isTrue(); - assertThat(Address.isValid(TEST_ADDRESS_3)).isTrue(); - assertThat(Address.isValid(TEST_ADDRESS_4)).isTrue(); - assertThat(Address.isValid("bad_address")).isFalse(); - } - - @Test - public void testBadAddress() { - assertThrows(Error.class, () -> { - Address.of(""); - Address.of("bad_input"); - Address.of("kf_8uRo6OBbQ97jCx2EIuKm8Wmt6Vb15-KsQHFLbKSMiYInz"); - Address.of("ov_8uRo6OBbQ97jCx2EIuKm8Wmt6Vb15-KsQHFLbKSMiYMg3"); - Address.of("0:8uRo6OBbQ97jCx2EIuKm8Wmt6Vb15:KsQHFLbKSMiYMg3"); + public static final String TEST_ADDRESS_0 = "0QAs9VlT6S776tq3unJcP5Ogsj-ELLunLXuOb1EKcOQi4-QO"; + public static final String TEST_ADDRESS_1 = "kQAs9VlT6S776tq3unJcP5Ogsj-ELLunLXuOb1EKcOQi47nL"; + public static final String TEST_ADDRESS_3 = + "0:2cf55953e92efbeadab7ba725c3f93a0b23f842cbba72d7b8e6f510a70e422e3"; + public static final String TEST_ADDRESS_4 = "kf_8uRo6OBbQ97jCx2EIuKm8Wmt6Vb15-KsQHFLbKSMiYIny"; + + public static final String TEST_ADDRESS_5 = + "-1:cdff07eb154c2e595930a6a9a4451608251cc1c894686c4c110894de43c96ad3"; + + @Test + public void testAddress() { + + Address address03 = Address.of(TEST_ADDRESS_3); + assertThat(address03.toRaw()).isEqualTo(TEST_ADDRESS_3); + + Address address04 = Address.of(TEST_ADDRESS_0); + assertThat(address04.toString(true, true, false)) + .isEqualTo("0QAs9VlT6S776tq3unJcP5Ogsj-ELLunLXuOb1EKcOQi4-QO"); + assertThat(address04.isBounceable).isFalse(); + + Address address05 = Address.of(TEST_ADDRESS_0); + assertThat(address05.toString(true, true, true)).isEqualTo(TEST_ADDRESS_1); + assertThat(address05.isBounceable).isFalse(); + + Address address06 = Address.of(TEST_ADDRESS_0); + assertThat(address06.toString(false)).isEqualTo(TEST_ADDRESS_3); + assertThat(address06.isBounceable).isFalse(); + + Address address07 = Address.of(TEST_ADDRESS_1); + assertThat(address07.toString(true, true, false)) + .isEqualTo("0QAs9VlT6S776tq3unJcP5Ogsj-ELLunLXuOb1EKcOQi4-QO"); + assertThat(address07.isBounceable).isTrue(); + + Address address08 = Address.of(TEST_ADDRESS_1); + assertThat(address08.toString(true, true, true)).isEqualTo(TEST_ADDRESS_1); + assertThat(address08.isBounceable).isTrue(); + + Address address09 = Address.of(TEST_ADDRESS_1); + assertThat(address09.toString(false)).isEqualTo(TEST_ADDRESS_3); + assertThat(address09.isBounceable).isTrue(); + + Address address10 = Address.of(TEST_ADDRESS_3); + assertThat(address10.toString(true, true, false, true)) + .isEqualTo("0QAs9VlT6S776tq3unJcP5Ogsj-ELLunLXuOb1EKcOQi4-QO"); + + Address address11 = Address.of(TEST_ADDRESS_3); + assertThat(address11.toString(true, true, true, true)).isEqualTo(TEST_ADDRESS_1); + + Address address12 = Address.of(TEST_ADDRESS_3); + assertThat(address12.toString(false)).isEqualTo(TEST_ADDRESS_3); + + Address address13 = + Address.of("-1:3333333333333333333333333333333333333333333333333333333333333333"); + assertThat(address13.toString(true, false, true, false)) + .isEqualTo("Ef8zMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzM0vF"); + assertThat(address13.toString(true, false, false, false)) + .isEqualTo("Uf8zMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMxYA"); + assertThat(Utils.bytesToHex(address13.hashPart)) + .isEqualTo("3333333333333333333333333333333333333333333333333333333333333333"); + assertThat(address13.hashPart.length).isEqualTo(32); + assertThat(address13.wc).isEqualTo((byte) -1); + + Address address14 = Address.of(TEST_ADDRESS_4); + assertThat(address14.isTestOnly).isTrue(); + + assertThat(Address.isValid(TEST_ADDRESS_0)).isTrue(); + assertThat(Address.isValid(TEST_ADDRESS_1)).isTrue(); + assertThat(Address.isValid(TEST_ADDRESS_3)).isTrue(); + assertThat(Address.isValid(TEST_ADDRESS_4)).isTrue(); + assertThat(Address.isValid("bad_address")).isFalse(); + } + + @Test + public void testBadAddress() { + assertThrows( + Error.class, + () -> { + Address.of(""); + Address.of("bad_input"); + Address.of("kf_8uRo6OBbQ97jCx2EIuKm8Wmt6Vb15-KsQHFLbKSMiYInz"); + Address.of("ov_8uRo6OBbQ97jCx2EIuKm8Wmt6Vb15-KsQHFLbKSMiYMg3"); + Address.of("0:8uRo6OBbQ97jCx2EIuKm8Wmt6Vb15:KsQHFLbKSMiYMg3"); }); - } - - @Test - public void testCompareAddress() { - Address a = Address.of(TEST_ADDRESS_0); - Address b = Address.of(TEST_ADDRESS_4); - assertThat(a).isNotEqualTo(b); - - b = Address.of(TEST_ADDRESS_1); - assertThat(a).isNotEqualTo(b); - } - - /** - * Save address to file in 36-byte format - */ - @Test - public void testSaveAddress() throws IOException { - // wc 0 - Address address01 = Address.of(TEST_ADDRESS_0); - log.info("full address {}" , address01.toString(false)); - log.info("bounceable address {}", address01.toString(true, true, true)); - log.info("non-bounceable address {}", address01.toString(true, true, false)); - - address01.saveToFile("test0.addr"); - - // wc -1 - Address address02 = Address.of(TEST_ADDRESS_5); - log.info("full address {} ", address02.toString(false)); - log.info("bounceable address {}", address02.toString(true, true, true, true)); - log.info("non-bounceable address {}", address02.toString(true, true, false, true)); - - address02.saveToFile("test1.addr"); - } - - @Test - public void testIsWallet() { - - assertThat(Address.of(TEST_ADDRESS_0).isWallet).isTrue(); -// assertThat(Address.of(TEST_ADDRESS_1).isWallet).isTrue(); - assertThat(Address.of(TEST_ADDRESS_3).isWallet).isTrue(); -// assertThat(Address.of(TEST_ADDRESS_4).isWallet).isTrue(); - assertThat(Address.of(TEST_ADDRESS_5).isWallet).isTrue(); - - } + } + + @Test + public void testCompareAddress() { + Address a = Address.of(TEST_ADDRESS_0); + Address b = Address.of(TEST_ADDRESS_4); + assertThat(a).isNotEqualTo(b); + + b = Address.of(TEST_ADDRESS_1); + assertThat(a).isNotEqualTo(b); + } + + /** Save address to file in 36-byte format */ + @Test + public void testSaveAddress() throws IOException { + // wc 0 + Address address01 = Address.of(TEST_ADDRESS_0); + log.info("full address {}", address01.toString(false)); + log.info("bounceable address {}", address01.toString(true, true, true)); + log.info("non-bounceable address {}", address01.toString(true, true, false)); + + address01.saveToFile("test0.addr"); + + // wc -1 + Address address02 = Address.of(TEST_ADDRESS_5); + log.info("full address {} ", address02.toString(false)); + log.info("bounceable address {}", address02.toString(true, true, true, true)); + log.info("non-bounceable address {}", address02.toString(true, true, false, true)); + + address02.saveToFile("test1.addr"); + } + + @Test + public void testIsWallet() { + + assertThat(Address.of(TEST_ADDRESS_0).isWallet).isTrue(); + // assertThat(Address.of(TEST_ADDRESS_1).isWallet).isTrue(); + assertThat(Address.of(TEST_ADDRESS_3).isWallet).isTrue(); + // assertThat(Address.of(TEST_ADDRESS_4).isWallet).isTrue(); + assertThat(Address.of(TEST_ADDRESS_5).isWallet).isTrue(); + } } diff --git a/cell/src/main/java/org/ton/java/tlb/types/MsgAddressIntStd.java b/cell/src/main/java/org/ton/java/tlb/types/MsgAddressIntStd.java index add7ada5..9e664140 100644 --- a/cell/src/main/java/org/ton/java/tlb/types/MsgAddressIntStd.java +++ b/cell/src/main/java/org/ton/java/tlb/types/MsgAddressIntStd.java @@ -6,6 +6,7 @@ import java.math.BigInteger; import lombok.Builder; import lombok.Data; +import org.apache.commons.lang3.StringUtils; import org.ton.java.address.Address; import org.ton.java.cell.Cell; import org.ton.java.cell.CellBuilder; @@ -30,7 +31,11 @@ public class MsgAddressIntStd implements MsgAddressInt { @Override public String toString() { - return nonNull(address) ? (workchainId + ":" + address.toString(16)) : null; + String addressStr = address.toString(16); + if (addressStr.length() != 64) { + addressStr = StringUtils.leftPad(addressStr, 64, "0"); + } + return nonNull(address) ? (workchainId + ":" + addressStr) : null; } public Cell toCell() { diff --git a/cell/src/test/java/org/ton/java/tlb/TestTlbDeserialization.java b/cell/src/test/java/org/ton/java/tlb/TestTlbDeserialization.java new file mode 100644 index 00000000..dfcda362 --- /dev/null +++ b/cell/src/test/java/org/ton/java/tlb/TestTlbDeserialization.java @@ -0,0 +1,32 @@ +package org.ton.java.tlb; + +import static org.assertj.core.api.Assertions.assertThat; + +import lombok.extern.slf4j.Slf4j; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.ton.java.tlb.types.MsgAddressIntStd; + +@Slf4j +@RunWith(JUnit4.class) +public class TestTlbDeserialization { + + @Test + public void testSaveAddressWithZeros() { + MsgAddressIntStd addr1 = + MsgAddressIntStd.of("0:000212646ce2585c73ad02a115cd6e5c8485dda6cccd62e1b05385ff121e5a7c"); + MsgAddressIntStd addr2 = + MsgAddressIntStd.of("0QAAAhJkbOJYXHOtAqEVzW5chIXdpszNYuGwU4X_Eh5afLsu"); + log.info("addr1 {}", addr1); + log.info("addr2 {}", addr2); + + log.info("addr1 toAddress {}", addr1.toAddress()); + log.info("addr2 toAddress {}", addr2.toAddress()); + + assertThat(addr1.toString()) + .isEqualTo("0:000212646ce2585c73ad02a115cd6e5c8485dda6cccd62e1b05385ff121e5a7c"); + assertThat(addr2.toString()) + .isEqualTo("0:000212646ce2585c73ad02a115cd6e5c8485dda6cccd62e1b05385ff121e5a7c"); + } +} diff --git a/cell/src/test/java/org/ton/java/tlb/TestTlbSerialization.java b/cell/src/test/java/org/ton/java/tlb/TestTlbSerialization.java index e2f56b7a..34d9c0dc 100644 --- a/cell/src/test/java/org/ton/java/tlb/TestTlbSerialization.java +++ b/cell/src/test/java/org/ton/java/tlb/TestTlbSerialization.java @@ -1,5 +1,6 @@ package org.ton.java.tlb; +import java.math.BigInteger; import lombok.extern.slf4j.Slf4j; import org.junit.Test; import org.junit.runner.RunWith; @@ -8,30 +9,30 @@ import org.ton.java.tlb.types.StorageInfo; import org.ton.java.tlb.types.StorageUsed; -import java.math.BigInteger; - @Slf4j @RunWith(JUnit4.class) public class TestTlbSerialization { - @Test - public void testLoadShardStateFromCell() { + @Test + public void testLoadShardStateFromCell() { - StorageUsed storageUsed = StorageUsed.builder() - .bitsUsed(BigInteger.valueOf(5)) - .cellsUsed(BigInteger.valueOf(3)) - .publicCellsUsed(BigInteger.valueOf(3)) - .build(); + StorageUsed storageUsed = + StorageUsed.builder() + .bitsUsed(BigInteger.valueOf(5)) + .cellsUsed(BigInteger.valueOf(3)) + .publicCellsUsed(BigInteger.valueOf(3)) + .build(); - StorageInfo storageInfo = StorageInfo.builder() - .storageUsed(storageUsed) - .lastPaid(1709674914) - .duePayment(BigInteger.valueOf(12)) - .build(); + StorageInfo storageInfo = + StorageInfo.builder() + .storageUsed(storageUsed) + .lastPaid(1709674914) + .duePayment(BigInteger.valueOf(12)) + .build(); - Cell serializedStorageInfo = storageInfo.toCell(); + Cell serializedStorageInfo = storageInfo.toCell(); - log.info("serializedStorageInfo Cell {}", serializedStorageInfo.print()); - log.info("serializedStorageInfo Cell {}", serializedStorageInfo.toHex()); - log.info("serializedStorageInfo Struct {}", storageInfo); - } + log.info("serializedStorageInfo Cell {}", serializedStorageInfo.print()); + log.info("serializedStorageInfo Cell {}", serializedStorageInfo.toHex()); + log.info("serializedStorageInfo Struct {}", storageInfo); + } } diff --git a/tl/src/main/resources/tl-schemes/lite_api.tl b/tl/src/main/resources/tl-schemes/lite_api.tl index 49621212..b00951da 100644 --- a/tl/src/main/resources/tl-schemes/lite_api.tl +++ b/tl/src/main/resources/tl-schemes/lite_api.tl @@ -35,14 +35,15 @@ liteServer.blockData id:tonNode.blockIdExt data:bytes = liteServer.BlockData; liteServer.blockState id:tonNode.blockIdExt root_hash:int256 file_hash:int256 data:bytes = liteServer.BlockState; liteServer.blockHeader id:tonNode.blockIdExt mode:# header_proof:bytes = liteServer.BlockHeader; liteServer.sendMsgStatus status:int = liteServer.SendMsgStatus; -liteServer.account id:tonNode.blockIdExt shardblk:tonNode.blockIdExt shard_proof:bytes proof:bytes state:bytes = liteServer.AccountState; +liteServer.accountState id:tonNode.blockIdExt shardblk:tonNode.blockIdExt shard_proof:bytes proof:bytes state:bytes = liteServer.AccountState; liteServer.runMethodResult mode:# id:tonNode.blockIdExt shardblk:tonNode.blockIdExt shard_proof:mode.0?bytes proof:mode.0?bytes state_proof:mode.1?bytes init_c7:mode.3?bytes lib_extras:mode.4?bytes exit_code:int result:mode.2?bytes = liteServer.RunMethodResult; liteServer.shardInfo id:tonNode.blockIdExt shardblk:tonNode.blockIdExt shard_proof:bytes shard_descr:bytes = liteServer.ShardInfo; liteServer.allShardsInfo id:tonNode.blockIdExt proof:bytes data:bytes = liteServer.AllShardsInfo; liteServer.transactionInfo id:tonNode.blockIdExt proof:bytes transaction:bytes = liteServer.TransactionInfo; liteServer.transactionList ids:(vector tonNode.blockIdExt) transactions:bytes = liteServer.TransactionList; -liteServer.transactionId mode:# accountHelper:mode.0?int256 lt:mode.1?long hash:mode.2?int256 = liteServer.TransactionId; -liteServer.transactionId3 accountHelper:int256 lt:long = liteServer.TransactionId3; +liteServer.transactionMetadata mode:# depth:int initiator:liteServer.accountId initiator_lt:long = liteServer.TransactionMetadata; +liteServer.transactionId#b12f65af mode:# account:mode.0?int256 lt:mode.1?long hash:mode.2?int256 metadata:mode.8?liteServer.transactionMetadata = liteServer.TransactionId; +liteServer.transactionId3 account:int256 lt:long = liteServer.TransactionId3; liteServer.blockTransactions id:tonNode.blockIdExt req_count:# incomplete:Bool ids:(vector liteServer.transactionId) proof:bytes = liteServer.BlockTransactions; liteServer.blockTransactionsExt id:tonNode.blockIdExt req_count:# incomplete:Bool transactions:bytes proof:bytes = liteServer.BlockTransactionsExt; liteServer.signature node_id_short:int256 signature:bytes = liteServer.Signature; @@ -53,11 +54,27 @@ liteServer.partialBlockProof complete:Bool from:tonNode.blockIdExt to:tonNode.bl liteServer.configInfo mode:# id:tonNode.blockIdExt state_proof:bytes config_proof:bytes = liteServer.ConfigInfo; liteServer.validatorStats mode:# id:tonNode.blockIdExt count:int complete:Bool state_proof:bytes data_proof:bytes = liteServer.ValidatorStats; liteServer.libraryResult result:(vector liteServer.libraryEntry) = liteServer.LibraryResult; +liteServer.libraryResultWithProof id:tonNode.blockIdExt mode:# result:(vector liteServer.libraryEntry) state_proof:bytes data_proof:bytes = liteServer.LibraryResultWithProof; liteServer.shardBlockLink id:tonNode.blockIdExt proof:bytes = liteServer.ShardBlockLink; liteServer.shardBlockProof masterchain_id:tonNode.blockIdExt links:(vector liteServer.shardBlockLink) = liteServer.ShardBlockProof; +liteServer.lookupBlockResult id:tonNode.blockIdExt mode:# mc_block_id:tonNode.blockIdExt client_mc_state_proof:bytes mc_block_proof:bytes shard_links:(vector liteServer.shardBlockLink) header:bytes prev_header:bytes = liteServer.LookupBlockResult; +liteServer.outMsgQueueSize id:tonNode.blockIdExt size:int = liteServer.OutMsgQueueSize; +liteServer.outMsgQueueSizes shards:(vector liteServer.outMsgQueueSize) ext_msg_queue_size_limit:int = liteServer.OutMsgQueueSizes; +liteServer.blockOutMsgQueueSize mode:# id:tonNode.blockIdExt size:long proof:mode.0?bytes = liteServer.BlockOutMsgQueueSize; +liteServer.accountDispatchQueueInfo addr:int256 size:long min_lt:long max_lt:long = liteServer.AccountDispatchQueueInfo; +liteServer.dispatchQueueInfo mode:# id:tonNode.blockIdExt account_dispatch_queues:(vector liteServer.accountDispatchQueueInfo) complete:Bool proof:mode.0?bytes = liteServer.DispatchQueueInfo; +liteServer.dispatchQueueMessage addr:int256 lt:long hash:int256 metadata:liteServer.transactionMetadata = liteServer.DispatchQueueMessage; +liteServer.dispatchQueueMessages mode:# id:tonNode.blockIdExt messages:(vector liteServer.dispatchQueueMessage) complete:Bool + proof:mode.0?bytes messages_boc:mode.2?bytes = liteServer.DispatchQueueMessages; liteServer.debug.verbosity value:int = liteServer.debug.Verbosity; +liteServer.nonfinal.candidateId block_id:tonNode.blockIdExt creator:int256 collated_data_hash:int256 = liteServer.nonfinal.CandidateId; +liteServer.nonfinal.candidate id:liteServer.nonfinal.candidateId data:bytes collated_data:bytes = liteServer.nonfinal.Candidate; +liteServer.nonfinal.candidateInfo id:liteServer.nonfinal.candidateId available:Bool approved_weight:long signed_weight:long total_weight:long = liteServer.nonfinal.CandidateInfo; +liteServer.nonfinal.validatorGroupInfo next_block_id:tonNode.blockId cc_seqno:int prev:(vector tonNode.blockIdExt) candidates:(vector liteServer.nonfinal.candidateInfo) = liteServer.nonfinal.ValidatorGroupInfo; +liteServer.nonfinal.validatorGroups groups:(vector liteServer.nonfinal.validatorGroupInfo) = liteServer.nonfinal.ValidatorGroups; + ---functions--- liteServer.getMasterchainInfo = liteServer.MasterchainInfo; @@ -68,14 +85,15 @@ liteServer.getBlock id:tonNode.blockIdExt = liteServer.BlockData; liteServer.getState id:tonNode.blockIdExt = liteServer.BlockState; liteServer.getBlockHeader id:tonNode.blockIdExt mode:# = liteServer.BlockHeader; liteServer.sendMessage body:bytes = liteServer.SendMsgStatus; -liteServer.getAccountState id:tonNode.blockIdExt accountHelper:liteServer.accountId = liteServer.AccountState; -liteServer.getAccountStatePrunned id:tonNode.blockIdExt accountHelper:liteServer.accountId = liteServer.AccountState; -liteServer.runSmcMethod mode:# id:tonNode.blockIdExt accountHelper:liteServer.accountId method_id:long params:bytes = liteServer.RunMethodResult; +liteServer.getAccountState id:tonNode.blockIdExt account:liteServer.accountId = liteServer.AccountState; +liteServer.getAccountStatePrunned id:tonNode.blockIdExt account:liteServer.accountId = liteServer.AccountState; +liteServer.runSmcMethod mode:# id:tonNode.blockIdExt account:liteServer.accountId method_id:long params:bytes = liteServer.RunMethodResult; liteServer.getShardInfo id:tonNode.blockIdExt workchain:int shard:long exact:Bool = liteServer.ShardInfo; liteServer.getAllShardsInfo id:tonNode.blockIdExt = liteServer.AllShardsInfo; -liteServer.getOneTransaction id:tonNode.blockIdExt accountHelper:liteServer.accountId lt:long = liteServer.TransactionInfo; -liteServer.getTransactions count:# accountHelper:liteServer.accountId lt:long hash:int256 = liteServer.TransactionList; +liteServer.getOneTransaction id:tonNode.blockIdExt account:liteServer.accountId lt:long = liteServer.TransactionInfo; +liteServer.getTransactions count:# account:liteServer.accountId lt:long hash:int256 = liteServer.TransactionList; liteServer.lookupBlock mode:# id:tonNode.blockId lt:mode.1?long utime:mode.2?int = liteServer.BlockHeader; +liteServer.lookupBlockWithProof mode:# id:tonNode.blockId mc_block_id:tonNode.blockIdExt lt:mode.1?long utime:mode.2?int = liteServer.LookupBlockResult; liteServer.listBlockTransactions id:tonNode.blockIdExt mode:# count:# after:mode.7?liteServer.transactionId3 reverse_order:mode.6?true want_proof:mode.5?true = liteServer.BlockTransactions; liteServer.listBlockTransactionsExt id:tonNode.blockIdExt mode:# count:# after:mode.7?liteServer.transactionId3 reverse_order:mode.6?true want_proof:mode.5?true = liteServer.BlockTransactionsExt; liteServer.getBlockProof mode:# known_block:tonNode.blockIdExt target_block:mode.0?tonNode.blockIdExt = liteServer.PartialBlockProof; @@ -83,7 +101,16 @@ liteServer.getConfigAll mode:# id:tonNode.blockIdExt = liteServer.ConfigInfo; liteServer.getConfigParams mode:# id:tonNode.blockIdExt param_list:(vector int) = liteServer.ConfigInfo; liteServer.getValidatorStats#091a58bc mode:# id:tonNode.blockIdExt limit:int start_after:mode.0?int256 modified_after:mode.2?int = liteServer.ValidatorStats; liteServer.getLibraries library_list:(vector int256) = liteServer.LibraryResult; +liteServer.getLibrariesWithProof id:tonNode.blockIdExt mode:# library_list:(vector int256) = liteServer.LibraryResultWithProof; liteServer.getShardBlockProof id:tonNode.blockIdExt = liteServer.ShardBlockProof; +liteServer.getOutMsgQueueSizes mode:# wc:mode.0?int shard:mode.0?long = liteServer.OutMsgQueueSizes; +liteServer.getBlockOutMsgQueueSize mode:# id:tonNode.blockIdExt want_proof:mode.0?true = liteServer.BlockOutMsgQueueSize; +liteServer.getDispatchQueueInfo mode:# id:tonNode.blockIdExt after_addr:mode.1?int256 max_accounts:int want_proof:mode.0?true = liteServer.DispatchQueueInfo; +liteServer.getDispatchQueueMessages mode:# id:tonNode.blockIdExt addr:int256 after_lt:long max_messages:int + want_proof:mode.0?true one_account:mode.1?true messages_boc:mode.2?true = liteServer.DispatchQueueMessages; + +liteServer.nonfinal.getValidatorGroups mode:# wc:mode.0?int shard:mode.0?long = liteServer.nonfinal.ValidatorGroups; +liteServer.nonfinal.getCandidate id:liteServer.nonfinal.candidateId = liteServer.nonfinal.Candidate; liteServer.queryPrefix = Object; liteServer.query data:bytes = Object; diff --git a/tl/src/main/resources/tl-schemes/ton_api.tl b/tl/src/main/resources/tl-schemes/ton_api.tl index 9a5ef173..16f48345 100644 --- a/tl/src/main/resources/tl-schemes/ton_api.tl +++ b/tl/src/main/resources/tl-schemes/ton_api.tl @@ -144,7 +144,26 @@ adnl.message.part hash:int256 total_size:int offset:int data:bytes = adnl.Messag ---types--- adnl.db.node.key local_id:int256 peer_id:int256 = adnl.db.Key; -adnl.db.node.value date:int id:PublicKey addr_list:adnl.addressList priority_addr_list:adnl.addressList = adnl.db.node.Value; +adnl.db.node.value date:int id:PublicKey addr_list:adnl.addressList priority_addr_list:adnl.addressList = adnl.db.node.Value; + +adnl.stats.packets ts_start:double ts_end:double + in_packets:long in_bytes:long in_packets_channel:long in_bytes_channel:long + out_packets:long out_bytes:long out_packets_channel:long out_bytes_channel:long + out_expired_messages:long out_expired_bytes:long = adnl.stats.Packets; +adnl.stats.peerPair local_id:int256 peer_id:int256 ip_str:string + packets_recent:adnl.stats.packets packets_total:adnl.stats.packets + last_out_packet_ts:double last_in_packet_ts:double + connection_ready:Bool channel_status:int try_reinit_at:double + out_queue_messages:long out_queue_bytes:long + = adnl.stats.PeerPair; +adnl.stats.ipPackets ip_str:string packets:long = adnl.stats.IpPackets; +adnl.stats.localIdPackets ts_start:double ts_end:double + decrypted_packets:(vector adnl.stats.ipPackets) dropped_packets:(vector adnl.stats.ipPackets) = adnl.stats.LocalIdPackets; +adnl.stats.localId short_id:int256 + current_decrypt:(vector adnl.stats.ipPackets) + packets_recent:adnl.stats.localIdPackets packets_total:adnl.stats.localIdPackets + peers:(vector adnl.stats.peerPair) = adnl.stats.LocalId; +adnl.stats timestamp:double local_ids:(vector adnl.stats.localId) = adnl.Stats; ---functions--- @@ -209,10 +228,15 @@ dht.query node:dht.node = True; ---types--- overlay.node.toSign id:adnl.id.short overlay:int256 version:int = overlay.node.ToSign; +overlay.node.toSignEx id:adnl.id.short overlay:int256 flags:int version:int = overlay.node.ToSign; overlay.node id:PublicKey overlay:int256 version:int signature:bytes = overlay.Node; +overlay.nodeV2 id:PublicKey overlay:int256 flags:int version:int signature:bytes certificate:overlay.MemberCertificate = overlay.NodeV2; overlay.nodes nodes:(vector overlay.node) = overlay.Nodes; +overlay.nodesV2 nodes:(vector overlay.NodeV2) = overlay.NodesV2; +overlay.messageExtra flags:# certificate:flags.0?overlay.MemberCertificate = overlay.MessageExtra; overlay.message overlay:int256 = overlay.Message; +overlay.messageWithExtra overlay:int256 extra:overlay.messageExtra = overlay.Message; //overlay.randomPeers peers:(vector adnl.node) = overlay.RandomPeers; overlay.broadcastList hashes:(vector int256) = overlay.BroadcastList; @@ -225,6 +249,9 @@ overlay.broadcastFec.partId broadcast_hash:int256 data_hash:int256 seqno:int = o overlay.broadcast.toSign hash:int256 date:int = overlay.broadcast.ToSign; +overlay.memberCertificateId node:adnl.id.short flags:int slot:int expire_at:int = overlay.MemberCertificateId; +overlay.memberCertificate issued_by:PublicKey flags:int slot:int expire_at:int signature:bytes = overlay.MemberCertificate; +overlay.emptyMemberCertificate = overlay.MemberCertificate; overlay.certificate issued_by:PublicKey expire_at:int max_size:int signature:bytes = overlay.Certificate; overlay.certificateV2 issued_by:PublicKey expire_at:int max_size:int flags:int signature:bytes = overlay.Certificate; overlay.emptyCertificate = overlay.Certificate; @@ -242,13 +269,16 @@ overlay.broadcastNotFound = overlay.Broadcast; ---functions--- overlay.getRandomPeers peers:overlay.nodes = overlay.Nodes; +overlay.getRandomPeersV2 peers:overlay.NodesV2 = overlay.NodesV2; overlay.query overlay:int256 = True; +overlay.queryWithExtra overlay:int256 extra:overlay.messageExtra = True; overlay.getBroadcast hash:int256 = overlay.Broadcast; overlay.getBroadcastList list:overlay.broadcastList = overlay.BroadcastList; ---types--- +overlay.db.nodesV2 nodes:overlay.nodesV2 = overlay.db.Nodes; overlay.db.nodes nodes:overlay.nodes = overlay.db.Nodes; overlay.db.key.nodes local_id:int256 overlay:int256 = overlay.db.Key; @@ -309,6 +339,7 @@ validatorSession.candidateId src:int256 root_hash:int256 file_hash:int256 collat validatorSession.blockUpdate ts:long actions:(vector validatorSession.round.Message) state:int = validatorSession.BlockUpdate; validatorSession.candidate src:int256 round:int root_hash:int256 data:bytes collated_data:bytes = validatorSession.Candidate; +validatorSession.compressedCandidate flags:# src:int256 round:int root_hash:int256 decompressed_size:int data:bytes = validatorSession.Candidate; validatorSession.config catchain_idle_timeout:double catchain_max_deps:int round_candidates:int next_candidate_delay:double round_attempt_duration:int max_round_attempts:int max_block_size:int max_collated_data_size:int = validatorSession.Config; @@ -365,6 +396,7 @@ tonNode.blockSignature who:int256 signature:bytes = tonNode.BlockSignature; tonNode.blockId workchain:int shard:long seqno:int = tonNode.BlockId; tonNode.blockIdExt workchain:int shard:long seqno:int root_hash:int256 file_hash:int256 = tonNode.BlockIdExt; tonNode.zeroStateIdExt workchain:int root_hash:int256 file_hash:int256 = tonNode.ZeroStateIdExt; +tonNode.shardId workchain:int shard:long = tonNode.ShardId; tonNode.blockDescriptionEmpty = tonNode.BlockDescription; tonNode.blockDescription id:tonNode.blockIdExt = tonNode.BlockDescription; @@ -385,32 +417,45 @@ tonNode.externalMessage data:bytes = tonNode.ExternalMessage; tonNode.newShardBlock block:tonNode.blockIdExt cc_seqno:int data:bytes = tonNode.NewShardBlock; -tonNode.blockBroadcast id:tonNode.blockIdExt catchain_seqno:int validator_set_hash:int - signatures:(vector tonNode.blockSignature) +tonNode.blockBroadcastCompressed.data signatures:(vector tonNode.blockSignature) proof_data:bytes = tonNode.blockBroadcaseCompressed.Data; + +tonNode.blockBroadcast id:tonNode.blockIdExt catchain_seqno:int validator_set_hash:int + signatures:(vector tonNode.blockSignature) proof:bytes data:bytes = tonNode.Broadcast; +tonNode.blockBroadcastCompressed id:tonNode.blockIdExt catchain_seqno:int validator_set_hash:int + flags:# compressed:bytes = tonNode.Broadcast; tonNode.ihrMessageBroadcast message:tonNode.ihrMessage = tonNode.Broadcast; tonNode.externalMessageBroadcast message:tonNode.externalMessage = tonNode.Broadcast; tonNode.newShardBlockBroadcast block:tonNode.newShardBlock = tonNode.Broadcast; +// signature may be empty, at least for now +tonNode.newBlockCandidateBroadcast id:tonNode.blockIdExt catchain_seqno:int validator_set_hash:int + collator_signature:tonNode.blockSignature data:bytes = tonNode.Broadcast; +tonNode.newBlockCandidateBroadcastCompressed id:tonNode.blockIdExt catchain_seqno:int validator_set_hash:int + collator_signature:tonNode.blockSignature flags:# compressed:bytes = tonNode.Broadcast; tonNode.shardPublicOverlayId workchain:int shard:long zero_state_file_hash:int256 = tonNode.ShardPublicOverlayId; +tonNode.privateBlockOverlayId zero_state_file_hash:int256 nodes:(vector int256) = tonNode.PrivateBlockOverlayId; +tonNode.customOverlayId zero_state_file_hash:int256 name:string nodes:(vector int256) = tonNode.CustomOverlayId; + tonNode.keyBlocks blocks:(vector tonNode.blockIdExt) incomplete:Bool error:Bool = tonNode.KeyBlocks; ton.blockId root_cell_hash:int256 file_hash:int256 = ton.BlockId; ton.blockIdApprove root_cell_hash:int256 file_hash:int256 = ton.BlockId; -tonNode.dataList data:(vector bytes) = tonNode.DataList; - tonNode.dataFull id:tonNode.blockIdExt proof:bytes block:bytes is_link:Bool = tonNode.DataFull; +tonNode.dataFullCompressed id:tonNode.blockIdExt flags:# compressed:bytes is_link:Bool = tonNode.DataFull; tonNode.dataFullEmpty = tonNode.DataFull; -tonNode.capabilities version:int capabilities:long = tonNode.Capabilities; +tonNode.capabilities#f5bf60c0 version_major:int version_minor:int flags:# = tonNode.Capabilities; tonNode.success = tonNode.Success; tonNode.archiveNotFound = tonNode.ArchiveInfo; tonNode.archiveInfo id:long = tonNode.ArchiveInfo; +tonNode.forgetPeer = tonNode.ForgetPeer; + ---functions--- tonNode.getNextBlockDescription prev_block:tonNode.blockIdExt = tonNode.BlockDescription; @@ -428,19 +473,15 @@ tonNode.getNextKeyBlockIds block:tonNode.blockIdExt max_size:int = tonNode.KeyBl tonNode.downloadNextBlockFull prev_block:tonNode.blockIdExt = tonNode.DataFull; tonNode.downloadBlockFull block:tonNode.blockIdExt = tonNode.DataFull; tonNode.downloadBlock block:tonNode.blockIdExt = tonNode.Data; -tonNode.downloadBlocks blocks:(vector tonNode.blockIdExt) = tonNode.DataList; tonNode.downloadPersistentState block:tonNode.blockIdExt masterchain_block:tonNode.blockIdExt = tonNode.Data; tonNode.downloadPersistentStateSlice block:tonNode.blockIdExt masterchain_block:tonNode.blockIdExt offset:long max_size:long = tonNode.Data; tonNode.downloadZeroState block:tonNode.blockIdExt = tonNode.Data; tonNode.downloadBlockProof block:tonNode.blockIdExt = tonNode.Data; tonNode.downloadKeyBlockProof block:tonNode.blockIdExt = tonNode.Data; -tonNode.downloadBlockProofs blocks:(vector tonNode.blockIdExt) = tonNode.DataList; -tonNode.downloadKeyBlockProofs blocks:(vector tonNode.blockIdExt) = tonNode.DataList; tonNode.downloadBlockProofLink block:tonNode.blockIdExt = tonNode.Data; tonNode.downloadKeyBlockProofLink block:tonNode.blockIdExt = tonNode.Data; -tonNode.downloadBlockProofLinks blocks:(vector tonNode.blockIdExt) = tonNode.DataList; -tonNode.downloadKeyBlockProofLinks blocks:(vector tonNode.blockIdExt) = tonNode.DataList; tonNode.getArchiveInfo masterchain_seqno:int = tonNode.ArchiveInfo; +tonNode.getShardArchiveInfo masterchain_seqno:int shard_prefix:tonNode.shardId = tonNode.ArchiveInfo; tonNode.getArchiveSlice archive_id:long offset:long max_size:int = tonNode.Data; tonNode.getCapabilities = tonNode.Capabilities; @@ -495,6 +536,7 @@ db.filedb.key.proof block_id:tonNode.blockIdExt = db.filedb.Key; db.filedb.key.proofLink block_id:tonNode.blockIdExt = db.filedb.Key; db.filedb.key.signatures block_id:tonNode.blockIdExt = db.filedb.Key; db.filedb.key.candidate id:db.candidate.id = db.filedb.Key; +db.filedb.key.candidateRef id:tonNode.blockIdExt = db.filedb.Key; db.filedb.key.blockInfo block_id:tonNode.blockIdExt = db.filedb.Key; db.filedb.value key:db.filedb.Key prev:int256 next:int256 file_hash:int256 = db.filedb.Value; @@ -506,6 +548,9 @@ db.state.shardClient block:tonNode.blockIdExt = db.state.ShardClient; db.state.asyncSerializer block:tonNode.blockIdExt last:tonNode.blockIdExt last_ts:int = db.state.AsyncSerializer; db.state.hardforks blocks:(vector tonNode.blockIdExt) = db.state.Hardforks; db.state.dbVersion version:int = db.state.DbVersion; +db.state.persistentStateDescriptionShards shard_blocks:(vector tonNode.blockIdExt) = db.state.PersistentStateDescriptionShards; +db.state.persistentStateDescriptionHeader masterchain_id:tonNode.blockIdExt start_time:int end_time:int = db.state.PersistentStateDescriptionHeader; +db.state.persistentStateDescriptionsList list:(vector db.state.persistentStateDescriptionHeader) = db.state.PersistentStateDescriptionsList; db.state.key.destroyedSessions = db.state.Key; db.state.key.initBlockId = db.state.Key; @@ -514,6 +559,8 @@ db.state.key.shardClient = db.state.Key; db.state.key.asyncSerializer = db.state.Key; db.state.key.hardforks = db.state.Key; db.state.key.dbVersion = db.state.Key; +db.state.key.persistentStateDescriptionShards masterchain_seqno:int = db.state.Key; +db.state.key.persistentStateDescriptionsList = db.state.Key; db.lt.el.key workchain:int shard:long idx:int = db.lt.Key; db.lt.desc.key workchain:int shard:long = db.lt.Key; @@ -529,7 +576,7 @@ db.files.package.key package_id:int key:Bool temp:Bool = db.files.Key; db.files.index.value packages:(vector int) key_packages:(vector int) temp_packages:(vector int) = db.files.index.Value; db.files.package.firstBlock workchain:int shard:long seqno:int unixtime:int lt:long = db.files.package.FirstBlock; --+db.files.package.value package_id:int key:Bool temp:Bool firstblocks:(vector db.files.package.firstBlock) deleted:Bool +db.files.package.value package_id:int key:Bool temp:Bool firstblocks:(vector db.files.package.firstBlock) deleted:Bool = db.files.package.Value; ---functions--- @@ -541,6 +588,10 @@ validator.group workchain:int shard:long catchain_seqno:int config_hash:int256 m validator.groupEx workchain:int shard:long vertical_seqno:int catchain_seqno:int config_hash:int256 members:(vector validator.groupMember) = validator.Group; validator.groupNew workchain:int shard:long vertical_seqno:int last_key_block_seqno:int catchain_seqno:int config_hash:int256 members:(vector validator.groupMember) = validator.Group; +validator.telemetry flags:# timestamp:double adnl_id:int256 + node_version:string os_version:string node_started_at:int + ram_size:long cpu_cores:int node_threads:int = validator.Telemetry; + ---functions--- @@ -565,8 +616,13 @@ dummyworkchain0.config.global zero_state_hash:int256 = dummyworkchain0.config.Gl validator.config.global zero_state:tonNode.blockIdExt init_block:tonNode.blockIdExt hardforks:(vector tonNode.blockIdExt) = validator.config.Global; config.global adnl:adnl.config.global dht:dht.config.Global validator:validator.config.global = config.Global; +liteserver.descV2.sliceSimple shards:(vector tonNode.shardId) = liteserver.descV2.Slice; +liteserver.descV2.shardInfo shard_id:tonNode.shardId seqno:int utime:int lt:long = liteserver.descV2.ShardInfo; +liteserver.descV2.sliceTimed shards_from:(vector liteserver.descV2.shardInfo) shards_to:(vector liteserver.descV2.shardInfo) = liteserver.descV2.Slice; + liteserver.desc id:PublicKey ip:int port:int = liteserver.Desc; -liteclient.config.global liteservers:(vector liteserver.desc) validator:validator.config.global = liteclient.config.Global; +liteserver.descV2 id:PublicKey ip:int port:int slices:(vector liteserver.descV2.Slice) = liteserver.DescV2; +liteclient.config.global liteservers:(vector liteserver.desc) liteservers_v2:(vector liteserver.descV2) validator:validator.config.global = liteclient.config.Global; engine.adnl id:int256 category:int = engine.Adnl; engine.addr ip:int port:int categories:(vector int) priority_categories:(vector int) = engine.Addr; @@ -585,14 +641,28 @@ engine.dht.config dht:(vector engine.dht) gc:engine.gc = engine.dht.Config; engine.validator.fullNodeMaster port:int adnl:int256 = engine.validator.FullNodeMaster; engine.validator.fullNodeSlave ip:int port:int adnl:PublicKey = engine.validator.FullNodeSlave; engine.validator.fullNodeConfig ext_messages_broadcast_disabled:Bool = engine.validator.FullNodeConfig; -engine.validator.config out_port:int addrs:(vector engine.Addr) adnl:(vector engine.adnl) +engine.validator.extraConfig state_serializer_enabled:Bool = engine.validator.ExtraConfig; +engine.validator.config out_port:int addrs:(vector engine.Addr) adnl:(vector engine.adnl) dht:(vector engine.dht) validators:(vector engine.validator) fullnode:int256 fullnodeslaves:(vector engine.validator.fullNodeSlave) fullnodemasters:(vector engine.validator.fullNodeMaster) fullnodeconfig:engine.validator.fullNodeConfig + extraconfig:engine.validator.extraConfig liteservers:(vector engine.liteServer) control:(vector engine.controlInterface) + shards_to_monitor:(vector tonNode.shardId) gc:engine.gc = engine.validator.Config; +engine.validator.customOverlayNode adnl_id:int256 msg_sender:Bool msg_sender_priority:int block_sender:Bool = engine.validator.CustomOverlayNode; +engine.validator.customOverlay name:string nodes:(vector engine.validator.customOverlayNode) sender_shards:(vector tonNode.shardId) + = engine.validator.CustomOverlay; +engine.validator.customOverlaysConfig overlays:(vector engine.validator.customOverlay) = engine.validator.CustomOverlaysConfig; + +engine.validator.collatorOptions + deferring_enabled:Bool defer_messages_after:int defer_out_queue_size_limit:long + dispatch_phase_2_max_total:int dispatch_phase_3_max_total:int + dispatch_phase_2_max_per_initiator:int dispatch_phase_3_max_per_initiator:int + whitelist:(vector string) prioritylist:(vector string) = engine.validator.CollatorOptions; + ---functions--- ---types--- @@ -617,6 +687,7 @@ engine.validator.signature signature:bytes = engine.validator.Signature; engine.validator.oneStat key:string value:string = engine.validator.OneStat; engine.validator.stats stats:(vector engine.validator.oneStat) = engine.validator.Stats; +engine.validator.textStats data:string = engine.validator.TextStats; engine.validator.controlQueryError code:int message:string = engine.validator.ControlQueryError; @@ -631,16 +702,28 @@ engine.validator.proposalVote perm_key:int256 to_send:bytes = engine.validator.P engine.validator.dhtServerStatus id:int256 status:int = engine.validator.DhtServerStatus; engine.validator.dhtServersStatus servers:(vector engine.validator.dhtServerStatus) = engine.validator.DhtServersStatus; -engine.validator.overlayStatsNode adnl_id:int256 ip_addr:string bdcst_errors:int fec_bdcst_errors:int last_in_query:int last_out_query:int t_out_bytes:int t_in_bytes:int t_out_pckts:int t_in_pckts:int = engine.validator.OverlayStatsNode; +engine.validator.overlayStatsTraffic t_out_bytes:long t_in_bytes:long t_out_pckts:int t_in_pckts:int = engine.validator.OverlayStatsTraffic; + +engine.validator.overlayStatsNode adnl_id:int256 ip_addr:string is_neighbour:Bool is_alive:Bool node_flags:int + bdcst_errors:int fec_bdcst_errors:int last_in_query:int last_out_query:int + traffic:engine.validator.overlayStatsTraffic traffic_responses:engine.validator.overlayStatsTraffic = engine.validator.OverlayStatsNode; -engine.validator.overlayStats overlay_id:int256 overlay_id_full:PublicKey adnl_id:int256 scope:string nodes:(vector engine.validator.overlayStatsNode) stats:(vector engine.validator.oneStat) = engine.validator.OverlayStats; +engine.validator.overlayStats overlay_id:int256 overlay_id_full:PublicKey adnl_id:int256 scope:string + nodes:(vector engine.validator.overlayStatsNode) stats:(vector engine.validator.oneStat) + total_traffic:engine.validator.overlayStatsTraffic total_traffic_responses:engine.validator.overlayStatsTraffic + extra:string = engine.validator.OverlayStats; engine.validator.overlaysStats overlays:(vector engine.validator.overlayStats) = engine.validator.OverlaysStats; +engine.validator.shardOverlayStats.neighbour id:string verison_major:int version_minor:int flags:# + roundtrip:double unreliability:double = engine.validator.shardOverlayStats.Neighbour; +engine.validator.shardOverlayStats shard:string active:Bool + neighbours:(vector engine.validator.shardOverlayStats.neighbour) = engine.validator.ShardOverlayStats; + engine.validator.onePerfTimerStat time:int min:double avg:double max:double = engine.validator.OnePerfTimerStat; engine.validator.perfTimerStatsByName name:string stats:(vector engine.validator.OnePerfTimerStat) = engine.validator.PerfTimerStatsByName; engine.validator.perfTimerStats stats:(vector engine.validator.PerfTimerStatsByName) = engine.validator.PerfTimerStats; -engine.validator.shardOutQueueSize size:int = engine.validator.ShardOutQueueSize; +engine.validator.shardOutQueueSize size:long = engine.validator.ShardOutQueueSize; ---functions--- @@ -696,6 +779,21 @@ engine.validator.getPerfTimerStats name:string = engine.validator.PerfTimerStats engine.validator.getShardOutQueueSize flags:# block_id:tonNode.blockId dest_wc:flags.0?int dest_shard:flags.0?long = engine.validator.ShardOutQueueSize; engine.validator.setExtMessagesBroadcastDisabled disabled:Bool = engine.validator.Success; +engine.validator.addCustomOverlay overlay:engine.validator.customOverlay = engine.validator.Success; +engine.validator.delCustomOverlay name:string = engine.validator.Success; +engine.validator.showCustomOverlays = engine.validator.CustomOverlaysConfig; + +engine.validator.setStateSerializerEnabled enabled:Bool = engine.validator.Success; + +engine.validator.setCollatorOptionsJson json:string = engine.validator.Success; +engine.validator.getCollatorOptionsJson = engine.validator.JsonConfig; + +engine.validator.getAdnlStats all:Bool = adnl.Stats; +engine.validator.getActorTextStats = engine.validator.TextStats; + +engine.validator.addShard shard:tonNode.shardId = engine.validator.Success; +engine.validator.delShard shard:tonNode.shardId = engine.validator.Success; + ---types--- storage.pong = storage.Pong; @@ -742,14 +840,37 @@ http.server.config dhs:(vector http.server.dnsEntry) local_hosts:(vector http.se ---types--- -validatorSession.statsProducer id:int256 block_status:int block_timestamp:long = validatorSession.StatsProducer; - -validatorSession.statsRound timestamp:long producers:(vector validatorSession.statsProducer) = validatorSession.StatsRound; - -validatorSession.stats id:tonNode.blockId timestamp:long self:int256 creator:int256 total_validators:int total_weight:long +validatorSession.collationStats bytes:int gas:int lt_delta:int cat_bytes:int cat_gas:int cat_lt_delta:int + limits_log:string ext_msgs_total:int ext_msgs_filtered:int ext_msgs_accepted:int ext_msgs_rejected:int = validadorSession.CollationStats; + +validatorSession.statsProducer id:int256 candidate_id:int256 block_status:int root_hash:int256 file_hash:int256 + comment:string block_timestamp:double is_accepted:Bool is_ours:Bool got_submit_at:double + collation_time:double collated_at:double collation_cached:Bool + collation_work_time:double collation_cpu_work_time:double + collation_stats:validatorSession.collationStats + validation_time:double validated_at:double validation_cached:Bool + validation_work_time:double validation_cpu_work_time:double + gen_utime:double + approved_weight:long approved_33pct_at:double approved_66pct_at:double approvers:string + signed_weight:long signed_33pct_at:double signed_66pct_at:double signers:string + serialize_time:double deserialize_time:double serialized_size:int = validatorSession.StatsProducer; + +validatorSession.statsRound timestamp:double producers:(vector validatorSession.statsProducer) = validatorSession.StatsRound; + +validatorSession.stats success:Bool id:tonNode.blockIdExt timestamp:double self:int256 session_id:int256 cc_seqno:int + creator:int256 total_validators:int total_weight:long signatures:int signatures_weight:long approve_signatures:int approve_signatures_weight:long first_round:int rounds:(vector validatorSession.statsRound) = validatorSession.Stats; +validatorSession.newValidatorGroupStats.node id:int256 weight:long = validatorSession.newValidatorGroupStats.Node; +validatorSession.newValidatorGroupStats session_id:int256 workchain:int shard:long cc_seqno:int + last_key_block_seqno:int timestamp:double + self_idx:int nodes:(vector validatorSession.newValidatorGroupStats.node) = validatorSession.NewValidatorGroupStats; + +validatorSession.endValidatorGroupStats.node id:int256 catchain_blocks:int = validatorSession.endValidatorGroupStats.Node; +validatorSession.endValidatorGroupStats session_id:int256 timestamp:double + nodes:(vector validatorSession.endValidatorGroupStats.node) = validatorSession.EndValidatorGroupStats; + ---functions--- ---types--- @@ -887,3 +1008,6 @@ storage.daemon.withdraw contract:string = storage.daemon.Success; storage.daemon.sendCoins address:string amount:string message:string = storage.daemon.Success; storage.daemon.closeStorageContract address:string = storage.daemon.Success; storage.daemon.removeStorageProvider = storage.daemon.Success; + +---types--- +proxyLiteserver.config port:int id:PublicKey = proxyLiteserver.Config; diff --git a/tl/src/main/resources/tl-schemes/tonlib_api.tl b/tl/src/main/resources/tl-schemes/tonlib_api.tl index e36c4a38..31ca6fd4 100644 --- a/tl/src/main/resources/tl-schemes/tonlib_api.tl +++ b/tl/src/main/resources/tl-schemes/tonlib_api.tl @@ -50,8 +50,10 @@ internal.transactionId lt:int64 hash:bytes = internal.TransactionId; ton.blockId workchain:int32 shard:int64 seqno:int32 = internal.BlockId; ton.blockIdExt workchain:int32 shard:int64 seqno:int32 root_hash:bytes file_hash:bytes = ton.BlockIdExt; -raw.fullAccountState balance:int64 code:bytes data:bytes last_transaction_id:internal.transactionId block_id:ton.blockIdExt frozen_hash:bytes sync_utime:int53 = raw.FullAccountState; -raw.message source:accountAddress destination:accountAddress value:int64 fwd_fee:int64 ihr_fee:int64 created_lt:int64 body_hash:bytes msg_data:msg.Data = raw.Message; +extraCurrency id:int32 amount:int64 = ExtraCurrency; + +raw.fullAccountState balance:int64 extra_currencies:vector code:bytes data:bytes last_transaction_id:internal.transactionId block_id:ton.blockIdExt frozen_hash:bytes sync_utime:int53 = raw.FullAccountState; +raw.message hash:bytes source:accountAddress destination:accountAddress value:int64 extra_currencies:vector fwd_fee:int64 ihr_fee:int64 created_lt:int64 body_hash:bytes msg_data:msg.Data = raw.Message; raw.transaction address:accountAddress utime:int53 data:bytes transaction_id:internal.transactionId fee:int64 storage_fee:int64 other_fee:int64 in_msg:raw.message out_msgs:vector = raw.Transaction; raw.transactions transactions:vector previous_transaction_id:internal.transactionId = raw.Transactions; @@ -61,6 +63,7 @@ pchan.config alice_public_key:string alice_address:accountAddress bob_public_key raw.initialAccountState code:bytes data:bytes = InitialAccountState; wallet.v3.initialAccountState public_key:string wallet_id:int64 = InitialAccountState; +wallet.v4.initialAccountState public_key:string wallet_id:int64 = InitialAccountState; wallet.highload.v1.initialAccountState public_key:string wallet_id:int64 = InitialAccountState; wallet.highload.v2.initialAccountState public_key:string wallet_id:int64 = InitialAccountState; @@ -71,21 +74,22 @@ rwallet.initialAccountState init_public_key:string public_key:string wallet_id:i dns.initialAccountState public_key:string wallet_id:int64 = InitialAccountState; pchan.initialAccountState config:pchan.config = InitialAccountState; -raw.account code:bytes data:bytes frozen_hash:bytes = AccountState; -wallet.v3.account wallet_id:int64 seqno:int32 = AccountState; -wallet.highload.v1.account wallet_id:int64 seqno:int32 = AccountState; -wallet.highload.v2.account wallet_id:int64 = AccountState; -dns.account wallet_id:int64 = AccountState; -rwallet.account wallet_id:int64 seqno:int32 unlocked_balance:int64 config:rwallet.config = AccountState; +raw.accountState code:bytes data:bytes frozen_hash:bytes = AccountState; +wallet.v3.accountState wallet_id:int64 seqno:int32 = AccountState; +wallet.v4.accountState wallet_id:int64 seqno:int32 = AccountState; +wallet.highload.v1.accountState wallet_id:int64 seqno:int32 = AccountState; +wallet.highload.v2.accountState wallet_id:int64 = AccountState; +dns.accountState wallet_id:int64 = AccountState; +rwallet.accountState wallet_id:int64 seqno:int32 unlocked_balance:int64 config:rwallet.config = AccountState; pchan.stateInit signed_A:Bool signed_B:Bool min_A:int64 min_B:int64 expire_at:int53 A:int64 B:int64 = pchan.State; pchan.stateClose signed_A:Bool signed_B:Bool min_A:int64 min_B:int64 expire_at:int53 A:int64 B:int64 = pchan.State; pchan.statePayout A:int64 B:int64 = pchan.State; -pchan.account config:pchan.config state:pchan.State description:string = AccountState; -uninited.account frozen_hash:bytes = AccountState; +pchan.accountState config:pchan.config state:pchan.State description:string = AccountState; +uninited.accountState frozen_hash:bytes = AccountState; -fullAccountState address:accountAddress balance:int64 last_transaction_id:internal.transactionId block_id:ton.blockIdExt sync_utime:int53 account_state:AccountState revision:int32 = FullAccountState; +fullAccountState address:accountAddress balance:int64 extra_currencies:vector last_transaction_id:internal.transactionId block_id:ton.blockIdExt sync_utime:int53 account_state:AccountState revision:int32 = FullAccountState; accountRevisionList revisions:vector = AccountRevisionList; accountList accounts:vector = AccountList; @@ -108,7 +112,7 @@ msg.dataDecrypted proof:bytes data:msg.Data = msg.DataDecrypted; msg.dataEncryptedArray elements:vector = msg.DataEncryptedArray; msg.dataDecryptedArray elements:vector = msg.DataDecryptedArray; -msg.message destination:accountAddress public_key:string amount:int64 data:msg.Data send_mode:int32 = msg.Message; +msg.message destination:accountAddress public_key:string amount:int64 extra_currencies:vector data:msg.Data send_mode:int32 = msg.Message; // // DNS @@ -184,6 +188,10 @@ smc.runResult gas_used:int53 stack:vector exit_code:int32 = smc. smc.libraryEntry hash:int256 data:bytes = smc.LibraryEntry; smc.libraryResult result:(vector smc.libraryEntry) = smc.LibraryResult; +smc.libraryQueryExt.one hash:int256 = smc.LibraryQueryExt; +smc.libraryQueryExt.scanBoc boc:bytes max_libs:int32 = smc.LibraryQueryExt; +smc.libraryResultExt dict_boc:bytes libs_ok:(vector int256) libs_not_found:(vector int256) = smc.LibraryResultExt; + updateSendLiteServerQuery id:int64 data:bytes = Update; updateSyncState sync_state:SyncState = Update; @@ -212,8 +220,8 @@ liteServer.info now:int53 version:int32 capabilities:int64 = liteServer.Info; blocks.masterchainInfo last:ton.BlockIdExt state_root_hash:bytes init:ton.BlockIdExt = blocks.MasterchainInfo; blocks.shards shards:vector = blocks.Shards; -blocks.accountTransactionId accountHelper:bytes lt:int64 = blocks.AccountTransactionId; -blocks.shortTxId mode:# accountHelper:mode.0?bytes lt:mode.1?int64 hash:mode.2?bytes = liteServer.TransactionId; +blocks.accountTransactionId account:bytes lt:int64 = blocks.AccountTransactionId; +blocks.shortTxId mode:# account:mode.0?bytes lt:mode.1?int64 hash:mode.2?bytes = liteServer.TransactionId; blocks.transactions id:ton.blockIdExt req_count:int32 incomplete:Bool transactions:vector = blocks.Transactions; blocks.transactionsExt id:ton.blockIdExt req_count:int32 incomplete:Bool transactions:vector = blocks.TransactionsExt; blocks.header id:ton.blockIdExt global_id:int32 version:int32 flags:# after_merge:Bool after_split:Bool before_split:Bool want_merge:Bool want_split:Bool validator_list_hash_short:int32 catchain_seqno:int32 min_ref_mc_seqno:int32 is_key_block:Bool prev_key_block_seqno:int32 start_lt:int64 end_lt:int64 gen_utime:int53 vert_seqno:# prev_blocks:vector = blocks.Header; @@ -224,6 +232,8 @@ blocks.blockSignatures id:ton.blockIdExt signatures:(vector blocks.signature) = blocks.shardBlockLink id:ton.blockIdExt proof:bytes = blocks.ShardBlockLink; blocks.blockLinkBack to_key_block:Bool from:ton.blockIdExt to:ton.blockIdExt dest_proof:bytes proof:bytes state_proof:bytes = blocks.BlockLinkBack; blocks.shardBlockProof from:ton.blockIdExt mc_id:ton.blockIdExt links:(vector blocks.shardBlockLink) mc_proof:(vector blocks.blockLinkBack) = blocks.ShardBlockProof; +blocks.outMsgQueueSize id:ton.blockIdExt size:int32 = blocks.OutMsgQueueSize; +blocks.outMsgQueueSizes shards:(vector blocks.outMsgQueueSize) ext_msg_queue_size_limit:int32 = blocks.OutMsgQueueSizes; configInfo config:tvm.cell = ConfigInfo; @@ -303,9 +313,11 @@ smc.forget id:int53 = Ok; smc.getCode id:int53 = tvm.Cell; smc.getData id:int53 = tvm.Cell; smc.getState id:int53 = tvm.Cell; +smc.getRawFullAccountState id:int53 = raw.FullAccountState; smc.runGetMethod id:int53 method:smc.MethodId stack:vector = smc.RunResult; smc.getLibraries library_list:(vector int256) = smc.LibraryResult; +smc.getLibrariesExt list:(vector smc.LibraryQueryExt) = smc.LibraryResultExt; dns.resolve account_address:accountAddress name:string category:int256 ttl:int32 = dns.Resolved; @@ -324,6 +336,7 @@ blocks.getTransactionsExt id:ton.blockIdExt mode:# count:# after:blocks.accountT blocks.getBlockHeader id:ton.blockIdExt = blocks.Header; blocks.getMasterchainBlockSignatures seqno:int32 = blocks.BlockSignatures; blocks.getShardBlockProof id:ton.blockIdExt mode:# from:mode.0?ton.blockIdExt = blocks.ShardBlockProof; +blocks.getOutMsgQueueSizes mode:# wc:mode.0?int32 shard:mode.0?int64 = blocks.OutMsgQueueSizes; onLiteServerQueryResult id:int64 bytes:bytes = Ok; onLiteServerQueryError id:int64 error:error = Ok; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/Tonlib.java b/tonlib/src/main/java/org/ton/java/tonlib/Tonlib.java index aea99ea8..b0ad0660 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/Tonlib.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/Tonlib.java @@ -6,6 +6,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.ToNumberPolicy; +import com.sun.jna.Library; import com.sun.jna.Native; import java.io.InputStream; import java.math.BigInteger; @@ -219,12 +220,19 @@ public Tonlib build() { newLiteServers[0] = liteServers[super.liteServerIndex]; globalConfigCurrent.setLiteservers(newLiteServers); - super.tonlibJson = Native.load(super.pathToTonlibSharedLib, TonlibJsonI.class); + super.tonlibJson = + Native.load( + super.pathToTonlibSharedLib, + // "tonlibjson", + TonlibJsonI.class, + // W32APIOptions.DEFAULT_OPTIONS + Collections.singletonMap(Library.OPTION_STRING_ENCODING, "UTF-8")); Utils.disableNativeOutput(); super.tonlib = super.tonlibJson.tonlib_client_json_create(); - + super.tonlibJson.tonlib_client_set_verbosity_level( + super.tonlib, super.verbosityLevel.ordinal()); Utils.enableNativeOutput(); if (super.printInfo) { @@ -294,7 +302,8 @@ public Tonlib build() { } } - } catch (Exception e) { + } catch (Throwable e) { + e.printStackTrace(); throw new RuntimeException("Error creating tonlib instance: " + e.getMessage()); } return super.build(); @@ -344,10 +353,12 @@ private void reinitTonlibConfig(TonGlobalConfig tonGlobalConfig) { tonlib = tonlibJson.tonlib_client_json_create(); // set verbosity - VerbosityLevelQuery verbosityLevelQuery = - VerbosityLevelQuery.builder().new_verbosity_level(verbosityLevel.ordinal()).build(); - tonlibJson.tonlib_client_json_send(tonlib, gson.toJson(verbosityLevelQuery)); - tonlibJson.tonlib_client_json_receive(tonlib, receiveTimeout); + // VerbosityLevelQuery verbosityLevelQuery = + // VerbosityLevelQuery.builder().new_verbosity_level(verbosityLevel.ordinal()).build(); + // tonlibJson.tonlib_client_json_send(tonlib, gson.toJson(verbosityLevelQuery)); + // tonlibJson.tonlib_client_json_receive(tonlib, receiveTimeout); + + tonlibJson.tonlib_client_set_verbosity_level(tonlib, verbosityLevel.ordinal()); TonlibSetup tonlibSetup = TonlibSetup.builder() @@ -568,6 +579,15 @@ public MasterChainInfo getLast() { } } + public LiteServerVersion getLiteServerVersion() { + synchronized (gson) { + GetLiteServerInfoQuery getLiteServerQuery = GetLiteServerInfoQuery.builder().build(); + + String result = syncAndRead(gson.toJson(getLiteServerQuery)); + return gson.fromJson(result, LiteServerVersion.class); + } + } + public MasterChainInfo getMasterChainInfo() { return getLast(); } @@ -668,6 +688,37 @@ public RawTransactions getRawTransactions( } } + /** + * @param address String + * @param fromTxLt BigInteger + * @param fromTxHash String in base64 format + * @return RawTransactions + */ + public RawTransactions getRawTransactionsV2( + String address, BigInteger fromTxLt, String fromTxHash, int count, boolean tryDecodeMessage) { + + if (isNull(fromTxLt) || isNull(fromTxHash)) { + RawAccountState fullAccountState = + getRawAccountState(AccountAddressOnly.builder().account_address(address).build()); + fromTxLt = fullAccountState.getLast_transaction_id().getLt(); + fromTxHash = fullAccountState.getLast_transaction_id().getHash(); + } + + synchronized (gson) { + GetRawTransactionsV2Query getRawTransactionsQuery = + GetRawTransactionsV2Query.builder() + .account_address(AccountAddressOnly.builder().account_address(address).build()) + .from_transaction_id( + LastTransactionId.builder().lt(fromTxLt).hash(fromTxHash).build()) + .count(count) + .try_decode_message(tryDecodeMessage) + .build(); + + String result = syncAndRead(gson.toJson(getRawTransactionsQuery)); + return gson.fromJson(result, RawTransactions.class); + } + } + /** * Similar to getRawTransactions but limits the number of txs * @@ -1636,6 +1687,20 @@ public SmcLibraryResult getLibraries(List librariesHashes) { } } + /** + * @param librariesHashes list of SmcLibraryQueryExt + * @return SmcLibraryResult + */ + public SmcLibraryResult getLibrariesExt(List librariesHashes) { + synchronized (gson) { + GetLibrariesExtQuery getLibrariesQuery = + GetLibrariesExtQuery.builder().list(librariesHashes).build(); + + String result = syncAndRead(gson.toJson(getLibrariesQuery)); + return libraryResultParser.parse(result); + } + } + public boolean isDeployed(Address address) { return StringUtils.isNotEmpty(this.getRawAccountState(address).getCode()); } diff --git a/tonlib/src/main/java/org/ton/java/tonlib/TonlibJsonI.java b/tonlib/src/main/java/org/ton/java/tonlib/TonlibJsonI.java index 0ab035e6..75f62f21 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/TonlibJsonI.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/TonlibJsonI.java @@ -3,13 +3,15 @@ import com.sun.jna.Library; public interface TonlibJsonI extends Library { - long tonlib_client_json_create(); + long tonlib_client_json_create(); - void tonlib_client_json_destroy(long tonlib); + void tonlib_client_json_destroy(long tonlib); - String tonlib_client_json_execute(long tonlib, String query); + String tonlib_client_json_execute(long tonlib, String query); - String tonlib_client_json_receive(long tonlib, Double size); + String tonlib_client_json_receive(long tonlib, Double size); - void tonlib_client_json_send(long tonlib, String query); + void tonlib_client_json_send(long tonlib, String query); + + void tonlib_client_set_verbosity_level(long tonlib, int verbosity_level); } diff --git a/tonlib/src/main/java/org/ton/java/tonlib/queries/GetLibrariesExtQuery.java b/tonlib/src/main/java/org/ton/java/tonlib/queries/GetLibrariesExtQuery.java new file mode 100644 index 00000000..b6e545c7 --- /dev/null +++ b/tonlib/src/main/java/org/ton/java/tonlib/queries/GetLibrariesExtQuery.java @@ -0,0 +1,20 @@ +package org.ton.java.tonlib.queries; + +import com.google.gson.annotations.SerializedName; +import java.util.List; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.ton.java.tonlib.types.SmcLibraryQueryExt; + +@Builder +@Setter +@Getter +@ToString +public class GetLibrariesExtQuery extends ExtraQuery { + @SerializedName(value = "@type") + final String type = "smc.getLibrariesExt"; + + List list; +} diff --git a/tonlib/src/main/java/org/ton/java/tonlib/queries/GetLiteServerInfoQuery.java b/tonlib/src/main/java/org/ton/java/tonlib/queries/GetLiteServerInfoQuery.java new file mode 100644 index 00000000..fe3bee4a --- /dev/null +++ b/tonlib/src/main/java/org/ton/java/tonlib/queries/GetLiteServerInfoQuery.java @@ -0,0 +1,16 @@ +package org.ton.java.tonlib.queries; + +import com.google.gson.annotations.SerializedName; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Builder +@Setter +@Getter +@ToString +public class GetLiteServerInfoQuery extends ExtraQuery { + @SerializedName("@type") + final String type = "liteServer.getInfo"; +} diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/LiteServerVersion.java b/tonlib/src/main/java/org/ton/java/tonlib/types/LiteServerVersion.java new file mode 100644 index 00000000..8abab54a --- /dev/null +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/LiteServerVersion.java @@ -0,0 +1,22 @@ +package org.ton.java.tonlib.types; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Builder +@Setter +@Getter +@ToString +public class LiteServerVersion implements Serializable { + + @SerializedName("@type") + final String type = "liteServer.info"; + + long now; + long version; + long capabilities; +} diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/RawMessage.java b/tonlib/src/main/java/org/ton/java/tonlib/types/RawMessage.java index 39c386de..c635021e 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/RawMessage.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/RawMessage.java @@ -1,6 +1,9 @@ package org.ton.java.tonlib.types; +import static java.util.Objects.nonNull; + import com.google.gson.annotations.SerializedName; +import java.io.Serializable; import lombok.Builder; import lombok.Data; import org.apache.commons.codec.binary.Hex; @@ -8,10 +11,6 @@ import org.ton.java.cell.CellSlice; import org.ton.java.utils.Utils; -import java.io.Serializable; - -import static java.util.Objects.nonNull; - @Builder @Data public class RawMessage implements Serializable { @@ -37,7 +36,7 @@ public String getMessage() { if (nonNull(msg_data.getBody())) { return msg_data.getBody(); } else { - return Utils.base64ToString(msg_data.getText()); + return Utils.base64ToString(msg_data.getText()); } } diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/SmcLibraryExtResult.java b/tonlib/src/main/java/org/ton/java/tonlib/types/SmcLibraryExtResult.java new file mode 100644 index 00000000..f8445709 --- /dev/null +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/SmcLibraryExtResult.java @@ -0,0 +1,22 @@ +package org.ton.java.tonlib.types; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import java.util.List; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Builder +@Setter +@Getter +@ToString +public class SmcLibraryExtResult implements Serializable { + @SerializedName("@type") + final String type = "smc.LibraryResultExt"; + + String dict_boc; + List libs_ok; + List libs_not_found; +} diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/SmcLibraryQueryExt.java b/tonlib/src/main/java/org/ton/java/tonlib/types/SmcLibraryQueryExt.java new file mode 100644 index 00000000..ac5a57c6 --- /dev/null +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/SmcLibraryQueryExt.java @@ -0,0 +1,22 @@ +package org.ton.java.tonlib.types; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Builder +@Setter +@Getter +@ToString +public class SmcLibraryQueryExt implements Serializable { + @SerializedName("@type") + // final String type = "smc.libraryQueryExt.one"; + final String type = "smc.LibraryQueryExt"; + + long hash; + String boc; + long max_libs; +} diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/SmcLibraryQueryExtScanBoc.java b/tonlib/src/main/java/org/ton/java/tonlib/types/SmcLibraryQueryExtScanBoc.java new file mode 100644 index 00000000..e24b4817 --- /dev/null +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/SmcLibraryQueryExtScanBoc.java @@ -0,0 +1,20 @@ +package org.ton.java.tonlib.types; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Builder +@Setter +@Getter +@ToString +public class SmcLibraryQueryExtScanBoc implements Serializable { + @SerializedName("@type") + final String type = "smc.libraryQueryExt.scanBoc"; + + String boc; + long max_libs; +} diff --git a/tonlib/src/test/java/org/ton/java/tonlib/TestTonlibJson.java b/tonlib/src/test/java/org/ton/java/tonlib/TestTonlibJson.java index 79c0cff5..f7661929 100644 --- a/tonlib/src/test/java/org/ton/java/tonlib/TestTonlibJson.java +++ b/tonlib/src/test/java/org/ton/java/tonlib/TestTonlibJson.java @@ -6,16 +6,14 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.iwebpp.crypto.TweetNaclFast; +import com.sun.jna.Library; import com.sun.jna.Native; import java.io.IOException; import java.io.InputStream; import java.math.BigInteger; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; -import java.util.ArrayDeque; -import java.util.Collections; -import java.util.Deque; -import java.util.Map; +import java.util.*; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; @@ -51,24 +49,39 @@ public class TestTonlibJson { public static void setUpBeforeClass() { // works only when running tests, since ton4j does not ship integrated tonlibjson shared library - String resourcePath = Utils.getResourceAbsoluteDirectory(ClassLoader.getSystemClassLoader(), "tonlibjson.dll"); +// String resourcePath = Utils.getResourceAbsoluteDirectory(ClassLoader.getSystemClassLoader(), "tonlibjson.dll"); +// +// tonlib = Tonlib.builder() +// .pathToTonlibSharedLib(resourcePath) +// .receiveTimeout(5) +// .ignoreCache(false) +// .build(); + } + + @Test + public void testIssue13() { + System.setProperty("jna.library.path","G:\\Git_Projects\\ton-neodix42\\artifacts"); - tonlib = Tonlib.builder() - .pathToTonlibSharedLib(resourcePath) + Tonlib tonlib = Tonlib.builder() + .pathToTonlibSharedLib("tonlibjson.dll") .receiveTimeout(5) .ignoreCache(false) .build(); - } - @Test - public void testIssue13() { BlockIdExt block = tonlib.getLast().getLast(); log.info("block {}", block); } + @Test + public void testGetLiteServerVersion() { + LiteServerVersion liteServerVersion = tonlib.getLiteServerVersion(); + log.info("liteServerVersion {}", liteServerVersion); + } + @Test public void testInitTonlibJson() throws IOException { - TonlibJsonI tonlibJson = Native.load("tonlibjson.dll", TonlibJsonI.class); + TonlibJsonI tonlibJson = Native.load("tonlibjson", TonlibJsonI.class, + Collections.singletonMap(Library.OPTION_STRING_ENCODING, "UTF-8")); long tonlib = tonlibJson.tonlib_client_json_create(); @@ -357,6 +370,96 @@ public void testTonlibGetTxsByAddress() { assertThat(rawTransactions.getTransactions().size()).isLessThan(20); } + @Test + public void testTonlibGetTxsByAddressTestnet() { + + // works only when running tests, since ton4j does not ship integrated tonlibjson shared library + String resourcePath = Utils.getResourceAbsoluteDirectory(ClassLoader.getSystemClassLoader(), "tonlibjson.dll"); + + Tonlib tonlib = Tonlib.builder() + .pathToTonlibSharedLib(resourcePath) + .verbosityLevel(VerbosityLevel.DEBUG) + .ignoreCache(false) + .testnet(true) + .build(); + Address address = Address.of("0:b52a16ba3735501df19997550e7ed4c41754ee501ded8a841088ce4278b66de4"); + + log.info("address: " + address.toBounceable()); + + RawTransactions rawTransactions = tonlib.getRawTransactions(address.toRaw(), null, null); + + log.info("total txs: {}", rawTransactions.getTransactions().size()); + + for (RawTransaction tx : rawTransactions.getTransactions()) { + if (nonNull(tx.getIn_msg()) + && (!tx.getIn_msg().getSource().getAccount_address().equals(""))) { + log.info("rawTx {}", tx); + log.info( + "{}, {} <<<<< {} : {} ", + Utils.toUTC(tx.getUtime()), + tx.getIn_msg().getSource().getAccount_address(), + tx.getIn_msg().getDestination().getAccount_address(), + Utils.formatNanoValue(tx.getIn_msg().getValue())); + } + if (nonNull(tx.getOut_msgs())) { + for (RawMessage msg : tx.getOut_msgs()) { + log.info( + "{}, {} >>>>> {} : {} ", + Utils.toUTC(tx.getUtime()), + msg.getSource().getAccount_address(), + msg.getDestination().getAccount_address(), + Utils.formatNanoValue(msg.getValue())); + } + } + } + } + + @Test + public void testTonlibGetTxsV2ByAddressTestnet() { + + // works only when running tests, since ton4j does not ship integrated tonlibjson shared library + String resourcePath = Utils.getResourceAbsoluteDirectory(ClassLoader.getSystemClassLoader(), "tonlibjson.dll"); + + Tonlib tonlib = Tonlib.builder() + .pathToTonlibSharedLib(resourcePath) + .verbosityLevel(VerbosityLevel.DEBUG) + .ignoreCache(false) + .testnet(true) + .build(); + Address address = Address.of("0:b52a16ba3735501df19997550e7ed4c41754ee501ded8a841088ce4278b66de4"); + + log.info("address: " + address.toBounceable()); + + RawTransactions rawTransactions = tonlib.getRawTransactionsV2(address.toRaw(), null, null, 10, true); + + log.info("total txs: {}", rawTransactions.getTransactions().size()); + + for (RawTransaction tx : rawTransactions.getTransactions()) { + if (nonNull(tx.getIn_msg()) + && (!tx.getIn_msg().getSource().getAccount_address().equals(""))) { + log.info("rawTx {}", tx); + log.info( + "{}, {} <<<<< {} : {} ", + Utils.toUTC(tx.getUtime()), + tx.getIn_msg().getSource().getAccount_address(), + tx.getIn_msg().getDestination().getAccount_address(), + Utils.formatNanoValue(tx.getIn_msg().getValue())); + } + if (nonNull(tx.getOut_msgs())) { + for (RawMessage msg : tx.getOut_msgs()) { + log.info( + "{}, {} >>>>> {} : {} ", + Utils.toUTC(tx.getUtime()), + msg.getSource().getAccount_address(), + msg.getDestination().getAccount_address(), + Utils.formatNanoValue(msg.getValue())); + } + } + } + + assertThat(rawTransactions.getTransactions().size()).isLessThan(20); + } + @Test public void testTonlibGetTxsWithLimitByAddress() { Address address = Address.of(TON_FOUNDATION); @@ -968,6 +1071,27 @@ public void testTonlibGetLibraries() { .isEqualTo("wkUmK4wrzl6fzSPKM04dVfqW1M5pqigX3tcXzvy6P3M="); } + @Test + public void testTonlibGetLibrariesExt() { + BigInteger arg1 = + new BigInteger("6aaf20fed58ba5e6db692909e78e5c5c6525e28d1cfa8bd22dc216729b4841b3", 16); + + SmcLibraryQueryExt smcLibraryQueryExt = SmcLibraryQueryExt.builder() + .boc("b5ee9c72410101010024000043801482bf04d1769cf0b59f5ffd4cbf659b5e1d9ddd2eccc47901ec29242b3fd76fb07111e8d8") + .max_libs(10) + .hash(arg1.longValue()) + .build(); + List list = new ArrayList<>(); + list.add(smcLibraryQueryExt); + + SmcLibraryResult result = + tonlib.getLibrariesExt(list); + log.info("result: {}", result); + + assertThat(result.getResult().get(0).getHash()) + .isEqualTo("wkUmK4wrzl6fzSPKM04dVfqW1M5pqigX3tcXzvy6P3M="); + } + @Test public void testTonlibRunMethodGetSrcAddr() { Tonlib tonlib = Tonlib.builder().testnet(false).ignoreCache(false).build(); diff --git a/tonlib/src/test/resources/tonlibjson.dll b/tonlib/src/test/resources/tonlibjson.dll index 9c44f37a..f7c2bcec 100644 Binary files a/tonlib/src/test/resources/tonlibjson.dll and b/tonlib/src/test/resources/tonlibjson.dll differ diff --git a/utils/src/main/java/org/ton/java/utils/Utils.java b/utils/src/main/java/org/ton/java/utils/Utils.java index 4906b2a7..5cb9d133 100644 --- a/utils/src/main/java/org/ton/java/utils/Utils.java +++ b/utils/src/main/java/org/ton/java/utils/Utils.java @@ -4,11 +4,8 @@ import com.iwebpp.crypto.TweetNaclFast; import com.sun.jna.Library; -import com.sun.jna.Native; -import com.sun.jna.platform.win32.Kernel32; import com.sun.jna.platform.win32.WinNT; import java.io.*; -import java.lang.reflect.Field; import java.math.BigDecimal; import java.math.BigInteger; import java.math.RoundingMode; @@ -1069,110 +1066,113 @@ public interface CStdLib extends Library { static CStdLib cStdLib; public static void disableNativeOutput() { - // System.out.println("disable"); - try { - if ((Utils.getOS() == Utils.OS.WINDOWS) || (Utils.getOS() == Utils.OS.WINDOWS_ARM)) { - // Redirect native output on Windows - originalOut = Kernel32.INSTANCE.GetStdHandle(Kernel32.STD_OUTPUT_HANDLE); - originalErr = Kernel32.INSTANCE.GetStdHandle(Kernel32.STD_ERROR_HANDLE); - - try { - FileOutputStream nulStream = new FileOutputStream("NUL"); - - WinNT.HANDLE hNul = - Kernel32.INSTANCE.CreateFile( - "NUL", - Kernel32.GENERIC_WRITE, - Kernel32.FILE_SHARE_WRITE, - null, - Kernel32.OPEN_EXISTING, - 0, - null); - - // Redirect stdout and stderr to NUL - Kernel32.INSTANCE.SetStdHandle(Kernel32.STD_OUTPUT_HANDLE, hNul); - Kernel32.INSTANCE.SetStdHandle(Kernel32.STD_ERROR_HANDLE, hNul); - - // Close the handle to NUL - Kernel32.INSTANCE.CloseHandle(hNul); - } catch (IOException e) { - // throw new RuntimeException(e); - } - } else if ((Utils.getOS() == Utils.OS.LINUX) || (Utils.getOS() == Utils.OS.LINUX_ARM)) { - try { - // Load the native library - cStdLib = Native.load("c", CStdLib.class); - - // Save original stdout and stderr file descriptors - originalStdoutFD = cStdLib.dup(1); - originalStderrFD = cStdLib.dup(2); - - // Redirect stdout and stderr to /dev/null - try (FileOutputStream devNull = new FileOutputStream("/dev/null")) { - // Get the file descriptor for /dev/null - FileDescriptor fd = devNull.getFD(); - - // Get the file descriptor integer value by accessing the private field via reflection - // Retrieve the field that holds the actual fd (in a private field) - Field fdField = FileDescriptor.class.getDeclaredField("fd"); - fdField.setAccessible(true); - int devNullFD = (int) fdField.get(fd); - - cStdLib.dup2(devNullFD, 1); - cStdLib.dup2(devNullFD, 2); - - } catch (IOException | NoSuchFieldException | IllegalAccessException e) { - throw new RuntimeException(e); - } - } catch (Exception e) { - // System.out.println("error here " + e.getMessage()); - } - } else if ((Utils.getOS() == Utils.OS.MAC) || (Utils.getOS() == Utils.OS.MAC_ARM64)) { - // Load the native library - CStdLib cStdLib = Native.load("c", CStdLib.class); - - // Redirect stdout and stderr to /dev/null - try (FileOutputStream devNull = new FileOutputStream("/dev/null")) { - // Get the file descriptor for /dev/null - FileDescriptor fd = devNull.getFD(); - - // Get the file descriptor integer value by accessing the private field via reflection - // Retrieve the field that holds the actual fd (in a private field) - Field fdField = FileDescriptor.class.getDeclaredField("fd"); - fdField.setAccessible(true); - int devNullFD = (int) fdField.get(fd); - - // Duplicate and redirect stdout and stderr - int stdoutFD = 1; // File descriptor for stdout - int stderrFD = 2; // File descriptor for stderr - cStdLib.dup2(devNullFD, stdoutFD); - cStdLib.dup2(devNullFD, stderrFD); - - } catch (IOException | NoSuchFieldException | IllegalAccessException e) { - throw new RuntimeException(e); - } - } - } catch (Exception e) { - // System.err.println("cannot disable native stdout"); - } + // + // // System.out.println("disable"); + // try { + // if ((Utils.getOS() == Utils.OS.WINDOWS) || (Utils.getOS() == Utils.OS.WINDOWS_ARM)) { + // // Redirect native output on Windows + // originalOut = Kernel32.INSTANCE.GetStdHandle(Kernel32.STD_OUTPUT_HANDLE); + // originalErr = Kernel32.INSTANCE.GetStdHandle(Kernel32.STD_ERROR_HANDLE); + // + // try { + // FileOutputStream nulStream = new FileOutputStream("NUL"); + // + // WinNT.HANDLE hNul = + // Kernel32.INSTANCE.CreateFile( + // "NUL", + // Kernel32.GENERIC_WRITE, + // Kernel32.FILE_SHARE_WRITE, + // null, + // Kernel32.OPEN_EXISTING, + // 0, + // null); + // + // // Redirect stdout and stderr to NUL + // Kernel32.INSTANCE.SetStdHandle(Kernel32.STD_OUTPUT_HANDLE, hNul); + // Kernel32.INSTANCE.SetStdHandle(Kernel32.STD_ERROR_HANDLE, hNul); + // + // // Close the handle to NUL + // Kernel32.INSTANCE.CloseHandle(hNul); + // } catch (IOException e) { + // // throw new RuntimeException(e); + // } + // } else if ((Utils.getOS() == Utils.OS.LINUX) || (Utils.getOS() == Utils.OS.LINUX_ARM)) { + // try { + // // Load the native library + // cStdLib = Native.load("c", CStdLib.class); + // + // // Save original stdout and stderr file descriptors + // originalStdoutFD = cStdLib.dup(1); + // originalStderrFD = cStdLib.dup(2); + // + // // Redirect stdout and stderr to /dev/null + // try (FileOutputStream devNull = new FileOutputStream("/dev/null")) { + // // Get the file descriptor for /dev/null + // FileDescriptor fd = devNull.getFD(); + // + // // Get the file descriptor integer value by accessing the private field via + // reflection + // // Retrieve the field that holds the actual fd (in a private field) + // Field fdField = FileDescriptor.class.getDeclaredField("fd"); + // fdField.setAccessible(true); + // int devNullFD = (int) fdField.get(fd); + // + // cStdLib.dup2(devNullFD, 1); + // cStdLib.dup2(devNullFD, 2); + // + // } catch (IOException | NoSuchFieldException | IllegalAccessException e) { + // throw new RuntimeException(e); + // } + // } catch (Exception e) { + // // System.out.println("error here " + e.getMessage()); + // } + // } else if ((Utils.getOS() == Utils.OS.MAC) || (Utils.getOS() == Utils.OS.MAC_ARM64)) { + // // Load the native library + // CStdLib cStdLib = Native.load("c", CStdLib.class); + // + // // Redirect stdout and stderr to /dev/null + // try (FileOutputStream devNull = new FileOutputStream("/dev/null")) { + // // Get the file descriptor for /dev/null + // FileDescriptor fd = devNull.getFD(); + // + // // Get the file descriptor integer value by accessing the private field via + // reflection + // // Retrieve the field that holds the actual fd (in a private field) + // Field fdField = FileDescriptor.class.getDeclaredField("fd"); + // fdField.setAccessible(true); + // int devNullFD = (int) fdField.get(fd); + // + // // Duplicate and redirect stdout and stderr + // int stdoutFD = 1; // File descriptor for stdout + // int stderrFD = 2; // File descriptor for stderr + // cStdLib.dup2(devNullFD, stdoutFD); + // cStdLib.dup2(devNullFD, stderrFD); + // + // } catch (IOException | NoSuchFieldException | IllegalAccessException e) { + // throw new RuntimeException(e); + // } + // } + // } catch (Exception e) { + // // System.err.println("cannot disable native stdout"); + // } } public static void enableNativeOutput() { - try { - if ((Utils.getOS() == Utils.OS.WINDOWS) || (Utils.getOS() == Utils.OS.WINDOWS_ARM)) { - Kernel32.INSTANCE.SetStdHandle(Kernel32.STD_OUTPUT_HANDLE, originalOut); - Kernel32.INSTANCE.SetStdHandle(Kernel32.STD_ERROR_HANDLE, originalErr); - } else if ((Utils.getOS() == Utils.OS.LINUX) || (Utils.getOS() == Utils.OS.LINUX_ARM)) { - cStdLib.dup2(originalStdoutFD, 1); - cStdLib.dup2(originalStderrFD, 2); - } else if ((Utils.getOS() == Utils.OS.MAC) || (Utils.getOS() == Utils.OS.MAC_ARM64)) { - cStdLib.dup2(originalStdoutFD, 1); - cStdLib.dup2(originalStderrFD, 2); - } - } catch (Exception e) { - // System.err.println("cannot enable native stdout"); - } - // System.out.println("enable"); + // try { + // if ((Utils.getOS() == Utils.OS.WINDOWS) || (Utils.getOS() == Utils.OS.WINDOWS_ARM)) { + // Kernel32.INSTANCE.SetStdHandle(Kernel32.STD_OUTPUT_HANDLE, originalOut); + // Kernel32.INSTANCE.SetStdHandle(Kernel32.STD_ERROR_HANDLE, originalErr); + // } else if ((Utils.getOS() == Utils.OS.LINUX) || (Utils.getOS() == Utils.OS.LINUX_ARM)) { + // cStdLib.dup2(originalStdoutFD, 1); + // cStdLib.dup2(originalStderrFD, 2); + // } else if ((Utils.getOS() == Utils.OS.MAC) || (Utils.getOS() == Utils.OS.MAC_ARM64)) { + // cStdLib.dup2(originalStdoutFD, 1); + // cStdLib.dup2(originalStderrFD, 2); + // } + // } catch (Exception e) { + // // System.err.println("cannot enable native stdout"); + // } + // // System.out.println("enable"); } public static String convertShardIdentToShard(BigInteger shardPrefix, int prefixBits) {