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 2 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
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
9 changes: 9 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 Expand Up @@ -34,6 +42,7 @@ services:
ports:
- '30303:30303/tcp'
- '30303:30303/udp'
- '8551:8551'
healthcheck:
test: 'wget -qO /dev/null --header "content-type: application/json" --post-data {\"jsonrpc\":\"2.0\",\"method\":\"eth_blockNumber\",\"params\":[],\"id\":1} http://127.0.0.1:8545'
interval: 5s
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