You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 01_overview-and-development.adoc
+72-14
Original file line number
Diff line number
Diff line change
@@ -776,33 +776,81 @@ Subsequent sections will contain various exercises related to their subject area
776
776
To prepare for this we will begin with the following exercises which will ensure that our environment is ready:
777
777
778
778
. Build Bitcoin Core from source
779
-
** Clone Bitcoin Core repository from GitHub
780
-
** Check out the latest release tag (e.g. `v24.0.1`)
781
-
** Install any dependencies required for your system
782
-
** Follow the build instructions to compile the program
783
-
** Run `make check` to run the unit tests
784
-
** Follow the documentation to install dependencies required to run the functional tests
785
-
*** Run the functional tests
786
-
. Run a `bitcoind` node in regtest mode and control it using the `cli` tool
787
-
** `./src/bitcoind -regtest` will start bitcoind in regtest mode. You can then control it using `./src/bitcoin-cli -regtest -getinfo`
779
+
- [ ] Clone Bitcoin Core repository from GitHub
780
+
- [ ] Check out the latest release tag (e.g. `v24.0.1`)
781
+
- [ ] Install any dependencies required for your system
782
+
- [ ] Follow the build instructions to compile the program
783
+
- [ ] Run `make check` to run the unit tests
784
+
- [ ] Follow the documentation to install dependencies required to run the functional tests
785
+
- [ ] Run the functional tests
786
+
. Run a `bitcoind` node in regtest mode and control it using the `cli` tool +
787
+
+
788
+
TIP: `./src/bitcoind -regtest` will start bitcoind in regtest mode. You can then control it using `./src/bitcoin-cli -regtest -getinfo`
788
789
. Run and control a Bitcoin Core node using the `TestShell` python class from the test framework in a Jupyter notebook
789
790
** See <<test_shell_nodes, Running nodes via Test Framework>> for more information on how to do this
791
+
. Review a Pull Request from the repo
792
+
- [ ] Find a PR (which can be open or closed) on GitHub which looks interesting and/or accessible
793
+
- [ ] Checkout the PR locally
794
+
- [ ] Review the changes
795
+
- [ ] Record any questions that arise during code review
796
+
- [ ] Build the PR
797
+
- [ ] Test the PR
798
+
- [ ] Break a test / add a new test
799
+
- [ ] Leave review feedback on GitHub, possibly including:
800
+
+
801
+
ACK/NACK
802
+
+
803
+
Approach
804
+
+
805
+
How you reviewed it
806
+
+
807
+
Your system specifications if relevant
808
+
+
809
+
Any suggested nits
790
810
791
811
[#test_shell_nodes]
792
812
.Running nodes via Test Framework
793
813
****
814
+
[discrete]
815
+
== Why
816
+
794
817
Using Bitcoin Core's Test Framework means that nodes can be started, controlled and stopped using a python control class.
795
-
Additionally, they are run in a temporary directory which is automatically removed by the system later, if not done
818
+
Additionally, they are run in a temporary directory which is automatically removed by the operating system, if not done
796
819
manually.
797
820
798
-
In addition to this, the `TestShell` class has an extremely similar interface to `bitcoin-cli`, where `bitcoin-cli` commands are mapped to `TestShell` methods, and arguments can be supplied positionally or as named values.
821
+
In addition to this, the `TestShell` class has an extremely similar interface to `bitcoin-cli`, where most `bitcoin-cli` commands are mapped to `TestShell` methods, and arguments can be supplied positionally or as named values.
822
+
Specifically, all RPCs are available to `TestShell`.
823
+
However, certain `bitcoin-cli` commands, for example `-getinfo` require `bitcoin-cli` to call multiple RPCs and combine the results into something more user-friendly.
824
+
These commands are not available to `TestShell`, but you can re-create them yourself using the source code!
825
+
826
+
When `TestShell` is combined with a jupyter notebook the result is easy-to-setup ephemeral nodes where iteration on complex commands is more pleasant than in the shell, and complex sequences of commands can be reproduced without having to write bash scripts or use shell history.
827
+
828
+
Once a complex command or sequence of commands is established, they can generally be translated to `bitcoin-cli` commands without much difficulty.
829
+
830
+
[discrete]
831
+
== How
832
+
833
+
You **MUST** have a compiled `bitcoind` binary in the Bitcoin Core source directory.
834
+
You can use any recent supported version of Bitcoin Core.
799
835
800
-
When combined with a jupyter notebook, the result is easy-to-setup ephemeral nodes where iteration on complex commands is more pleasant, and complex sequences of commands can be reproduced without having to write bash scripts or use shell history.
836
+
In order to add startup (`bitcoind` program) options to our node(s) we need https://github.com/bitcoin/bitcoin/pull/26617/commits/989a52e0a50c0ae30a5c2bd3c08bb3ad1363a250[this^] commit.
837
+
We can include this two ways:
801
838
802
-
To begin it is recommended to create a python virtual environment which can be done as follows when in the onboarding to bitcoin core top level directory:
839
+
. Use the master branch of Bitcoin Core and running `git pull`, which will include the change.
840
+
. Use any recent tag (e.g. v24.0.1) and running `git cherry-pick 989a52e0` to pull that change into the Test Framework code.
841
+
842
+
You **MUST** have a copy of the jupyter notebook, either manually downloaded from https://github.com/chaincodelabs/onboarding-to-bitcoin-core or by cloning the onboarding-to-bitcoin-core repo (recommended) with:
You **MAY** want to use a python virtual environment (recommended) which can be done as follows when in the onboarding to bitcoin core top level directory:
803
850
804
851
[source, bash]
805
852
----
853
+
cd /path/to/source/onboarding-to-bitcoin-core
806
854
python3 -m venv "obc-venv"
807
855
source obc-venv/bin/activate
808
856
----
@@ -824,7 +872,7 @@ jupyter notebook
824
872
----
825
873
826
874
This will open a list of all the files in this directory.
827
-
Opening the file named `exercises.ipynb` will start the empty notebook containing instructions on how to use `TestShell` from the test Framework.
875
+
Opening the file named `exercise_tutorial.ipynb` will start the notebook containing instructions on how to use `TestShell` from the test Framework.
828
876
829
877
When you are finished you can deactivate the venv using
830
878
@@ -834,6 +882,16 @@ deactivate
834
882
----
835
883
836
884
TIP: Don't forget to re-activate your venv each time you want to start the Jupyter notebook after deactivating the venv!
885
+
886
+
[discrete]
887
+
== Quick use
888
+
889
+
Once you have familiarized yourself with the `TestShell` method using `exercise_tutorial.ipynb`, you can instead start new notebooks for exercises based on the `exercise_base.ipynb` notebook, which has much of the instruction removed and will let you get started faster.
890
+
891
+
If you correct the import path for your system in this file and save it, you can then easily make copies of it to use as start points for different exercises:
"Finally, we must set up one or more nodes using the `setup()` method."
68
+
"Finally, we must set up one or more nodes using the `setup()` method.\n",
69
+
"\n",
70
+
"We can pass `bitcoind` options to each node using the `extra_args` argument.\n",
71
+
"This is the equivalent of setting options in the config file for `bitcoind` on the command line.\n",
72
+
"Arguments are passed in as a list of lists, one list of arguments for each node."
69
73
]
70
74
},
71
75
{
72
76
"cell_type": "code",
73
-
"execution_count": 3,
77
+
"execution_count": 5,
74
78
"metadata": {
75
79
"pycharm": {
76
80
"name": "#%%\n"
@@ -81,7 +85,7 @@
81
85
"name": "stdout",
82
86
"output_type": "stream",
83
87
"text": [
84
-
"2022-12-13T22:18:13.318000Z TestFramework (INFO): Initializing test directory /tmp/bitcoin_func_test_wbfjhnzg\n"
88
+
"2022-12-14T13:28:53.132000Z TestFramework (INFO): Initializing test directory /tmp/bitcoin_func_test_r8jqr6ge\n"
85
89
]
86
90
}
87
91
],
@@ -90,6 +94,7 @@
90
94
"test = TestShell().setup(\n",
91
95
" num_nodes=2,\n",
92
96
" setup_clean_chain=True,\n",
97
+
" extra_args=[[], ['-fallbackfee=0.0002']],\n",
93
98
")"
94
99
]
95
100
},
@@ -105,22 +110,47 @@
105
110
},
106
111
{
107
112
"cell_type": "code",
108
-
"execution_count": null,
113
+
"execution_count": 6,
109
114
"metadata": {
110
115
"pycharm": {
111
116
"name": "#%%\n"
112
117
}
113
118
},
114
119
"outputs": [],
115
120
"source": [
116
-
"node1 = test.nodes[0]\n",
117
-
"node2 = test.nodes[1]\n"
121
+
"test.nodes[0].getblockchaininfo()\n",
122
+
"\n",
123
+
"# or\n",
124
+
"\n",
125
+
"node2 = test.nodes[1]\n",
126
+
"node2.getmemoryinfo()"
118
127
]
119
128
},
120
129
{
121
130
"cell_type": "markdown",
122
131
"metadata": {},
123
-
"source": []
132
+
"source": [
133
+
"## Shutdown\n",
134
+
"\n",
135
+
"When you are finished, you can shut down the nodes just you would via `bitcoin-cli` by using the `shutdown()` method as shown below.\n",
136
+
"\n",
137
+
"If you kill the jupyter notebook server without shutting down the nodes then they are usually torn down automatically, but there is a slim chance they remain operational.\n",
138
+
"You can check for running `bitcoind` processes using `htop` or `sudo pidof bitcoind`."
0 commit comments