-
Notifications
You must be signed in to change notification settings - Fork 411
/
testnetContractStatus.html
231 lines (197 loc) · 9.43 KB
/
testnetContractStatus.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="btc relay, ethereum, bitcoin, bitcoin relay, smart contracts, sidechain, peg" />
<link rel="apple-touch-icon" sizes="57x57" href="images/favicons/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="images/favicons/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="images/favicons/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="images/favicons/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="images/favicons/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="images/favicons/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="images/favicons/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="images/favicons/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="images/favicons/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="images/favicons/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="images/favicons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="images/favicons/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="images/favicons/favicon-16x16.png">
<link rel="manifest" href="images/favicons/manifest.json">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="images/favicons/ms-icon-144x144.png">
<meta name="theme-color" content="#ffffff">
<link href='https://fonts.googleapis.com/css?family=Lato:400,300,300italic,400italic,700,700italic|Montserrat:400,700' rel='stylesheet' type='text/css'>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Ethereum Bitcoin Relay Status on TESTNET Morden</title>
<link rel="stylesheet" href="./css/bootstrap.min.css">
<link rel="stylesheet" href="./css/dapp.css">
<script src="./js/jquery-2.1.3.min.js"></script>
<script src="./js/bootstrap.min.js"></script>
<script src="./js/btcRelayAbi.js"></script>
<script src="./js/tokenContractAbi.js"></script>
<script src="./js/bignumber.js"></script>
<script src="./js/web3.min.js"></script>
<script>
if (typeof web3 !== 'undefined') {
// Web3 has been injected by the browser (Mist/MetaMask)
web3 = new Web3(web3.currentProvider);
} else {
// fallback - use your fallback strategy (local node / hosted node + in-dapp id mgmt / fail)
web3 = new Web3(new Web3.providers.HttpProvider("https://morden.infura.io:8545"));
}
var heightPerRelay;
$(function() {
/*
do NOT forget to update ABI files when needed
*/
var relayAddr = '0x5770345100a27b15f5b40bec86a701f888e8c601'; // Morden
// var relayAddr = web3.eth.namereg.addr('btcrelay'); // Olympic
$('#relayAddr').text(relayAddr);
updateBCI();
updateBlockr();
var RelayContract = web3.eth.contract(btcRelayAbi); // see ./js/btcRelayAbi.js
var contract = RelayContract.at(relayAddr);
heightPerRelay = contract.getLastBlockHeight.call().toString();
$('#latestBlockHeight').text(heightPerRelay);
var headHash = contract.getBlockchainHead.call();
$('#latestBlockHash').text(formatHash(headHash));
var feeVTX = web3.fromWei(contract.getFeeAmount.call(headHash), 'ether');
$('#feeVTX').text(feeVTX);
var feeRecipient = contract.getFeeRecipient.call(headHash).toString(16);
$('#feeRecipient').text('0x' + formatETHAddress(feeRecipient));
window.btcrelayTester = contract;
// signature of verifyTx is (txHash, txIndex, merkleSiblingArray, txBlockHash)
// to make a call to verifyTx so that btcrelay will get some fees,
// run this code in the browser developer console: fees will be sent
// from the coinbase
// res = btcrelayTester.verifyTx.sendTransaction(0, 1, [], 0, {from: web3.eth.coinbase, value: web3.toWei('0.1', 'ether')});
// console.log('txHash for verifyTx: ', res)
//setTimeout(checkHeights, 1000);
});
function updateBCI() {
// 2 calls needed since https://blockchain.info/latestblock is missing CORS
$.getJSON('https://blockchain.info/q/getblockcount?cors=true', function(data) {
$('#bciBlockHeight').text(data);
});
// https://github.com/blockchain/api-v1-client-python/issues/17
// $.getJSON('https://blockchain.info/q/latesthash?cors=true', function(data) {
// $('#bciBlockHash').text(data);
// });
}
function updateBlockr() {
$.getJSON('http://btc.blockr.io/api/v1/block/info/last', function(data) {
$('#blockrBlockHeight').text(data.data.nb);
});
}
function checkHeights() {
var bciHeight = $('#bciBlockHeight').text();
var blockrHeight = $('#blockrBlockHeight').text();
if (!bciHeight || !blockrHeight ||
heightPerRelay === bciHeight || heightPerRelay === blockrHeight) {
$('#warnSync').hide();
}
else {
$('#nodeBlockNum').text(web3.eth.blockNumber);
$('#warnSync').show();
}
}
function formatHash(bnHash) {
var hash = bnHash.toString(16);
return Array(64 - hash.length + 1).join('0') + hash;
}
function formatETHAddress(bnEthAddress) {
var ethAddress = bnEthAddress.toString(16);
return Array(40 - ethAddress.length + 1).join('0') + ethAddress;
}
</script>
</head>
<body>
<div class="container">
<div class="logo">
<img src="./images/BTCRelayLogo.png"/>
</div>
<div class="jumbotron">
<h3><small>Contract address: </small><strong id="relayAddr"></strong></h3>
<div class="row">
<div class="col-xs-2"><h3><a href="./BitcoinRelayABI.js">ABI</a></h3></div>
<div class="col-xs-2"><h3><a href="https://github.com/ethereum/btcrelay#api">API</a></h3></div>
</div>
<hr>
<h2>Status on TESTNET Morden <small>(may need relayers)</small></h2>
<h5>Latest Block Hash: <strong id="latestBlockHash"></strong></h5>
<div>
<h3 style="display: inline-block">Latest Block#: <strong id="latestBlockHeight"></strong></h3>
<div style="display: inline-block; margin-left:3em"><a href="https://blockchain.info" target="_">blockchain.info</a>: <strong id="bciBlockHeight"></strong></div>
<span><a href="https://btc.blockr.io" target="_">btc.blockr.io</a>: <strong id="blockrBlockHeight"></strong></span>
</div>
<h3 id="warnSync" style="display: none">Your Ethereum node may not be fully synced: <span id=nodeBlockNum></span>. Check <a href="https://stats.ethdev.com" target="_">stats</a>
for the latest blocks.
</h3>
<h3>ETH fee: <strong id="feeVTX"></strong></h3>
<h5>Relayer: <strong id="feeRecipient"></strong></h5>
<h5 class="text-right">Initial Block: <strong id="initialBlock">405216</strong></h5>
<h5 class="text-right"><a href="http://btc-relay.readthedocs.io/en/latest/status.html">FAQ</a></h5>
</div>
<div>
<h3>Verifying the Source Code <small>at 0x5770345100a27b15f5b40bec86a701f888e8c601</small></h3>
<p>
The deployed version of <a href="https://github.com/ethereum/btcrelay/tree/6fa4098747b9c030ed7a64b304dbcfa35100afe0">BTC Relay is from commit
6fa4098747b9c030ed7a64b304dbcfa35100afe0</a>
</p>
<p>
The main steps to verifying the source code are: <br>
1) compile code to the evm (bytecode) <br>
2) compare the evm against the data used in the contract creation transaction
</p>
<h4>1)</h4>
<pre>
serpent compile btcBulkStoreHeaders.se > compiled.evm
</pre>
<h4>2)</h4>
<p>Here's how to use Geth console to obtain the evm. The receipt is used to
guarantee that the tx hash provided is the one that created the BTC Relay contract
(see contractAddress property of the receipt).
</p>
<pre>
> tx='0x8e135b828db84bce864d4789cde112eacc04d3d21b5fa569f12f79d8d3ded3c6'
> eth.getTransactionReceipt(tx)
{
blockHash: "0x6739c150e39dbcc5c4c4b078a33061db444ef72ca4b671960fbec8ad49f4f99c",
blockNumber: 484230,
contractAddress: "0x5770345100a27b15f5b40bec86a701f888e8c601",
cumulativeGasUsed: 2776382,
gasUsed: 2776382,
logs: [],
transactionHash: "0x8e135b828db84bce864d4789cde112eacc04d3d21b5fa569f12f79d8d3ded3c6",
transactionIndex: 0
}
> objTx = eth.getTransaction(tx)
> objTx.input
</pre>
<p>
Compare objTx.input with the contents of compiled.evm and you will see
that they match identically (except for 0x at the front of objTx.input)
</p>
<p>
The version of the <a href="https://github.com/ethereum/serpent/tree/f0b4128f91d173fb3f6de48a6993e7db75446924">Serpent compiler used is commit f0b4128f91d173fb3f6de48a6993e7db75446924</a>
</p>
</div>
<hr>
<div class="jumbotron">
<p>
<a href="https://github.com/ethereum/btcrelay/blob/master/LICENSE">BTC RELAY IS PROVIDED "AS IS"</a>, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
</p>
</div>
<hr>
<div class="footer-logo">
<img src="./images/ethereum-logo-small.png"/>
</div>
</div>
</body>
</html>