Bitcoin Forum
June 18, 2024, 05:56:12 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: testnet4 in a container  (Read 290 times)
mocacinno (OP)
Legendary
*
Offline Offline

Activity: 3430
Merit: 5032


https://merel.mobi => buy facemasks with BTC/LTC


View Profile WWW
May 15, 2024, 07:46:39 AM
Last edit: May 15, 2024, 08:30:07 AM by mocacinno
Merited by LoyceV (42), vapourminer (10), pooya87 (10), DaveF (5), DdmrDdmr (4), seoincorporation (3), ABCbits (2)
 #1

Hi guys, tought i would share my work (in progress)  Grin

I was part of this discussion: https://bitcointalk.org/index.php?topic=5496329.0
It was about a potential switch to testnet4...

I quickly pointed out how to merge the pull request for testnet4, but last night i started to think: i want to do this in a reproducible way... So i created a docker image you could easily run yourself...

Code:
FROM ubuntu:22.04 AS builder
#start.sh sets proxy for apt, needed for my env...
#COPY start.sh /usr/local/bin/
#RUN chmod +x /usr/local/bin/start.sh
#RUN /usr/local/bin/start.sh

#install all prereqs
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata && apt-get -y install git autoconf pkg-config libtool build-essential bsdmainutils libevent-dev  libdb-dev libdb++-dev clang python3 libssl-dev  libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libminiupnpc-dev libzmq3-dev libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler libsqlite3-dev ccache

#pull pr
RUN git clone https://github.com/bitcoin/bitcoin.git /bitcoin
WORKDIR /bitcoin
RUN git fetch origin pull/29775/head:pr-29775 && git checkout pr-29775

#compile
RUN ./autogen.sh
RUN ./configure --with-incompatible-bdb CC=clang CXX=clang++
RUN make -j "$(($(nproc) + 1))"
WORKDIR /bitcoin/src
RUN strip bitcoin-util && strip bitcoind && strip bitcoin-cli && strip bitcoin-tx && strip qt/bitcoin-qt

#multistage
FROM ubuntu:22.04
RUN apt-get update && apt-get install -y libdb5.3++-dev libminiupnpc-dev libevent-dev libzmq3-dev libsqlite3-dev
COPY --from=builder /bitcoin/src/bitcoin-util /usr/local/bin
COPY --from=builder /bitcoin/src/bitcoin-cli /usr/local/bin
COPY --from=builder /bitcoin/src/bitcoin-tx /usr/local/bin
COPY --from=builder /bitcoin/src/bitcoind /usr/local/bin
COPY --from=builder /bitcoin/src/qt/bitcoin-qt /usr/local/bin

you can either build the image yourself (should be reproducible), or you can use the image i built: https://hub.docker.com/r/mocacinno/btc_testnet4

Afterwards, create a simple docker-compose.yml
Code:
version: '3'
services:
  bitcoind:
    image: mocacinno/btc_testnet4
    privileged: true
    container_name: bitcoind
    volumes:
      - /root/project/run_btc_testnet4/data:/root/.bitcoin/
    command: ["bitcoind", "-testnet4", "-server", "-rpcuser=demo", "-rpcpassword=demo", "-rpcallowip=127.0.0.1"]
    ports:
      - "8333:8333"
      - "48332:48332"

Ofcourse, change the volume path to a path that exists on your host, and change the rpc user and pass Smiley

Then it's just a matter of "docker-compose up -d" to pull the image and start bitcoind.

Connect to the running container and create a wallet:
Code:
docker exec -it bitcoind /bin/bash
bitcoin-cli -testnet4 -rpcuser=demo -rpcpassword=demo createwallet mywally

a (testnet4) tipping address: tb1qumlhr8tn9gsdyujy464jkk4c5r488u8kxteyx5  (only send testnet4 tBTC!!!) Tongue

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
mocacinno (OP)
Legendary
*
Offline Offline

Activity: 3430
Merit: 5032


https://merel.mobi => buy facemasks with BTC/LTC


View Profile WWW
May 15, 2024, 08:29:44 AM
Last edit: May 15, 2024, 11:23:29 AM by mocacinno
 #2

I have tried to put a "mining" image together aswell:

Code:
FROM ubuntu:22.04 AS miner
#start.sh sets proxy for apt, needed for my env
#COPY start.sh /usr/local/bin/
#RUN chmod +x /usr/local/bin/start.sh
#RUN /usr/local/bin/start.sh
RUN apt-get update \
  && apt-get install -y \
    build-essential \
    libssl-dev \
    libgmp-dev \
    libcurl4-openssl-dev \
    libjansson-dev \
    automake \
git \
zlib1g-dev \
    && rm -rf /var/lib/apt/lists/*
RUN git clone https://github.com/JayDDee/cpuminer-opt /cpuminer
WORKDIR /cpuminer
RUN ./build.sh


FROM ubuntu:22.04 AS builder
#start.sh sets proxy for apt, needed for my env
#COPY start.sh /usr/local/bin/
#RUN chmod +x /usr/local/bin/start.sh
#RUN /usr/local/bin/start.sh

#install all prereqs
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata && apt-get -y install git autoconf pkg-config libtool build-essential bsdmainutils libevent-dev  libdb-dev libdb++-dev clang python3 libssl-dev  libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libminiupnpc-dev libzmq3-dev libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler libsqlite3-dev ccache

#pull pr
RUN git clone https://github.com/bitcoin/bitcoin.git /bitcoin
WORKDIR /bitcoin
RUN git fetch origin pull/29775/head:pr-29775 && git checkout pr-29775

#compile
RUN ./autogen.sh
RUN ./configure --with-incompatible-bdb CC=clang CXX=clang++
RUN make -j "$(($(nproc) + 1))"
WORKDIR /bitcoin/src
RUN strip bitcoin-util && strip bitcoind && strip bitcoin-cli && strip bitcoin-tx && strip qt/bitcoin-qt

#multistage
FROM ubuntu:22.04
RUN apt-get update && apt-get install -y libdb5.3++-dev libminiupnpc-dev libevent-dev libzmq3-dev libsqlite3-dev \
libjansson-dev  libcurl4-openssl-dev

COPY --from=builder /bitcoin/src/bitcoin-util /usr/local/bin
COPY --from=builder /bitcoin/src/bitcoin-cli /usr/local/bin
COPY --from=builder /bitcoin/src/bitcoin-tx /usr/local/bin
COPY --from=builder /bitcoin/src/bitcoind /usr/local/bin
COPY --from=builder /bitcoin/src/qt/bitcoin-qt /usr/local/bin
COPY --from=miner /cpuminer/cpuminer /usr/local/bin


you can build it yourself, or get if from dockerhub mocacinno/btc_testnet4:cpuminer

if you use this docker-compose.yml to start:
Code:
version: '3'
services:
  bitcoind:
    image: mocacinno/btc_testnet4:cpuminer
    privileged: true
    container_name: bitcoind
    volumes:
      - /root/project/run_btc_testnet4/data:/root/.bitcoin/
    command: ["bitcoind", "-testnet4", "-server", "-rpcuser=demo", "-rpcpassword=demo", "-rpcallowip=127.0.0.1", "-rpcport=5000"]
    ports:
      - "8333:8333"
      - "48332:48332"

you can afterwards log in to the running container like this:

Code:
docker exec -it bitcoind /bin/bash

and start cpu mining like this (replace my address by yours offcourse)

Code:
cpuminer -a sha256d -o http://127.0.0.1:5000 -O demo:demo --coinbase-addr=tb1qumlhr8tn9gsdyujy464jkk4c5r488u8kxteyx5

the problem is the only vps i currently have is slooooooooooooooow (it's a small vps from hostnamaste and they seem to have overloaded their hosts. Logging in takes about 2 minutes, let alone running a cpu miner)... I barely get 20 Mhashes per second (really, not kidding......). I have no idear if the mining actually works, since at this hashrate i will not find anything.


update it seems like somebody is running an asic on the testnet4... hashrate is 425 Th, so my 22Mh is < 1/19.000.000 of the current network hashrate... On average, i'd hit one block every >300 years. I just hope this asic-miner turns off his asic from time to time to give the cpuminers a chance...
Maybe i have to dust off my old geccoscience compaq... If i remember correctly it hashed somewhere at the 50 Gh range??? At least i'd have 1/8500 of the total network hashrate, and i would be able to mine a block every couple of months... ~sigh~

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
DaveF
Legendary
*
Offline Offline

Activity: 3514
Merit: 6350


Crypto Swap Exchange


View Profile WWW
May 15, 2024, 01:22:23 PM
Merited by vapourminer (2)
 #3


the problem is the only vps i currently have is slooooooooooooooow (it's a small vps from hostnamaste and they seem to have overloaded their hosts. Logging in takes about 2 minutes, let alone running a cpu miner)... I barely get 20 Mhashes per second (really, not kidding......). I have no idear if the mining actually works, since at this hashrate i will not find anything.


update it seems like somebody is running an asic on the testnet4... hashrate is 425 Th, so my 22Mh is < 1/19.000.000 of the current network hashrate... On average, i'd hit one block every >300 years. I just hope this asic-miner turns off his asic from time to time to give the cpuminers a chance...
Maybe i have to dust off my old geccoscience compaq... If i remember correctly it hashed somewhere at the 50 Gh range??? At least i'd have 1/8500 of the total network hashrate, and i would be able to mine a block every couple of months... ~sigh~

That will continue to be an issue forever with anything that is 'low use' and has a mining algo that has asics for it.

There are so many 2 or 3 gen out miners that are just sitting there that it's not a big deal to mine something worthless with it.

The difference in loss for the cost of power between something that has $0 value and the potential profit of mining BTC (or LTC or whatever) that has value but a difficulty that is that high is just about nothing.

Back to this, has anyone been able to compile this for windows? I tried last night and got a bunch of errors. Was exhausted and doing it remotely and just went to bed. Didn't even record the errors.

-Dave 

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
seoincorporation
Legendary
*
Offline Offline

Activity: 3192
Merit: 2978


Top Crypto Casino


View Profile
May 15, 2024, 03:55:31 PM
 #4

Great job mocacinno, you automate the full process. Now people can start working with Testnet 4 in an easy way.

And it would be if user could mine with CPU, but as you say, 1 modern iner would kill that option for all. It would be fun to include a rule on the node setting a limit for miners. But i know that's not possible because that would not only affect the big engines, but would affect the pools too.  This gives me the idea of opening a mining pool for tBTC 4, that way even if users do not have the hardware, they could get a small piece of the cake with their CPU. But tBTC4 is still green, let's give it some time to mature.

And again, thanks for the apport.

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
mocacinno (OP)
Legendary
*
Offline Offline

Activity: 3430
Merit: 5032


https://merel.mobi => buy facemasks with BTC/LTC


View Profile WWW
May 24, 2024, 01:36:07 PM
 #5

I built (yet another) image that is including c-lighting + a simple walktrouh

I've updated the info on dockerhub:
https://hub.docker.com/repository/docker/mocacinno/btc_testnet4/general

If anybody is interested, i'm running two bitcoin nodes on testnet4, and two testnet4 lightning nodes on top of my bitcoin testnet4 node... I'll be AFK during the weekend, but when i get back on monday, i'll see if there are people interested in connecting to my testnet4 lightning node, creating some funded channels and creating some invoices Smiley

the Dockerfile itself is as follows:
Code:
FROM ubuntu:22.04 AS lightning
RUN apt-get update && \
apt-get install -y  git build-essential python3 sqlite3 libsqlite3-dev autoconf libtool python3-dev python3-mako gettext  python3-pip jq
RUN pip install protobuf grpcio-tools
RUN git clone https://github.com/ElementsProject/lightning /lightning
WORKDIR /lightning
RUN git fetch --all --tags
RUN git checkout tags/v24.02.2 -b v24.02.2
RUN sed -i '1311,1313d' /lightning/lightningd/chaintopology.c
RUN ./configure
#RUN apt-get install -y python3-grpc-tools
RUN make -j "$(($(nproc) + 1))"

FROM ubuntu:22.04 AS miner
#start.sh sets proxy for apt, needed for my env
COPY start.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/start.sh
RUN /usr/local/bin/start.sh
RUN apt-get update \
  && apt-get install -y \
    build-essential \
    libssl-dev \
    libgmp-dev \
    libcurl4-openssl-dev \
    libjansson-dev \
    automake \
git \
zlib1g-dev \
    && rm -rf /var/lib/apt/lists/*
RUN git clone https://github.com/JayDDee/cpuminer-opt /cpuminer
WORKDIR /cpuminer
RUN git fetch --all --tags
RUN git checkout tags/v24.2 -b v24.2
RUN ./build.sh


FROM ubuntu:22.04 AS builder
#start.sh sets proxy for apt, needed for my env
COPY start.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/start.sh
RUN /usr/local/bin/start.sh

#install all prereqs
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata && apt-get -y install git autoconf pkg-config libtool build-essential bsdmainutils libevent-dev  libdb-dev libdb++-dev clang python3 libssl-dev  libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libminiupnpc-dev libzmq3-dev libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler libsqlite3-dev ccache

#pull pr
RUN git clone https://github.com/bitcoin/bitcoin.git /bitcoin
WORKDIR /bitcoin
RUN git fetch origin pull/29775/head:pr-29775 && git checkout pr-29775

#compile
RUN ./autogen.sh
RUN ./configure --with-incompatible-bdb --with-gui=no  CC=clang CXX=clang++
RUN make -j "$(($(nproc) + 1))"
WORKDIR /bitcoin/src
RUN strip bitcoin-util && strip bitcoind && strip bitcoin-cli && strip bitcoin-tx

#multistage
FROM ubuntu:22.04
RUN apt-get update && apt-get install -y libdb5.3++-dev libminiupnpc-dev libevent-dev libzmq3-dev libsqlite3-dev \
libjansson-dev  libcurl4-openssl-dev python3

COPY --from=builder /bitcoin/src/bitcoin-util /usr/local/bin
COPY --from=builder /bitcoin/src/bitcoin-cli /usr/local/bin
COPY --from=builder /bitcoin/src/bitcoin-tx /usr/local/bin
COPY --from=builder /bitcoin/src/bitcoind /usr/local/bin
COPY --from=miner /cpuminer/cpuminer /usr/local/bin
COPY --from=lightning /lightning/cli/lightning-cli /usr/local/bin
COPY --from=lightning /lightning/tools/reckless /usr/local/bin
COPY --from=lightning /lightning/lightningd/lightningd /usr/local/bin
COPY --from=lightning /lightning/lightningd/lightning_channeld /usr/local/libexec/c-lightning/
COPY --from=lightning /lightning/lightningd/lightning_closingd /usr/local/libexec/c-lightning/
COPY --from=lightning /lightning/lightningd/lightning_connectd /usr/local/libexec/c-lightning/
COPY --from=lightning /lightning/lightningd/lightning_gossipd /usr/local/libexec/c-lightning/
COPY --from=lightning /lightning/lightningd/lightning_hsmd /usr/local/libexec/c-lightning/
COPY --from=lightning /lightning/lightningd/lightning_onchaind /usr/local/libexec/c-lightning/
COPY --from=lightning /lightning/lightningd/lightning_openingd /usr/local/libexec/c-lightning/
COPY --from=lightning /lightning/plugins /opt/lightningd/plugins

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
baryonlee
Newbie
*
Offline Offline

Activity: 43
Merit: 0


View Profile
May 27, 2024, 12:30:52 PM
 #6

Thank you very much. I am launching the testnet4 docker container in live.
Great work!

🔴 [Live] The Note block explorer is currently syncing with the BTC Testnet4. We've throttled the speed to one block per second so you can observe this process in real-time.
Check it out here:  https://testnet4.noteprotocol.org

And For the main network https://explorer.noteprotocol.org
mocacinno (OP)
Legendary
*
Offline Offline

Activity: 3430
Merit: 5032


https://merel.mobi => buy facemasks with BTC/LTC


View Profile WWW
June 12, 2024, 11:40:32 AM
Last edit: June 12, 2024, 12:43:48 PM by mocacinno
Merited by LoyceV (4), garlonicon (1)
 #7

new image available: mocacinno/btc_testnet4:ckpool

you can either pull this image, or build your own... The Dockerfile is available from my git repo:
https://github.com/mocacinno/btc_testnet4/tree/ckpool

currently running @ my vps IN SOLO MINING MODE with 2% donation... example cpuminer command to mine on this testnet4 pool:

Code:
cpuminer -o stratum+tcp://173.46.81.70:3334 -u tb1qumlhr8tn9gsdyujy464jkk4c5r488u8kxteyx5 -p x -a sha256d

or if you prefer minerd:

Code:
minerd -a sha256d -o stratum+tcp://173.46.81.70:3334 -O tb1qumlhr8tn9gsdyujy464jkk4c5r488u8kxteyx5:x

offcourse, exchange my testnet addy by yours Smiley

i give no guarantee whatsoever, not even that i configured this pool correctly... It's testnet guys... The pool will run untill the vps crashes (i rented this vps for the sole purpose of testnet4 containerisation, so when my work is done, i'll no longer pay for it).

no user interface or stats available... you either trust me to run the pool, or you run your own (which is really easy using the container image provided).

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
garlonicon
Hero Member
*****
Offline Offline

Activity: 819
Merit: 1982


View Profile
June 12, 2024, 05:20:44 PM
 #8

Quote
example cpuminer command to mine on this testnet4 pool
Is there an option to always get block headers with minimal difficulty? Or maybe you use just the default settings, and those CPU miners are trying to compete with ASICs, and their difficulty?

Edit: If you use just the default settings, then I guess manual adjustment of time and difficulty would work, and would form a proper share, right?

The main question is: if I would fetch some 80-byte header, and change those two fields, to make it CPU-mineable, and submit a share at difficulty one, then it would be accepted or not?
mocacinno (OP)
Legendary
*
Offline Offline

Activity: 3430
Merit: 5032


https://merel.mobi => buy facemasks with BTC/LTC


View Profile WWW
June 13, 2024, 05:58:56 AM
Merited by garlonicon (1)
 #9

Quote
example cpuminer command to mine on this testnet4 pool
Is there an option to always get block headers with minimal difficulty? Or maybe you use just the default settings, and those CPU miners are trying to compete with ASICs, and their difficulty?

Edit: If you use just the default settings, then I guess manual adjustment of time and difficulty would work, and would form a proper share, right?

The main question is: if I would fetch some 80-byte header, and change those two fields, to make it CPU-mineable, and submit a share at difficulty one, then it would be accepted or not?

I'm not completely sure about the inner workings of ckpool to be honest... I did set the minimum share diff to 1, aswell as the starting diff. I'm cpu mining myself, and every share i've sent was valid if it had a diff of >= 1.
I did solve two blocks whilst solo mining with my cpu on my own solo pool, but by the time they got relayed they were already stale. If no block is found for 20 minutes on the testnet, the diff resets to 1, and you have a very brief window before one of those ASIC miners solves and relays a block at diff 1. It's a longshot tough, and so far my 2 "solved" blocks did not make it into the blockchain.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
garlonicon
Hero Member
*****
Offline Offline

Activity: 819
Merit: 1982


View Profile
June 13, 2024, 06:29:32 AM
Merited by LoyceV (6), ABCbits (2), mocacinno (1)
 #10

Quote
and you have a very brief window before one of those ASIC miners solves and relays a block at diff 1
The window to mine it is quite wide. The window to broadcast it is shorter, but only if the network is two hours in the future, like testnet3. For testnet4, as long as you don't see blocks from the future, you can safely submit them, and get them confirmed, even if you mine them on your CPU.

Example modification in Bitcoin Core, that could help mining blocks on CPU:
Quote
Code:
$ git diff 86fea43762 5ffd95377b
diff --git a/src/chain.h b/src/chain.h
index bb70dbd8bc..30d5d48d5d 100644
--- a/src/chain.h
+++ b/src/chain.h
@@ -26,7 +26,7 @@
  * Maximum amount of time that a block timestamp is allowed to exceed the
  * current time before the block will be accepted.
  */
-static constexpr int64_t MAX_FUTURE_BLOCK_TIME = 2 * 60 * 60;
+static constexpr int64_t MAX_FUTURE_BLOCK_TIME = 20 * 60 * 60;
 
 /**
  * Timestamp window used as a grace period by code that compares external
diff --git a/src/node/miner.cpp b/src/node/miner.cpp
index 87f40e993f..e83d3bde27 100644
--- a/src/node/miner.cpp
+++ b/src/node/miner.cpp
@@ -31,7 +31,7 @@ namespace node {
 int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev)
 {
     int64_t nOldTime = pblock->nTime;
-    int64_t nNewTime{std::max<int64_t>(pindexPrev->GetMedianTimePast() + 1, TicksSinceEpoch<std::chrono::seconds>(NodeClock::now()))};
+    int64_t nNewTime{std::max<int64_t>(pindexPrev->GetMedianTimePast() + 1, pindexPrev->GetBlockTime() + consensusParams.nPowTargetSpacing*2 + 1)};
 
     if (nOldTime < nNewTime) {
         pblock->nTime = nNewTime;
$
Then, each and every call to "getblocktemplate" will return the minimal difficulty. And also, if you replace for example "2 hours rule" with "20 hours rule", then you can work on blocks, which are not yet broadcasted, but will be, as the clock in other nodes will get there.
LoyceV
Legendary
*
Online Online

Activity: 3346
Merit: 16838


Thick-Skinned Gang Leader and Golden Feather 2021


View Profile WWW
June 13, 2024, 07:50:54 AM
Merited by garlonicon (1)
 #11

ELI5 for me garlonicon: does this mean you're always mining at difficulty 1, so you have a block ready the moment the difficulty drops after 20 minutes without a block?

garlonicon
Hero Member
*****
Offline Offline

Activity: 819
Merit: 1982


View Profile
June 13, 2024, 08:55:19 AM
Last edit: June 13, 2024, 05:32:35 PM by garlonicon
Merited by LoyceV (4), ABCbits (2), mocacinno (1)
 #12

Quote
does this mean you're always mining at difficulty 1, so you have a block ready the moment the difficulty drops after 20 minutes without a block?
Yes. Because if you have a field in the block header called "difficulty", then you have to put something there. And you have a choice: putting the real difficulty, or the minimal one. If you have an ASIC, you can put the real one. But: if you mine for example a half-baked block with your ASIC, then you cannot submit "the best header you did", because it does not meet the network difficulty. After 20 minutes, even if you have ASIC, you have to switch to the minimal difficulty, and mine it separately.

So, the conclusion is: all is left to the network propagation. Both CPU and ASIC miners have their blocks with minimal difficulty, prepared in advance. And then, the winner is not the one, who can mine it faster. The winner is the one, who can propagate it faster. And for that reason, you can compete with ASICs, and mine some blocks even on your CPU.

But obviously, this method is not bulletproof. First, if you have some ASIC, then you can decide to reorg all CPU-mined blocks, and nobody will stop you. Second, you have to mine and propagate a block. Serious miners are well-connected, so if your propagation is worse, then you will get a block, but it will be stale.

Edit: One more thing: obviously, if someone is mining with CPU-only difficulty, then the time of the block is set to 20 minutes. But the real difficulty is set to 10 minutes. So, it is normal to have ASICs in-between.

Another observation is that mining on top of some ASIC block is the easiest thing to do, because ASICs usually set the real time in their blocks, while CPU miners are working on the future, for example one or two hours forward (so after some ASIC block, there is a wider room for propagating new CPU blocks).
mocacinno (OP)
Legendary
*
Offline Offline

Activity: 3430
Merit: 5032


https://merel.mobi => buy facemasks with BTC/LTC


View Profile WWW
June 14, 2024, 07:44:29 AM
 #13

I'm searching for a guinea pig...

I just upgraded lightning core from 24.02.2 to 24.05 in my development container image... However... I'm already renting 2 VPS's right now with the sole purpose of testnet4 containerisations and they're both running a container image i modified and not yet saved, so i'm unable to test the new version out without renting yet another vps (unless i start messing with ports, which is a hassle)

On dockerhub, i'm keeping the stable versions, so if you pull from dockerhub, you should always get a working setup.

On github, i have a CI/CD pipeline that automatically builds when i commit to my master branch. So on github, i have the "unstable/untested" versions (like the latest version containing the core lightning upgrade).
Is there anybody willing to pull v0.0.3 from github and test core lightning? The build process is completely transparent and automatic, so you can verify i didn't mess with the image


Offcourse, you're welcome to just take the dockerfile and build it yourself.

Basically, i'm looking for somebody to follow the following walktrough: https://github.com/mocacinno/btc_testnet4/tree/lightning, but when the step "edit the docker-compose.yml file" is suggested, also replace the image on dockerhub by ghcr.io/mocacinno/btc_testnet4:latest
On my modified node, i also have core lightning 24.02.2, so i only need one person to test out the new image, since the "guinea pig" can just connect to my node to open a channel.

Offcourse, i'll send some tBTC (testnet4) to cover channel creation to whoever volunteers Smiley

I'm going to Susecon in Germany for most of next week, so i'll be AFK starting this evening up untill next thursday. If i cannot find a volunteer by this evening, i'll have to postpone the testing untill friday the 21st of june.


█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!