Skip to content

Commit 00986ab

Browse files
authored
Merge pull request #7 from tonlabs/0.25.0-rc
Version 0.25.0
2 parents 8033368 + 76c1561 commit 00986ab

File tree

17 files changed

+402
-226
lines changed

17 files changed

+402
-226
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ block-signer-config.json
2828
/ton-node-se/pub-key
2929
/ton-node-se/log_cfg.yml
3030
/ton-node-se/tonos-se-tests
31+
workchains
3132
docker/.DS_Store
3233
readme.html

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Release Notes
22
All notable changes to this project will be documented in this file.
33

4+
## 0.25.0 Mar 05, 2021
5+
### New
6+
- [New high-load Giver with ABI Version 2](contracts) is supported. Now you can run your tests in parallel, giver supports up to 100 parallel requests at a time (previous giver had timestamp-based replay protection which didn't allow often access)
7+
48
## 0.24.13 Feb 26, 2021
59
### Fixed
610
- Documentation update

readme.md renamed to README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Local blockchain for Free TON DApp development and testing.
1313
- [Instal via TONDEV Development Environment](#instal-via-tondev-development-environment)
1414
- [Install via docker command](#install-via-docker-command)
1515
- [How to connect to TON OS SE Graphql API from SDK](#how-to-connect-to-ton-os-se-graphql-api-from-sdk)
16-
- [TON OS SE components:](#ton-os-se-components)
16+
- [TON OS SE components](#ton-os-se-components)
1717
- [How to build docker image locally](#how-to-build-docker-image-locally)
1818
- [Linux/Mac:](#linuxmac)
1919
- [Windows:](#windows)
@@ -71,13 +71,12 @@ If you specified another port then add it to the local url http://0.0.0.0:port/g
7171
To connect to local blockchain from your application [specify localhost in SDK Client network config](https://docs.ton.dev/86757ecb2/p/5328db-tonclient).
7272

7373

74-
## TON OS SE components:
74+
## TON OS SE components
7575

7676
* [TON Labs implementation of TON VM written in Rust](https://github.com/tonlabs/ton-labs-vm)
7777
* [ArangoDB database](https://www.arangodb.com/)
7878
* [GraphQL endpoint with web playground](https://docs.ton.dev/86757ecb2/p/793337-graphql-api)
79-
* [Pre-deployed Giver](https://docs.ton.dev/86757ecb2/p/00f9a3-ton-os-se-giver)
80-
79+
* [Pre-deployed high-performance Giver, ABI v2](contracts)
8180

8281
## How to build docker image locally
8382

contracts/GiverV2.abi.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{"ABI version": 2,
2+
"header": ["time", "expire"],
3+
"functions": [
4+
{
5+
"name": "upgrade",
6+
"inputs": [
7+
{"name":"newcode","type":"cell"}
8+
],
9+
"outputs": [
10+
]
11+
},
12+
{
13+
"name": "sendTransaction",
14+
"inputs": [
15+
{"name":"dest","type":"address"},
16+
{"name":"value","type":"uint128"},
17+
{"name":"bounce","type":"bool"}
18+
],
19+
"outputs": [
20+
]
21+
},
22+
{
23+
"name": "getMessages",
24+
"inputs": [
25+
],
26+
"outputs": [
27+
{"components":[{"name":"hash","type":"uint256"},{"name":"expireAt","type":"uint64"}],"name":"messages","type":"tuple[]"}
28+
]
29+
},
30+
{
31+
"name": "constructor",
32+
"inputs": [
33+
],
34+
"outputs": [
35+
]
36+
}
37+
],
38+
"events": [
39+
]
40+
}

contracts/GiverV2.keys.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"public": "2ada2e65ab8eeab09490e3521415f45b6e42df9c760a639bcf53957550b25a16",
3+
"secret": "172af540e43a524763dd53b26a066d472a97c4de37d5498170564510608250c3"
4+
}

contracts/GiverV2.sol

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
pragma solidity >=0.6.0;
2+
pragma AbiHeader time;
3+
pragma AbiHeader expire;
4+
5+
abstract contract Upgradable {
6+
/*
7+
* Set code
8+
*/
9+
10+
function upgrade(TvmCell newcode) public virtual {
11+
require(msg.pubkey() == tvm.pubkey(), 101);
12+
tvm.accept();
13+
tvm.commit();
14+
tvm.setcode(newcode);
15+
tvm.setCurrentCode(newcode);
16+
onCodeUpgrade();
17+
}
18+
19+
function onCodeUpgrade() internal virtual;
20+
}
21+
22+
contract GiverV2 is Upgradable {
23+
24+
mapping(uint256 => uint64) m_messages;
25+
26+
modifier acceptOnlyOwner {
27+
require(msg.pubkey() == tvm.pubkey(), 101);
28+
tvm.accept();
29+
_;
30+
}
31+
32+
/*
33+
* Publics
34+
*/
35+
36+
/// @notice Allows to accept simple transfers.
37+
receive() external {}
38+
39+
/// @notice Transfers grams to other contracts.
40+
function sendTransaction(address dest, uint128 value, bool bounce) public {
41+
dest.transfer(value, bounce, 3);
42+
gc();
43+
}
44+
45+
/*
46+
* Privates
47+
*/
48+
49+
/// @notice Function with predefined name called after signature check. Used to
50+
/// implement custom replay protection with parallel access.
51+
function afterSignatureCheck(TvmSlice body, TvmCell message) private inline
52+
returns (TvmSlice)
53+
{
54+
// owner check
55+
require(msg.pubkey() == tvm.pubkey(), 101);
56+
// load and drop message timestamp (uint64)
57+
(, uint64 expireAt) = body.decode(uint64, uint32);
58+
require(expireAt > now, 57);
59+
uint256 msgHash = tvm.hash(message);
60+
require(!m_messages.exists(msgHash), 102);
61+
62+
tvm.accept();
63+
m_messages[msgHash] = expireAt;
64+
65+
return body;
66+
}
67+
68+
/// @notice Allows to delete expired messages from dict.
69+
function gc() private inline {
70+
(uint256 msgHash, uint64 expireAt, bool ok) = m_messages.min();
71+
while (ok) {
72+
if (expireAt <= now) {
73+
delete m_messages[msgHash];
74+
}
75+
(msgHash, expireAt, ok) = m_messages.next(msgHash);
76+
}
77+
}
78+
79+
/*
80+
* Get methods
81+
*/
82+
struct Message {
83+
uint256 hash;
84+
uint64 expireAt;
85+
}
86+
function getMessages() public view returns (Message[] messages) {
87+
(uint256 msgHash, uint64 expireAt, bool ok) = m_messages.min();
88+
while (ok) {
89+
messages.push(Message(msgHash, expireAt));
90+
(msgHash, expireAt, ok) = m_messages.next(msgHash);
91+
}
92+
}
93+
94+
function onCodeUpgrade() internal override {}
95+
}

contracts/GiverV2.tvc

999 Bytes
Binary file not shown.

contracts/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Giver v2
2+
3+
This directory contains Giver v2 (ABI v2) contract. This giver is recommended over Giver v1.
4+
5+
In TON OS SE this giver is predeployed at `0:b5e9240fc2d2f1ff8cbb1d1dee7fb7cae155e5f6320e585fcc685698994a19a5` address
6+
and its initial balance is about 5 billion tokens.
7+
8+
## Keys:
9+
* Public: `2ada2e65ab8eeab09490e3521415f45b6e42df9c760a639bcf53957550b25a16`
10+
* Secret: `172af540e43a524763dd53b26a066d472a97c4de37d5498170564510608250c3`
11+
12+
## Usage
13+
Method: `sendTransaction`
14+
15+
parameters:
16+
* `dest`: `address` - destination address;
17+
* `value`: `uint128` - amount to send, in nanotokens;
18+
* `bounce`: `bool` - bounce flag of the message.
19+
20+
### Using tonos-cli:
21+
```commandline
22+
tonos-cli call 0:b5e9240fc2d2f1ff8cbb1d1dee7fb7cae155e5f6320e585fcc685698994a19a5 \
23+
sendTransaction '{"dest":"<address>","value":<nanotokens>,"bounce":false}' \
24+
--abi GiverV2.abi.json \
25+
--sign GiverV2.keys.json
26+
```
27+
28+
29+
## Files
30+
* ABI: [GiverV2.abi.json](GiverV2.abi.json)
31+
* Keypair: [GiverV2.keys.json](GiverV2.keys.json)
32+
* TVC file: [GiverV2.tvc](GiverV2.tvc)
33+
* Source code: [GiverV2.sol](GiverV2.sol)

ton-node-se/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[workspace]
22
members = [
33
"ton_node_startup",
4+
"create_msg",
45
]

ton-node-se/Dockerfile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ COPY --from=build-kit \
5555
/ton-node/ton_node/entrypoint \
5656
/node/
5757

58-
# create-msg
59-
COPY --from=build-kit \
60-
/ton-node/target/release/create-msg \
61-
/node/create-msg/create-msg
62-
6358
WORKDIR /node
6459

6560
EXPOSE 3030

0 commit comments

Comments
 (0)