Skip to content

Commit

Permalink
Merge pull request #124 from tonlabs/0.37.0-rc
Browse files Browse the repository at this point in the history
Version 0.37.0
  • Loading branch information
d3p authored Feb 17, 2023
2 parents 4cf46a8 + 0b98a6c commit 82ca711
Show file tree
Hide file tree
Showing 39 changed files with 807 additions and 908 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ block-signer-config.json
/ton-node-se/pub-key
/ton-node-se/log_cfg.yml
/ton-node-se/tonos-se-tests
workchains
docker/.DS_Store
readme.html
/dev/node_modules/
/dev/package-lock.json
/node/target/
/target/
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
# Release Notes
All notable changes to this project will be documented in this file.

## 0.37.0 Jan 11, 2023

### New

- Produces masterchain block for each workchain block.
- Added ability to update blockchain config with node restart (without killing the database). After [changing the config](https://github.com/tonlabs/evernode-se#how-to-change-the-blockchain-configuration) stop and start the node to apply it. It will produce new key block from the new config.
- `CapSignatureWithId` capability is supported: `global_id` parameter is used as a `signature_id` if `CapSignatureWithId` cap is turned
on in the blockchain config.

### Fixed
- `global_id` parameter in `ton-node.conf.json` is written into blocks.


## 0.36.3 Jan 11, 2023

### Fixed
Expand Down
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[workspace]
members = [
"node",
]

exclude = [
]
9 changes: 7 additions & 2 deletions contracts/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Smart Contracts, used in Evernode SE
* [Giver v2](giver_v2)
* [SafeMultisig Wallet](safe_multisig)

|Giver type | Address | Comment
| --------------- | -------------------------------------------------------------------|------
| [GiverV3](giver_v3) | 0:96137b99dcd65afce5a54a48dac83c0fd276432abbe3ba7f1bfb0fb795e69025 | Recommented Giver version
| [SafeMultisig](safe_multisig) | 0:d5f5cfc4b52d2eb1bd9d3a8e51707872c7ce0c174facddd0e06ae5ffd17d2fcd | Safe Multisig as Giver.
| [GiverV2](giver_v2) | 0:ece57bcc6c530283becbbd8a3b24d3c5987cdddc3c8b7b33be6e4a6312490415 | Deprecated. Recommended to use GiverV3
| GiverV1 | 0:841288ed3b55d9cdafa806807f02a0ae0c169aa5edfe88a789a6482429756a94 | Deprecated. Recommended to use GiverV3


7 changes: 4 additions & 3 deletions contracts/giver_v2/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Giver v2

This directory contains Giver v2 (ABI v2) contract. This giver is recommended over Giver v1 because ABI v1 is deprecated.
This directory contains Giver v2 (ABI v2) contract.

In Evernode SE this giver is predeployed at `0:ece57bcc6c530283becbbd8a3b24d3c5987cdddc3c8b7b33be6e4a6312490415` address
and its initial balance is about 5 billion tokens.

If you want to compile and deploy your own v2 giver you can find its fresh version in `giver_for_Sol_0.59.0_abi.2.2` folder that is compatible with the latest compiler version. We do not deploy this giver to SE because it has the same ABI, but will cause a breaking change because a lot of tools and scripts use the old `0:ece57bc...` address.
It is not recommented to use in production or recompile Giver V2 because its works on old Solidity version.
If you want to make changes to the Giver contract or use it in production - use [Giver V3](../giver_v3) version which can be successfully compiled with the latest Solidity compiler.

## Keys:
* Public: `2ada2e65ab8eeab09490e3521415f45b6e42df9c760a639bcf53957550b25a16`
Expand All @@ -24,7 +25,7 @@ parameters:
tonos-cli call 0:ece57bcc6c530283becbbd8a3b24d3c5987cdddc3c8b7b33be6e4a6312490415 \
sendTransaction '{"dest":"<address>","value":<nanotokens>,"bounce":false}' \
--abi GiverV2.abi.json \
--sign GiverV2.keys.json
--sign seGiver.keys.json
```


Expand Down
File renamed without changes.
94 changes: 47 additions & 47 deletions contracts/giver_v3/GiverV3.abi.json
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
{
"ABI version": 2,
"version": "2.2",
"header": ["time", "expire"],
"functions": [
{
"name": "sendTransaction",
"inputs": [
{"name":"dest","type":"address"},
{"name":"value","type":"uint128"},
{"name":"bounce","type":"bool"}
],
"outputs": [
]
},
{
"name": "getMessages",
"inputs": [
],
"outputs": [
{"components":[{"name":"hash","type":"uint256"},{"name":"expireAt","type":"uint64"}],"name":"messages","type":"tuple[]"}
]
},
{
"name": "upgrade",
"inputs": [
{"name":"newcode","type":"cell"}
],
"outputs": [
]
},
{
"name": "constructor",
"inputs": [
],
"outputs": [
]
}
],
"data": [
],
"events": [
],
"fields": [
{"name":"_pubkey","type":"uint256"},
{"name":"_constructorFlag","type":"bool"},
{"name":"m_messages","type":"map(uint256,uint64)"}
]
"ABI version": 2,
"version": "2.3",
"header": ["time", "expire"],
"functions": [
{
"name": "sendTransaction",
"inputs": [
{"name":"dest","type":"address"},
{"name":"value","type":"uint128"},
{"name":"bounce","type":"bool"}
],
"outputs": [
]
},
{
"name": "getMessages",
"inputs": [
],
"outputs": [
{"components":[{"name":"hash","type":"uint256"},{"name":"expireAt","type":"uint32"}],"name":"messages","type":"tuple[]"}
]
},
{
"name": "upgrade",
"inputs": [
{"name":"newcode","type":"cell"}
],
"outputs": [
]
},
{
"name": "constructor",
"inputs": [
],
"outputs": [
]
}
],
"data": [
],
"events": [
],
"fields": [
{"name":"_pubkey","type":"uint256"},
{"name":"_constructorFlag","type":"bool"},
{"name":"m_messages","type":"map(uint256,uint32)"}
]
}
22 changes: 11 additions & 11 deletions contracts/giver_v3/GiverV3.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma ton-solidity >= 0.59.0;
pragma ever-solidity >= 0.61.2;
pragma AbiHeader time;
pragma AbiHeader expire;

Expand All @@ -22,7 +22,7 @@ abstract contract Upgradable {
contract GiverV3 is Upgradable {

uint8 constant MAX_CLEANUP_MSGS = 30;
mapping(uint256 => uint64) m_messages;
mapping(uint256 => uint32) m_messages;

modifier acceptOnlyOwner {
require(msg.pubkey() == tvm.pubkey(), 101);
Expand All @@ -49,33 +49,33 @@ contract GiverV3 is Upgradable {

/// @notice Function with predefined name called after signature check. Used to
/// implement custom replay protection with parallel access.
function afterSignatureCheck(TvmSlice body, TvmCell message) private inline
function afterSignatureCheck(TvmSlice body, TvmCell) private inline
returns (TvmSlice)
{
// owner check
require(msg.pubkey() == tvm.pubkey(), 101);
uint256 bodyHash = tvm.hash(body);
// load and drop message timestamp (uint64)
(, uint64 expireAt) = body.decode(uint64, uint32);
(, uint32 expireAt) = body.decode(uint64, uint32);
require(expireAt > now, 57);
uint256 msgHash = tvm.hash(message);
require(!m_messages.exists(msgHash), 102);
require(!m_messages.exists(bodyHash), 102);

tvm.accept();
m_messages[msgHash] = expireAt;
m_messages[bodyHash] = expireAt;

return body;
}

/// @notice Allows to delete expired messages from dict.
function gc() private inline {
uint counter = 0;
for ((uint256 msgHash, uint64 expireAt) : m_messages) {
for ((uint256 bodyHash, uint32 expireAt) : m_messages) {
if (counter >= MAX_CLEANUP_MSGS) {
break;
}
counter++;
if (expireAt <= now) {
delete m_messages[msgHash];
delete m_messages[bodyHash];
}
}
}
Expand All @@ -85,10 +85,10 @@ contract GiverV3 is Upgradable {
*/
struct Message {
uint256 hash;
uint64 expireAt;
uint32 expireAt;
}
function getMessages() public view returns (Message[] messages) {
for ((uint256 msgHash, uint64 expireAt) : m_messages) {
for ((uint256 msgHash, uint32 expireAt) : m_messages) {
messages.push(Message(msgHash, expireAt));
}
}
Expand Down
Binary file modified contracts/giver_v3/GiverV3.tvc
Binary file not shown.
69 changes: 46 additions & 23 deletions contracts/giver_v3/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
# Giver v3

This directory contains Giver v3 (ABI v2.2) contract. This giver is recommended over Giver v1 or v2.
This directory contains Giver v3 contract. This giver is recommended to use with solc version above 0.61.2 to deploy it on devnet or mainnet.

In Evernode SE this giver is predeployed (since version `TODO`) at `0:78fbd6980c10cf41401b32e9b51810415e7578b52403af80dae68ddf99714498` address
In Evernode SE this giver is predeployed at `0:96137b99dcd65afce5a54a48dac83c0fd276432abbe3ba7f1bfb0fb795e69025` address
and its initial balance is about 5 billion tokens.

## Keys:

> ⚠ Using only local and dev environment
* Public: `2ada2e65ab8eeab09490e3521415f45b6e42df9c760a639bcf53957550b25a16`
* Secret: `172af540e43a524763dd53b26a066d472a97c4de37d5498170564510608250c3`

Expand All @@ -21,46 +18,72 @@ parameters:
* `bounce`: `bool` - bounce flag of the message.

### Using tonos-cli:
```shell
npx tonos-cli call 0:78fbd6980c10cf41401b32e9b51810415e7578b52403af80dae68ddf99714498 \
```commandline
tonos-cli call 0:cbd3ef42dcc261b9369fdb15fb836b460d4806c5b255e31541c46d6676a2f13d \
sendTransaction '{"dest":"<address>","value":<nanotokens>,"bounce":false}' \
--abi GiverV2.abi.json \
--sign GiverV2.keys.json
--abi GiverV3.abi.json \
--sign seGiver.keys.json
```

## Self deploy
## How to deploy GiverV3 on any network

### Compile
### Setup your signer
You can skip this step if you already have one.
```shell
npx everdev sol set --compiler 0.59.4 --linker 0.15.24
npx everdev sol compile GiverV3.sol
npx everdev signer add devnet_giver_keys <private_key>
npx everdev signer default devnet_giver_keys
```

> ℹ️ For compiler v0.59.4 and linker v0.15.2 code hash is `726aec999006a2e036af36c46024237acb946c13b4d4b3e1ad3b4ad486d564b1`
### [Optional] Verify Giver contract bytecode
This contract is compiled with `0.66.0 ` Solidity and `0.19.3`Linker version.

To check that the code hash of the compiled version from repository is equal to your freshly compiled version, run this command and check that the *Code Hash* is
`57a1e5e4304f4db2beb23117e4d85df9cb5caec127531350e73219a8b8dc8afd`.

### Setup yore signer
```shell
npx everdev signer add <name_signer> <private_key>
npx everdev signer default <name_signer>
npx everdev sol set --compiler 0.66.0 --linker 0.19.3
npx everdev sol compile GiverV3.sol
npx everdev contract info --signer devnet_giver_keys GiverV3

Configuration

Network: se (http://localhost)
Signer: devnet_giver_keys (public 7fbbd813ac8358ed2d8598de156eb62bdddf5191d6ce4a0f307d4eac8d4c8e16)

Address: 0:dd39b607834a23f7091d4d6d8982c6269c1d71f1b512757cf4d298325a550b6a (calculated from TVC and signer public)
Code Hash: 57a1e5e4304f4db2beb23117e4d85df9cb5caec127531350e73219a8b8dc8afd (from TVC file)
```

### Get `<giver_address>` and topup it
### Get your Giver address and top it up
The address is calculated from the compiled contract codehash and your public key.
Run this command to see the *Address*:
```shell
npx everdev contract info GiverV3
npx everdev contract info --signer devnet_giver_keys GiverV3
```
Now, you need to top up your giver. Transfer tokens from Surf wallet or Everwallet.

### Deploy

### Deploy your Giver
After you topped up Giver address, you can deploy it.
Run this command:
```shell
npx everdev contract deploy GiverV3
```

### Setup yore Giver
### Setup your Giver
Run this command to set up the giver for your network.

```shell
everdev network giver --signer <name_signer> --type GiverV3 <name_network> <giver_address>
npx everdev network giver --signer <name_signer> --type GiverV3 <name_network> <giver_address>
```

### Using your Giver
This command under the hood will use predefined signer and configured giver on the default network.
```
npx everdev contract topup -a `<refill_address>` -v `<nano_tokens_value>`
```

## Files
* ABI: [GiverV3.abi.json](GiverV3.abi.json)
* Keypair: [GiverV3.keys.json](GiverV3.keys.json)
* Source code: [GiverV3.sol](GiverV3.sol)
* TVC file: [GiverV3.tvc](GiverV3.tvc)
File renamed without changes.
1 change: 0 additions & 1 deletion contracts/giver_v4/.gitignore

This file was deleted.

Loading

0 comments on commit 82ca711

Please sign in to comment.