Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Misc fixes #18

Merged
merged 4 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ name := "consensus-client"
maintainer := "Units Network Team"
resolvers ++= Resolver.sonatypeOssRepos("releases") ++ Resolver.sonatypeOssRepos("snapshots") ++ Seq(Resolver.mavenLocal)
libraryDependencies ++= Seq(
"com.wavesplatform" % "node-testkit" % "1.5.7-3964-SNAPSHOT" % "test",
"com.wavesplatform" % "node" % "1.5.7-3964-SNAPSHOT" % "provided",
"com.wavesplatform" % "node-testkit" % "1.5.8-SNAPSHOT" % "test",
"com.wavesplatform" % "node" % "1.5.8-SNAPSHOT" % "provided",
"com.softwaremill.sttp.client3" % "core_2.13" % "3.9.8",
"com.softwaremill.sttp.client3" %% "play-json" % "3.9.8",
"com.github.jwt-scala" %% "jwt-play-json" % "10.0.1"
Expand Down
2 changes: 1 addition & 1 deletion docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Units Network node consists of Waves blockchain node, Consensus Client extension

## Prerequisites
* Install [Docker Compose](https://docs.docker.com/compose/install/).
* Generate JWT secret and execution client keys by running `./gen-keys.sh`. This script requires `openssl` and `xxd`.
* Generate JWT secret and execution client keys by running `./gen-keys.sh`. This script requires `openssl`.
* Optional: get waves node [state](https://docs.waves.tech/en/waves-node/options-for-getting-actual-blockchain/state-downloading-and-applying) and place it inside the `./data/waves` directory.
* Optional: get execution client state.

Expand Down
9 changes: 9 additions & 0 deletions docker/docker-compose-geth.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
services:
geth-init:
extends:
file: ./services/geth.yml
service: geth-init

geth:
extends:
file: ./services/geth.yml
service: geth
depends_on:
geth-init:
condition: service_completed_successfully

waves-node:
extends:
file: ./services/waves-node.yml
Expand Down
4 changes: 2 additions & 2 deletions docker/gen-keys.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
mkdir -p data/secrets
openssl rand 32 | xxd -p -c 32 > data/secrets/p2p-key
openssl rand 32 | xxd -p -c 32 > data/secrets/jwtsecret
openssl rand -hex 32 | tr -d "\n" > data/secrets/p2p-key
openssl rand -hex 32 | tr -d "\n" > data/secrets/jwtsecret
1 change: 0 additions & 1 deletion docker/services/besu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@ services:
ports:
- '30303:30303/tcp'
- '30303:30303/udp'
- '8545:8545'
environment:
- LOG4J_CONFIGURATION_FILE=/etc/besu/log4j2.xml
8 changes: 8 additions & 0 deletions docker/services/geth.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
services:
geth-init:
container_name: geth-init
image: ethereum/client-go:stable
entrypoint: /tmp/init-geth.sh
volumes:
- ../genesis-${NETWORK}.json:/tmp/genesis.json
- ../data/geth:/root/.ethereum
- ../init-geth.sh:/tmp/init-geth.sh
geth:
container_name: geth
image: ethereum/client-go:stable
Expand Down
6 changes: 3 additions & 3 deletions docker/testnet.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NETWORK=testnet
NETWORK_ID=88817
WAVES_NODE_TAG=L2-test
WAVES_DECLARED_ADDRESS=1.2.3.4:6868
UNITS_DECLARED_ADDRESS=1.2.3.4:6865
WAVES_NODE_TAG=testnet
#WAVES_DECLARED_ADDRESS=1.2.3.4:6868
#UNITS_DECLARED_ADDRESS=1.2.3.4:6865
3 changes: 2 additions & 1 deletion docker/waves-testnet.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ waves {
}

l2 {
chain-contract = 3MsqKJ6o1ABE37676cHHBxJRs6huYTt72ch
chain-contract = 3Msx4Aq69zWUKy4d1wyKnQ4ofzEDAfv5Ngf
execution-client-address = "http://${EXECUTION_CLIENT}:8551"
jwt-secret-file = /etc/secrets/jwtsecret

network {
port = 6865
declared-address = ${?UNITS_DECLARED_ADDRESS}
known-peers = [
"testnet-l2-htz-hel1-1.wavesnodes.com:6865"
"testnet-l2-htz-hel1-2.wavesnodes.com:6865"
"testnet-htz-nbg1-1.wavesnodes.com:6865"
]
Expand Down
11 changes: 4 additions & 7 deletions local-network/deploy/src/waves-txs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ export const ccMinerJoin1 = wt.invokeScript(
args: [
{
// Reward address
type: "binary",
// 0x7dbcf9c6c3583b76669100f9be3caf6d722bc9f9
value: "base64:fbz5xsNYO3ZmkQD5vjyvbXIryfk="
type: "string",
value: "0x7dbcf9c6c3583b76669100f9be3caf6d722bc9f9"
}
]
}
Expand All @@ -74,9 +73,8 @@ export const ccMinerJoin2 = wt.invokeScript(
args: [
{
// Reward address
type: "binary",
// 0xcf0b9e13fdd593f4ca26d36afcaa44dd3fdccbed
value: "base64:zwueE/3Vk/TKJtNq/KpE3T/cy+0="
type: "string",
value: "0xcf0b9e13fdd593f4ca26d36afcaa44dd3fdccbed"
}
]
}
Expand Down Expand Up @@ -131,4 +129,3 @@ export function mkE2CTransfer(senderPrivateKey: string, blockHash: string, merkl
{ privateKey: senderPrivateKey }
)
}

13 changes: 8 additions & 5 deletions src/test/resources/main.ride
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ func appendBlock(
}

@Callable(i)
func join(rewardAddress: ByteVector) = {
func join(rewardAddressHex: String) = {
# EL miner must sign a Network block by own private key
func ensureNotOverrideOtherMinerPk(elAddressHex: String) = {
match getBinary(minerPkKey(elAddressHex)) {
Expand All @@ -500,6 +500,9 @@ func join(rewardAddress: ByteVector) = {
}
}

let parts = rewardAddressHex.split("0x")
let rewardAddress = parts[parts.size() - 1].fromBase16String()

if (!isContractSetup()) then
throw("The contract has not yet set up")
else if (i.originCaller.wavesBalance().generating < MIN_BALANCE) then
Expand All @@ -513,8 +516,8 @@ func join(rewardAddress: ByteVector) = {
then []
else {
let newMiner = i.originCaller.toString()
let rewardAddressHex = rewardAddress.toBase16String()
strict check = ensureNotOverrideOtherMinerPk(rewardAddressHex)
let lowercaseRewardAddress = rewardAddress.toBase16String()
strict check = ensureNotOverrideOtherMinerPk(lowercaseRewardAddress)

let newMiners =
if (allMiners.size() == 0)
Expand All @@ -531,8 +534,8 @@ func join(rewardAddress: ByteVector) = {
}
[
StringEntry(allMinersKey, newMiners),
StringEntry(minerRewardAddressKey(newMiner), "0x" + rewardAddressHex),
BinaryEntry(minerPkKey(rewardAddressHex), i.originCallerPublicKey)
StringEntry(minerRewardAddressKey(newMiner), "0x" + lowercaseRewardAddress),
BinaryEntry(minerPkKey(lowercaseRewardAddress), i.originCallerPublicKey)
] ++ deletePrevRewardAddressPk
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import units.client.L2BlockLike
import units.client.contract.HasConsensusLayerDappTxHelpers.*
import units.client.contract.HasConsensusLayerDappTxHelpers.defaultFees.chainContract.*
import units.eth.{EthAddress, EthereumConstants}
import units.util.HexBytesConverter

trait HasConsensusLayerDappTxHelpers {
def currentHitSource: ByteStr
Expand All @@ -38,7 +37,7 @@ trait HasConsensusLayerDappTxHelpers {
invoker = minerAccount,
dApp = chainContractAddress,
func = "join".some,
args = List(Terms.CONST_BYTESTR(ByteStr(HexBytesConverter.toBytes(elRewardAddress.hexNoPrefix))).explicitGet()),
args = List(Terms.CONST_STRING(elRewardAddress.hexNoPrefix).explicitGet()),
fee = joinFee
)

Expand Down