├── .dockerignore ├── .github └── workflows │ └── rust.yml ├── .gitignore ├── .travis.yml ├── Cargo.lock ├── Cargo.toml ├── Dockerfile ├── LICENSE ├── README.md ├── cfg.example.toml ├── extra ├── dappnode-goerli │ ├── Dockerfile │ ├── avatar.png │ ├── cfg.goerli.toml │ ├── dappnode_package.json │ ├── docker-compose.yml │ └── package.sh ├── geth-devnet │ ├── config │ │ ├── genesis.json │ │ ├── keystore │ │ │ └── UTC--2019-05-15T07-25-50.175906751Z--83a909262608c650bd9b0ae06e29d90d0f67ac5e │ │ ├── passwd │ │ └── tesseracts.toml │ └── start.sh ├── screenshot.png └── test.sol ├── src ├── bootstrap │ ├── config.rs │ ├── error.rs │ ├── mod.rs │ └── staticres.rs ├── db │ ├── appdb.rs │ ├── error.rs │ ├── iterators.rs │ ├── mod.rs │ ├── tests.rs │ ├── types.rs │ └── utils.rs ├── eth │ ├── contract │ │ ├── error.rs │ │ ├── mod.rs │ │ ├── parser.rs │ │ └── verifier.rs │ ├── error.rs │ ├── geth │ │ ├── clique.rs │ │ ├── mod.rs │ │ └── web3.rs │ ├── mod.rs │ ├── reader.rs │ └── types.rs ├── explorer │ ├── address.rs │ ├── block.rs │ ├── error.rs │ ├── home.rs │ ├── html.rs │ ├── mod.rs │ ├── neb.rs │ ├── server.rs │ ├── tx.rs │ └── utils.rs ├── main.rs ├── scrapper │ ├── error.rs │ ├── mod.rs │ └── scrap.rs └── state.rs └── static ├── tmpl ├── address.handlebars ├── block.handlebars ├── config.handlebars ├── footer.handlebars ├── header.handlebars ├── home.handlebars ├── neb.handlebars └── tx.handlebars └── web ├── common.js ├── purecss-tabs.css └── style.css /.dockerignore: -------------------------------------------------------------------------------- 1 | Dockerfile 2 | target 3 | -------------------------------------------------------------------------------- /.github/workflows/rust.yml: -------------------------------------------------------------------------------- 1 | name: Rust 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | steps: 11 | - uses: actions/checkout@v2 12 | - name: Build 13 | run: cargo build --verbose 14 | - name: Run tests 15 | run: cargo test --verbose 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | data 3 | run_infura.sh 4 | run_nn.sh 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: rust 2 | rust: 3 | - stable -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tesseracts" 3 | version = "0.1.0" 4 | authors = ["Adrià Massanet "] 5 | 6 | [dependencies] 7 | web3 = { git = "https://github.com/tomusdrw/rust-web3" } 8 | rustc-hex = "2.0.1" 9 | handlebars = "1.1.0" 10 | rust-embed = "4.2.0" 11 | lazy_static = "1.2.0" 12 | serde = "1.0.82" 13 | serde_json = "1.0.33" 14 | serde_cbor = "0.9.0" 15 | serde_derive = "1.0.82" 16 | rocksdb = "0.10.1" 17 | rand = "0.6.1" 18 | ctrlc = "3.1.1" 19 | toml = "0.4.10" 20 | rouille = "3.0.0" 21 | ethabi = "6.1.0" 22 | reqwest = "0.9.5" 23 | keccak-hash = "0.1.2" 24 | chrono = "0.4.6" 25 | log = "0.4.6" 26 | stderrlog = "0.4.1" 27 | structopt = "0.2.14" 28 | rlp = "0.3.0" 29 | ethkey = { git = "https://github.com/paritytech/parity.git" } 30 | error-chain = { version = "0.12", default-features = false } 31 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:edge AS builder 2 | 3 | RUN apk add build-base \ 4 | cmake \ 5 | linux-headers \ 6 | openssl-dev \ 7 | cargo \ 8 | clang \ 9 | clang-libs \ 10 | git 11 | 12 | WORKDIR /home/rust/ 13 | COPY . . 14 | WORKDIR /home/rust/tesseracts 15 | RUN cargo build --release 16 | 17 | FROM alpine:edge 18 | WORKDIR /home/rust/ 19 | COPY --from=builder /home/rust/target/release/tesseracts . 20 | 21 | EXPOSE 8000 22 | 23 | RUN apk add clang clang-libs ca-certificates 24 | 25 | ENTRYPOINT ["./tesseracts"] 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | # GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 [Free Software Foundation, Inc.](http://fsf.org/) 5 | 6 | Everyone is permitted to copy and distribute verbatim copies of this license 7 | document, but changing it is not allowed. 8 | 9 | ## Preamble 10 | 11 | The GNU General Public License is a free, copyleft license for software and 12 | other kinds of works. 13 | 14 | The licenses for most software and other practical works are designed to take 15 | away your freedom to share and change the works. By contrast, the GNU General 16 | Public License is intended to guarantee your freedom to share and change all 17 | versions of a program--to make sure it remains free software for all its users. 18 | We, the Free Software Foundation, use the GNU General Public License for most 19 | of our software; it applies also to any other work released this way by its 20 | authors. You can apply it to your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not price. Our 23 | General Public Licenses are designed to make sure that you have the freedom to 24 | distribute copies of free software (and charge for them if you wish), that you 25 | receive source code or can get it if you want it, that you can change the 26 | software or use pieces of it in new free programs, and that you know you can do 27 | these things. 28 | 29 | To protect your rights, we need to prevent others from denying you these rights 30 | or asking you to surrender the rights. Therefore, you have certain 31 | responsibilities if you distribute copies of the software, or if you modify it: 32 | responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether gratis or for 35 | a fee, you must pass on to the recipients the same freedoms that you received. 36 | You must make sure that they, too, receive or can get the source code. And you 37 | must show them these terms so they know their rights. 38 | 39 | Developers that use the GNU GPL protect your rights with two steps: 40 | 41 | 1. assert copyright on the software, and 42 | 2. offer you this License giving you legal permission to copy, distribute 43 | and/or modify it. 44 | 45 | For the developers' and authors' protection, the GPL clearly explains that 46 | there is no warranty for this free software. For both users' and authors' sake, 47 | the GPL requires that modified versions be marked as changed, so that their 48 | problems will not be attributed erroneously to authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run modified 51 | versions of the software inside them, although the manufacturer can do so. This 52 | is fundamentally incompatible with the aim of protecting users' freedom to 53 | change the software. The systematic pattern of such abuse occurs in the area of 54 | products for individuals to use, which is precisely where it is most 55 | unacceptable. Therefore, we have designed this version of the GPL to prohibit 56 | the practice for those products. If such problems arise substantially in other 57 | domains, we stand ready to extend this provision to those domains in future 58 | versions of the GPL, as needed to protect the freedom of users. 59 | 60 | Finally, every program is threatened constantly by software patents. States 61 | should not allow patents to restrict development and use of software on 62 | general-purpose computers, but in those that do, we wish to avoid the special 63 | danger that patents applied to a free program could make it effectively 64 | proprietary. To prevent this, the GPL assures that patents cannot be used to 65 | render the program non-free. 66 | 67 | The precise terms and conditions for copying, distribution and modification 68 | follow. 69 | 70 | ## TERMS AND CONDITIONS 71 | 72 | ### 0. Definitions. 73 | 74 | *This License* refers to version 3 of the GNU General Public License. 75 | 76 | *Copyright* also means copyright-like laws that apply to other kinds of works, 77 | such as semiconductor masks. 78 | 79 | *The Program* refers to any copyrightable work licensed under this License. 80 | Each licensee is addressed as *you*. *Licensees* and *recipients* may be 81 | individuals or organizations. 82 | 83 | To *modify* a work means to copy from or adapt all or part of the work in a 84 | fashion requiring copyright permission, other than the making of an exact copy. 85 | The resulting work is called a *modified version* of the earlier work or a work 86 | *based on* the earlier work. 87 | 88 | A *covered work* means either the unmodified Program or a work based on the 89 | Program. 90 | 91 | To *propagate* a work means to do anything with it that, without permission, 92 | would make you directly or secondarily liable for infringement under applicable 93 | copyright law, except executing it on a computer or modifying a private copy. 94 | Propagation includes copying, distribution (with or without modification), 95 | making available to the public, and in some countries other activities as well. 96 | 97 | To *convey* a work means any kind of propagation that enables other parties to 98 | make or receive copies. Mere interaction with a user through a computer 99 | network, with no transfer of a copy, is not conveying. 100 | 101 | An interactive user interface displays *Appropriate Legal Notices* to the 102 | extent that it includes a convenient and prominently visible feature that 103 | 104 | 1. displays an appropriate copyright notice, and 105 | 2. tells the user that there is no warranty for the work (except to the 106 | extent that warranties are provided), that licensees may convey the work 107 | under this License, and how to view a copy of this License. 108 | 109 | If the interface presents a list of user commands or options, such as a menu, a 110 | prominent item in the list meets this criterion. 111 | 112 | ### 1. Source Code. 113 | 114 | The *source code* for a work means the preferred form of the work for making 115 | modifications to it. *Object code* means any non-source form of a work. 116 | 117 | A *Standard Interface* means an interface that either is an official standard 118 | defined by a recognized standards body, or, in the case of interfaces specified 119 | for a particular programming language, one that is widely used among developers 120 | working in that language. 121 | 122 | The *System Libraries* of an executable work include anything, other than the 123 | work as a whole, that (a) is included in the normal form of packaging a Major 124 | Component, but which is not part of that Major Component, and (b) serves only 125 | to enable use of the work with that Major Component, or to implement a Standard 126 | Interface for which an implementation is available to the public in source code 127 | form. A *Major Component*, in this context, means a major essential component 128 | (kernel, window system, and so on) of the specific operating system (if any) on 129 | which the executable work runs, or a compiler used to produce the work, or an 130 | object code interpreter used to run it. 131 | 132 | The *Corresponding Source* for a work in object code form means all the source 133 | code needed to generate, install, and (for an executable work) run the object 134 | code and to modify the work, including scripts to control those activities. 135 | However, it does not include the work's System Libraries, or general-purpose 136 | tools or generally available free programs which are used unmodified in 137 | performing those activities but which are not part of the work. For example, 138 | Corresponding Source includes interface definition files associated with source 139 | files for the work, and the source code for shared libraries and dynamically 140 | linked subprograms that the work is specifically designed to require, such as 141 | by intimate data communication or control flow between those subprograms and 142 | other parts of the work. 143 | 144 | The Corresponding Source need not include anything that users can regenerate 145 | automatically from other parts of the Corresponding Source. 146 | 147 | The Corresponding Source for a work in source code form is that same work. 148 | 149 | ### 2. Basic Permissions. 150 | 151 | All rights granted under this License are granted for the term of copyright on 152 | the Program, and are irrevocable provided the stated conditions are met. This 153 | License explicitly affirms your unlimited permission to run the unmodified 154 | Program. The output from running a covered work is covered by this License only 155 | if the output, given its content, constitutes a covered work. This License 156 | acknowledges your rights of fair use or other equivalent, as provided by 157 | copyright law. 158 | 159 | You may make, run and propagate covered works that you do not convey, without 160 | conditions so long as your license otherwise remains in force. You may convey 161 | covered works to others for the sole purpose of having them make modifications 162 | exclusively for you, or provide you with facilities for running those works, 163 | provided that you comply with the terms of this License in conveying all 164 | material for which you do not control copyright. Those thus making or running 165 | the covered works for you must do so exclusively on your behalf, under your 166 | direction and control, on terms that prohibit them from making any copies of 167 | your copyrighted material outside their relationship with you. 168 | 169 | Conveying under any other circumstances is permitted solely under the 170 | conditions stated below. Sublicensing is not allowed; section 10 makes it 171 | unnecessary. 172 | 173 | ### 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 174 | 175 | No covered work shall be deemed part of an effective technological measure 176 | under any applicable law fulfilling obligations under article 11 of the WIPO 177 | copyright treaty adopted on 20 December 1996, or similar laws prohibiting or 178 | restricting circumvention of such measures. 179 | 180 | When you convey a covered work, you waive any legal power to forbid 181 | circumvention of technological measures to the extent such circumvention is 182 | effected by exercising rights under this License with respect to the covered 183 | work, and you disclaim any intention to limit operation or modification of the 184 | work as a means of enforcing, against the work's users, your or third parties' 185 | legal rights to forbid circumvention of technological measures. 186 | 187 | ### 4. Conveying Verbatim Copies. 188 | 189 | You may convey verbatim copies of the Program's source code as you receive it, 190 | in any medium, provided that you conspicuously and appropriately publish on 191 | each copy an appropriate copyright notice; keep intact all notices stating that 192 | this License and any non-permissive terms added in accord with section 7 apply 193 | to the code; keep intact all notices of the absence of any warranty; and give 194 | all recipients a copy of this License along with the Program. 195 | 196 | You may charge any price or no price for each copy that you convey, and you may 197 | offer support or warranty protection for a fee. 198 | 199 | ### 5. Conveying Modified Source Versions. 200 | 201 | You may convey a work based on the Program, or the modifications to produce it 202 | from the Program, in the form of source code under the terms of section 4, 203 | provided that you also meet all of these conditions: 204 | 205 | - a) The work must carry prominent notices stating that you modified it, and 206 | giving a relevant date. 207 | - b) The work must carry prominent notices stating that it is released under 208 | this License and any conditions added under section 7. This requirement 209 | modifies the requirement in section 4 to *keep intact all notices*. 210 | - c) You must license the entire work, as a whole, under this License to 211 | anyone who comes into possession of a copy. This License will therefore 212 | apply, along with any applicable section 7 additional terms, to the whole 213 | of the work, and all its parts, regardless of how they are packaged. This 214 | License gives no permission to license the work in any other way, but it 215 | does not invalidate such permission if you have separately received it. 216 | - d) If the work has interactive user interfaces, each must display 217 | Appropriate Legal Notices; however, if the Program has interactive 218 | interfaces that do not display Appropriate Legal Notices, your work need 219 | not make them do so. 220 | 221 | A compilation of a covered work with other separate and independent works, 222 | which are not by their nature extensions of the covered work, and which are not 223 | combined with it such as to form a larger program, in or on a volume of a 224 | storage or distribution medium, is called an *aggregate* if the compilation and 225 | its resulting copyright are not used to limit the access or legal rights of the 226 | compilation's users beyond what the individual works permit. Inclusion of a 227 | covered work in an aggregate does not cause this License to apply to the other 228 | parts of the aggregate. 229 | 230 | ### 6. Conveying Non-Source Forms. 231 | 232 | You may convey a covered work in object code form under the terms of sections 4 233 | and 5, provided that you also convey the machine-readable Corresponding Source 234 | under the terms of this License, in one of these ways: 235 | 236 | - a) Convey the object code in, or embodied in, a physical product (including 237 | a physical distribution medium), accompanied by the Corresponding Source 238 | fixed on a durable physical medium customarily used for software 239 | interchange. 240 | - b) Convey the object code in, or embodied in, a physical product (including 241 | a physical distribution medium), accompanied by a written offer, valid for 242 | at least three years and valid for as long as you offer spare parts or 243 | customer support for that product model, to give anyone who possesses the 244 | object code either 245 | 1. a copy of the Corresponding Source for all the software in the product 246 | that is covered by this License, on a durable physical medium 247 | customarily used for software interchange, for a price no more than your 248 | reasonable cost of physically performing this conveying of source, or 249 | 2. access to copy the Corresponding Source from a network server at no 250 | charge. 251 | - c) Convey individual copies of the object code with a copy of the written 252 | offer to provide the Corresponding Source. This alternative is allowed only 253 | occasionally and noncommercially, and only if you received the object code 254 | with such an offer, in accord with subsection 6b. 255 | - d) Convey the object code by offering access from a designated place 256 | (gratis or for a charge), and offer equivalent access to the Corresponding 257 | Source in the same way through the same place at no further charge. You 258 | need not require recipients to copy the Corresponding Source along with the 259 | object code. If the place to copy the object code is a network server, the 260 | Corresponding Source may be on a different server operated by you or a 261 | third party) that supports equivalent copying facilities, provided you 262 | maintain clear directions next to the object code saying where to find the 263 | Corresponding Source. Regardless of what server hosts the Corresponding 264 | Source, you remain obligated to ensure that it is available for as long as 265 | needed to satisfy these requirements. 266 | - e) Convey the object code using peer-to-peer transmission, provided you 267 | inform other peers where the object code and Corresponding Source of the 268 | work are being offered to the general public at no charge under subsection 269 | 6d. 270 | 271 | A separable portion of the object code, whose source code is excluded from the 272 | Corresponding Source as a System Library, need not be included in conveying the 273 | object code work. 274 | 275 | A *User Product* is either 276 | 277 | 1. a *consumer product*, which means any tangible personal property which is 278 | normally used for personal, family, or household purposes, or 279 | 2. anything designed or sold for incorporation into a dwelling. 280 | 281 | In determining whether a product is a consumer product, doubtful cases shall be 282 | resolved in favor of coverage. For a particular product received by a 283 | particular user, *normally used* refers to a typical or common use of that 284 | class of product, regardless of the status of the particular user or of the way 285 | in which the particular user actually uses, or expects or is expected to use, 286 | the product. A product is a consumer product regardless of whether the product 287 | has substantial commercial, industrial or non-consumer uses, unless such uses 288 | represent the only significant mode of use of the product. 289 | 290 | *Installation Information* for a User Product means any methods, procedures, 291 | authorization keys, or other information required to install and execute 292 | modified versions of a covered work in that User Product from a modified 293 | version of its Corresponding Source. The information must suffice to ensure 294 | that the continued functioning of the modified object code is in no case 295 | prevented or interfered with solely because modification has been made. 296 | 297 | If you convey an object code work under this section in, or with, or 298 | specifically for use in, a User Product, and the conveying occurs as part of a 299 | transaction in which the right of possession and use of the User Product is 300 | transferred to the recipient in perpetuity or for a fixed term (regardless of 301 | how the transaction is characterized), the Corresponding Source conveyed under 302 | this section must be accompanied by the Installation Information. But this 303 | requirement does not apply if neither you nor any third party retains the 304 | ability to install modified object code on the User Product (for example, the 305 | work has been installed in ROM). 306 | 307 | The requirement to provide Installation Information does not include a 308 | requirement to continue to provide support service, warranty, or updates for a 309 | work that has been modified or installed by the recipient, or for the User 310 | Product in which it has been modified or installed. Access to a network may be 311 | denied when the modification itself materially and adversely affects the 312 | operation of the network or violates the rules and protocols for communication 313 | across the network. 314 | 315 | Corresponding Source conveyed, and Installation Information provided, in accord 316 | with this section must be in a format that is publicly documented (and with an 317 | implementation available to the public in source code form), and must require 318 | no special password or key for unpacking, reading or copying. 319 | 320 | ### 7. Additional Terms. 321 | 322 | *Additional permissions* are terms that supplement the terms of this License by 323 | making exceptions from one or more of its conditions. Additional permissions 324 | that are applicable to the entire Program shall be treated as though they were 325 | included in this License, to the extent that they are valid under applicable 326 | law. If additional permissions apply only to part of the Program, that part may 327 | be used separately under those permissions, but the entire Program remains 328 | governed by this License without regard to the additional permissions. 329 | 330 | When you convey a copy of a covered work, you may at your option remove any 331 | additional permissions from that copy, or from any part of it. (Additional 332 | permissions may be written to require their own removal in certain cases when 333 | you modify the work.) You may place additional permissions on material, added 334 | by you to a covered work, for which you have or can give appropriate copyright 335 | permission. 336 | 337 | Notwithstanding any other provision of this License, for material you add to a 338 | covered work, you may (if authorized by the copyright holders of that material) 339 | supplement the terms of this License with terms: 340 | 341 | - a) Disclaiming warranty or limiting liability differently from the terms of 342 | sections 15 and 16 of this License; or 343 | - b) Requiring preservation of specified reasonable legal notices or author 344 | attributions in that material or in the Appropriate Legal Notices displayed 345 | by works containing it; or 346 | - c) Prohibiting misrepresentation of the origin of that material, or 347 | requiring that modified versions of such material be marked in reasonable 348 | ways as different from the original version; or 349 | - d) Limiting the use for publicity purposes of names of licensors or authors 350 | of the material; or 351 | - e) Declining to grant rights under trademark law for use of some trade 352 | names, trademarks, or service marks; or 353 | - f) Requiring indemnification of licensors and authors of that material by 354 | anyone who conveys the material (or modified versions of it) with 355 | contractual assumptions of liability to the recipient, for any liability 356 | that these contractual assumptions directly impose on those licensors and 357 | authors. 358 | 359 | All other non-permissive additional terms are considered *further restrictions* 360 | within the meaning of section 10. If the Program as you received it, or any 361 | part of it, contains a notice stating that it is governed by this License along 362 | with a term that is a further restriction, you may remove that term. If a 363 | license document contains a further restriction but permits relicensing or 364 | conveying under this License, you may add to a covered work material governed 365 | by the terms of that license document, provided that the further restriction 366 | does not survive such relicensing or conveying. 367 | 368 | If you add terms to a covered work in accord with this section, you must place, 369 | in the relevant source files, a statement of the additional terms that apply to 370 | those files, or a notice indicating where to find the applicable terms. 371 | 372 | Additional terms, permissive or non-permissive, may be stated in the form of a 373 | separately written license, or stated as exceptions; the above requirements 374 | apply either way. 375 | 376 | ### 8. Termination. 377 | 378 | You may not propagate or modify a covered work except as expressly provided 379 | under this License. Any attempt otherwise to propagate or modify it is void, 380 | and will automatically terminate your rights under this License (including any 381 | patent licenses granted under the third paragraph of section 11). 382 | 383 | However, if you cease all violation of this License, then your license from a 384 | particular copyright holder is reinstated 385 | 386 | - a) provisionally, unless and until the copyright holder explicitly and 387 | finally terminates your license, and 388 | - b) permanently, if the copyright holder fails to notify you of the 389 | violation by some reasonable means prior to 60 days after the cessation. 390 | 391 | Moreover, your license from a particular copyright holder is reinstated 392 | permanently if the copyright holder notifies you of the violation by some 393 | reasonable means, this is the first time you have received notice of violation 394 | of this License (for any work) from that copyright holder, and you cure the 395 | violation prior to 30 days after your receipt of the notice. 396 | 397 | Termination of your rights under this section does not terminate the licenses 398 | of parties who have received copies or rights from you under this License. If 399 | your rights have been terminated and not permanently reinstated, you do not 400 | qualify to receive new licenses for the same material under section 10. 401 | 402 | ### 9. Acceptance Not Required for Having Copies. 403 | 404 | You are not required to accept this License in order to receive or run a copy 405 | of the Program. Ancillary propagation of a covered work occurring solely as a 406 | consequence of using peer-to-peer transmission to receive a copy likewise does 407 | not require acceptance. However, nothing other than this License grants you 408 | permission to propagate or modify any covered work. These actions infringe 409 | copyright if you do not accept this License. Therefore, by modifying or 410 | propagating a covered work, you indicate your acceptance of this License to do 411 | so. 412 | 413 | ### 10. Automatic Licensing of Downstream Recipients. 414 | 415 | Each time you convey a covered work, the recipient automatically receives a 416 | license from the original licensors, to run, modify and propagate that work, 417 | subject to this License. You are not responsible for enforcing compliance by 418 | third parties with this License. 419 | 420 | An *entity transaction* is a transaction transferring control of an 421 | organization, or substantially all assets of one, or subdividing an 422 | organization, or merging organizations. If propagation of a covered work 423 | results from an entity transaction, each party to that transaction who receives 424 | a copy of the work also receives whatever licenses to the work the party's 425 | predecessor in interest had or could give under the previous paragraph, plus a 426 | right to possession of the Corresponding Source of the work from the 427 | predecessor in interest, if the predecessor has it or can get it with 428 | reasonable efforts. 429 | 430 | You may not impose any further restrictions on the exercise of the rights 431 | granted or affirmed under this License. For example, you may not impose a 432 | license fee, royalty, or other charge for exercise of rights granted under this 433 | License, and you may not initiate litigation (including a cross-claim or 434 | counterclaim in a lawsuit) alleging that any patent claim is infringed by 435 | making, using, selling, offering for sale, or importing the Program or any 436 | portion of it. 437 | 438 | ### 11. Patents. 439 | 440 | A *contributor* is a copyright holder who authorizes use under this License of 441 | the Program or a work on which the Program is based. The work thus licensed is 442 | called the contributor's *contributor version*. 443 | 444 | A contributor's *essential patent claims* are all patent claims owned or 445 | controlled by the contributor, whether already acquired or hereafter acquired, 446 | that would be infringed by some manner, permitted by this License, of making, 447 | using, or selling its contributor version, but do not include claims that would 448 | be infringed only as a consequence of further modification of the contributor 449 | version. For purposes of this definition, *control* includes the right to grant 450 | patent sublicenses in a manner consistent with the requirements of this 451 | License. 452 | 453 | Each contributor grants you a non-exclusive, worldwide, royalty-free patent 454 | license under the contributor's essential patent claims, to make, use, sell, 455 | offer for sale, import and otherwise run, modify and propagate the contents of 456 | its contributor version. 457 | 458 | In the following three paragraphs, a *patent license* is any express agreement 459 | or commitment, however denominated, not to enforce a patent (such as an express 460 | permission to practice a patent or covenant not to sue for patent 461 | infringement). To *grant* such a patent license to a party means to make such 462 | an agreement or commitment not to enforce a patent against the party. 463 | 464 | If you convey a covered work, knowingly relying on a patent license, and the 465 | Corresponding Source of the work is not available for anyone to copy, free of 466 | charge and under the terms of this License, through a publicly available 467 | network server or other readily accessible means, then you must either 468 | 469 | 1. cause the Corresponding Source to be so available, or 470 | 2. arrange to deprive yourself of the benefit of the patent license for this 471 | particular work, or 472 | 3. arrange, in a manner consistent with the requirements of this License, to 473 | extend the patent license to downstream recipients. 474 | 475 | *Knowingly relying* means you have actual knowledge that, but for the patent 476 | license, your conveying the covered work in a country, or your recipient's use 477 | of the covered work in a country, would infringe one or more identifiable 478 | patents in that country that you have reason to believe are valid. 479 | 480 | If, pursuant to or in connection with a single transaction or arrangement, you 481 | convey, or propagate by procuring conveyance of, a covered work, and grant a 482 | patent license to some of the parties receiving the covered work authorizing 483 | them to use, propagate, modify or convey a specific copy of the covered work, 484 | then the patent license you grant is automatically extended to all recipients 485 | of the covered work and works based on it. 486 | 487 | A patent license is *discriminatory* if it does not include within the scope of 488 | its coverage, prohibits the exercise of, or is conditioned on the non-exercise 489 | of one or more of the rights that are specifically granted under this License. 490 | You may not convey a covered work if you are a party to an arrangement with a 491 | third party that is in the business of distributing software, under which you 492 | make payment to the third party based on the extent of your activity of 493 | conveying the work, and under which the third party grants, to any of the 494 | parties who would receive the covered work from you, a discriminatory patent 495 | license 496 | 497 | - a) in connection with copies of the covered work conveyed by you (or copies 498 | made from those copies), or 499 | - b) primarily for and in connection with specific products or compilations 500 | that contain the covered work, unless you entered into that arrangement, or 501 | that patent license was granted, prior to 28 March 2007. 502 | 503 | Nothing in this License shall be construed as excluding or limiting any implied 504 | license or other defenses to infringement that may otherwise be available to 505 | you under applicable patent law. 506 | 507 | ### 12. No Surrender of Others' Freedom. 508 | 509 | If conditions are imposed on you (whether by court order, agreement or 510 | otherwise) that contradict the conditions of this License, they do not excuse 511 | you from the conditions of this License. If you cannot convey a covered work so 512 | as to satisfy simultaneously your obligations under this License and any other 513 | pertinent obligations, then as a consequence you may not convey it at all. For 514 | example, if you agree to terms that obligate you to collect a royalty for 515 | further conveying from those to whom you convey the Program, the only way you 516 | could satisfy both those terms and this License would be to refrain entirely 517 | from conveying the Program. 518 | 519 | ### 13. Use with the GNU Affero General Public License. 520 | 521 | Notwithstanding any other provision of this License, you have permission to 522 | link or combine any covered work with a work licensed under version 3 of the 523 | GNU Affero General Public License into a single combined work, and to convey 524 | the resulting work. The terms of this License will continue to apply to the 525 | part which is the covered work, but the special requirements of the GNU Affero 526 | General Public License, section 13, concerning interaction through a network 527 | will apply to the combination as such. 528 | 529 | ### 14. Revised Versions of this License. 530 | 531 | The Free Software Foundation may publish revised and/or new versions of the GNU 532 | General Public License from time to time. Such new versions will be similar in 533 | spirit to the present version, but may differ in detail to address new problems 534 | or concerns. 535 | 536 | Each version is given a distinguishing version number. If the Program specifies 537 | that a certain numbered version of the GNU General Public License *or any later 538 | version* applies to it, you have the option of following the terms and 539 | conditions either of that numbered version or of any later version published by 540 | the Free Software Foundation. If the Program does not specify a version number 541 | of the GNU General Public License, you may choose any version ever published by 542 | the Free Software Foundation. 543 | 544 | If the Program specifies that a proxy can decide which future versions of the 545 | GNU General Public License can be used, that proxy's public statement of 546 | acceptance of a version permanently authorizes you to choose that version for 547 | the Program. 548 | 549 | Later license versions may give you additional or different permissions. 550 | However, no additional obligations are imposed on any author or copyright 551 | holder as a result of your choosing to follow a later version. 552 | 553 | ### 15. Disclaimer of Warranty. 554 | 555 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE 556 | LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER 557 | PARTIES PROVIDE THE PROGRAM *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER 558 | EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 559 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE 560 | QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE 561 | DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR 562 | CORRECTION. 563 | 564 | ### 16. Limitation of Liability. 565 | 566 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY 567 | COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS 568 | PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, 569 | INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE 570 | THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED 571 | INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE 572 | PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY 573 | HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 574 | 575 | ### 17. Interpretation of Sections 15 and 16. 576 | 577 | If the disclaimer of warranty and limitation of liability provided above cannot 578 | be given local legal effect according to their terms, reviewing courts shall 579 | apply local law that most closely approximates an absolute waiver of all civil 580 | liability in connection with the Program, unless a warranty or assumption of 581 | liability accompanies a copy of the Program in return for a fee. 582 | 583 | ## END OF TERMS AND CONDITIONS ### 584 | 585 | ### How to Apply These Terms to Your New Programs 586 | 587 | If you develop a new program, and you want it to be of the greatest possible 588 | use to the public, the best way to achieve this is to make it free software 589 | which everyone can redistribute and change under these terms. 590 | 591 | To do so, attach the following notices to the program. It is safest to attach 592 | them to the start of each source file to most effectively state the exclusion 593 | of warranty; and each file should have at least the *copyright* line and a 594 | pointer to where the full notice is found. 595 | 596 | 597 | Copyright (C) 598 | 599 | This program is free software: you can redistribute it and/or modify 600 | it under the terms of the GNU General Public License as published by 601 | the Free Software Foundation, either version 3 of the License, or 602 | (at your option) any later version. 603 | 604 | This program is distributed in the hope that it will be useful, 605 | but WITHOUT ANY WARRANTY; without even the implied warranty of 606 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 607 | GNU General Public License for more details. 608 | 609 | You should have received a copy of the GNU General Public License 610 | along with this program. If not, see . 611 | 612 | Also add information on how to contact you by electronic and paper mail. 613 | 614 | If the program does terminal interaction, make it output a short notice like 615 | this when it starts in an interactive mode: 616 | 617 | Copyright (C) 618 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 619 | This is free software, and you are welcome to redistribute it 620 | under certain conditions; type `show c' for details. 621 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![](https://www.rust-lang.org/logos/rust-logo-32x32-blk.png) 2 | ![Rust](https://github.com/adria0/tesseracts/workflows/Rust/badge.svg) 3 | [![Docker build](https://img.shields.io/docker/automated/adria0/tesseracts.svg?style=flat)](https://cloud.docker.com/repository/docker/adria0/tesseracts) 4 | [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) 5 | 6 | # Tesseracts 7 | A minimalistic block explorer initially created to learn rust. 8 | 9 | This block explorer has been created as a rust self-learning project to give support to [nou.network](https://nou.network), a small beta PoA for social projects with nodes from university teachers ([UPC](https://www.upc.edu), [UAB](https://www.uab.cat), [UOC](https://www.uoc.edu), [UdG](https://www.udg.edu), [UIB](https://www.uib.es/es)), [GuifiNet](https://guifi.net/en) and members the [White Hat Group](https://giveth.io/#heronav). 10 | 11 | ## Disclaimer 12 | 13 | This is an experimental block explorer, my first attempt to write something in rust, and expect to find newbie rustacean antipatterns here. Nonetheless it seems that it works as expected. 14 | 15 | ## Features 16 | 17 | ![screenshot](https://raw.githubusercontent.com/adriamb/tesseracts/master/extra/screenshot.png) 18 | 19 | At this moment it comes with the folowing features (checked items) and there's a roadmap for the next ones (unchecked items) 20 | 21 | - [X] Last blocks page 22 | - [X] Show block 23 | - [X] Show transaction 24 | - [X] Show address and their transactions 25 | - [X] Have a copy of blockchain in the local db 26 | - [X] Gracefull termination with control-C 27 | - [X] Configuration file 28 | - [X] Embeeded templates (does not need external files) 29 | - [X] Upload contracts and parse calls and logs 30 | - [X] Block & Tx pagination 31 | - [X] Command line parameters with better debug 32 | - [X] Internal transactions 33 | - [X] Parse clique block headers 34 | - [X] Named accounts 35 | - [X] Automatic function detection 36 | - [ ] Download receipts in batch 37 | - [ ] Forward-backwards block scanning 38 | - [ ] Set postly URL... `/tx` `/addr` `/block` 39 | - [ ] Automatic ERC20 parsing `/erc20` 40 | - [ ] Suport for user configuration 41 | - [ ] Naming addresses support 42 | - [ ] Specify token address 43 | 44 | ## Set up 45 | 46 | To run tesseracts, you need to install rust 47 | 48 | `curl https://sh.rustup.rs -sSf | sh` 49 | 50 | create a .toml config file (see `cfg.example.toml`) 51 | 52 | run the application with (if your config file is named `cfg.toml`) 53 | 54 | `cargo run -- --cfg cfg.toml -vvv` 55 | -------------------------------------------------------------------------------- /cfg.example.toml: -------------------------------------------------------------------------------- 1 | # user iterface ----------------------------------- 2 | 3 | # title of the page, e.g. "tesseracts" 4 | ui_title = 5 | 6 | # database ---------------------------------------- 7 | 8 | # where the database is located 9 | db_path = 10 | 11 | # true|false if we want to scan blocks and save it into db 12 | scan = 13 | 14 | # the starting block to start to retrieve blocks (only iff scan==true) 15 | scan_start_block = 16 | 17 | # store with tx are contained in addr? (bool) 18 | db_store_addr = 19 | 20 | # store the transactions and receipts? (bool) 21 | db_store_tx = 22 | 23 | # store internal transactions? (bool) 24 | db_store_itx = 25 | 26 | # store list of last non empty blocks? (bool) 27 | db_store_neb = 28 | 29 | # web3 ---------------------------------------------- 30 | 31 | # web3 json-rpc port, e.g. http://localhost:8545 32 | web3_url = 33 | 34 | # client type 35 | # "geth_clique" for geth PoS 36 | # "geth_pow" for geth PoW 37 | # "geth" to autodetect geth_clique and geth_pow 38 | web3_client = 39 | 40 | # process internal txs, true or false 41 | # in geth requieres: 42 | # --syncmode=full 43 | # --gcmode=archive 44 | # --rpcapi debug 45 | web3_itx = 46 | 47 | # compiler ------------------------------------------ 48 | 49 | # the path where solc binaries are stored (optional) 50 | solc_path = 51 | 52 | # solidity compiler can be bypassedi, by specifing the abi 53 | solc_bypass = 54 | 55 | # server -------------------------------------------- 56 | 57 | # http server binding (e.g. "0.0.0.0:8000") 58 | bind = 59 | 60 | # names --------------------------------------------- 61 | 62 | # multiple named_address entries can be added to name accouts 63 | [[named_address]] 64 | # e.g. "me" 65 | name = 66 | # e.g. "0x5d03df716ebf0e11bfb3e178fb39ed672c59ee61" 67 | address = 68 | -------------------------------------------------------------------------------- /extra/dappnode-goerli/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:edge AS builder 2 | 3 | RUN apk add build-base \ 4 | cmake \ 5 | linux-headers \ 6 | openssl-dev \ 7 | cargo \ 8 | clang \ 9 | clang-libs \ 10 | git 11 | 12 | WORKDIR /home/rust/ 13 | COPY . . 14 | WORKDIR /home/rust/tesseracts 15 | RUN cargo build --release 16 | 17 | FROM alpine:edge 18 | WORKDIR /home/rust/ 19 | COPY --from=builder /home/rust/target/release/tesseracts . 20 | COPY --from=builder /home/rust/cfg.goerli.toml . 21 | 22 | EXPOSE 80 23 | 24 | RUN apk add clang clang-libs ca-certificates 25 | 26 | ENTRYPOINT ["./tesseracts","--cfg","cfg.goerli.toml","-vvv"] -------------------------------------------------------------------------------- /extra/dappnode-goerli/avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adria0/tesseracts/cba0221ddd4e089a4627ca23ea9550bb16827293/extra/dappnode-goerli/avatar.png -------------------------------------------------------------------------------- /extra/dappnode-goerli/cfg.goerli.toml: -------------------------------------------------------------------------------- 1 | # user iterface ----------------------------------- 2 | 3 | # title of the page, e.g. "tesseracts" 4 | ui_title = "göerli" 5 | 6 | # database ---------------------------------------- 7 | 8 | # where the database is located 9 | db_path = "/tmp/db" 10 | 11 | # true|false if we want to scan blocks and save it into db 12 | scan = true 13 | 14 | # the starting block to start to retrieve blocks (only iff scan==true) 15 | scan_start_block = 1 16 | 17 | # store with tx are contained in addr? (bool) 18 | db_store_addr = true 19 | 20 | # store the transactions and receipts? (bool) 21 | db_store_tx = false 22 | 23 | # store internal transactions? (bool) 24 | db_store_itx = false 25 | 26 | # store list of last non empty blocks? (bool) 27 | db_store_neb = true 28 | 29 | # web3 ---------------------------------------------- 30 | web3_url = "http://my.goerli-geth.dnp.dappnode.eth:8545" 31 | 32 | # client type 33 | # "geth_clique" for geth PoS 34 | # "geth_pow" for geth PoW 35 | # "geth" to autodetect geth_clique and geth_pow 36 | web3_client = "geth_clique" 37 | 38 | # process internal txs, true or false 39 | # in geth requieres: 40 | # --syncmode=full 41 | # --gcmode=archive 42 | # --rpcapi debug 43 | web3_itx = false 44 | 45 | # compiler ------------------------------------------ 46 | 47 | # the path where solc binaries are stored (optional) 48 | # solc_path = 49 | solc_bypass = true 50 | 51 | # server -------------------------------------------- 52 | 53 | # http server binding (e.g. "0.0.0.0:8000") 54 | bind = "0.0.0.0:80" 55 | 56 | # names --------------------------------------------- 57 | 58 | # multiple named_address entries can be added to name accouts 59 | #[[named_address]] 60 | #name = 61 | #address = 62 | 63 | [[named_address]] 64 | name="parity" 65 | address="0xe0a2Bd4258D2768837BAa26A28fE71Dc079f84c7" 66 | 67 | [[named_address]] 68 | name="Nethermind" 69 | address="0x4c2ae482593505f0163cdeFc073e81c63CdA4107" 70 | 71 | [[named_address]] 72 | name="POA" 73 | address="0x000000568b9b5A365eaa767d42e74ED88915C204" 74 | 75 | [[named_address]] 76 | name="Dapowerplay" 77 | address="0xA8e8F14732658E4B51E8711931053a8A69BaF2B1" 78 | 79 | [[named_address]] 80 | name="Prysm Labs" 81 | address="0xD9A5179F091d85051d3C982785Efd1455CEc8699" 82 | 83 | [[named_address]] 84 | name="Yucong Sun" 85 | address="0x631AE5c534fE7b35aaF5243b54e5ac0CFc44E04C" 86 | 87 | [[named_address]] 88 | name="Infura" 89 | address="0x8b24Eb4E6aAe906058242D83e51fB077370c4720" 90 | 91 | [[named_address]] 92 | name="Pantheon" 93 | address="0x22eA9f6b28DB76A7162054c05ed812dEb2f519Cd" 94 | 95 | [[named_address]] 96 | name="Ethereum Foundation" 97 | address="0xa6DD2974B96e959F2c8930024451a30aFEC24203 " -------------------------------------------------------------------------------- /extra/dappnode-goerli/dappnode_package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "goerli-tesseracts.public.dappnode.eth", 3 | "version": "0.1.1", 4 | "description": "tesseracts goerli block explorer", 5 | "avatar": "/ipfs/QmP1yNThCymXdKXJd9WUDahrLB6g4hkD567PzgXYJ171Lf", 6 | "type": "service", 7 | "image": { 8 | "restart": "always", 9 | "volumes": [ 10 | "/data" 11 | ], 12 | "keywords": [ 13 | "BlockExplorer", 14 | "Geth" 15 | ], 16 | "path": "goerli-tesseracts.public.dappnode.eth_0.1.1.tar.xz", 17 | "hash": "/ipfs/QmXmrxzudZ2MpS22Ee8usx52VKAvu9TUR6J6qjwPwpF2AD", 18 | "size": 35260000 19 | }, 20 | "author": "@codecontext", 21 | "license": "GPLv3", 22 | "dependencies": { 23 | "goerli-geth.dnp.dappnode.eth": "latest" 24 | } 25 | } -------------------------------------------------------------------------------- /extra/dappnode-goerli/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.4' 2 | services: 3 | goerli-tesseracts.public.dappnode.eth: 4 | image: 'goerli-tesseracts.public.dappnode.eth:0.1.1' 5 | build: ./build 6 | volumes: 7 | - /data 8 | ports: 9 | - '80:80' 10 | -------------------------------------------------------------------------------- /extra/dappnode-goerli/package.sh: -------------------------------------------------------------------------------- 1 | npm i -g @dappnode/dappnodesdk 2 | rm -rf build 3 | mkdir build 4 | rsync -av --progress ../../ build --exclude .git --exclude dappnode --exclude data --exclude target 5 | cp cfg.goerli.toml Dockerfile build 6 | dappnodesdk build 7 | dappnodesdk build 8 | -------------------------------------------------------------------------------- /extra/geth-devnet/config/genesis.json: -------------------------------------------------------------------------------- 1 | { 2 | "config": { 3 | "chainId": 63819, 4 | "homesteadBlock": 1, 5 | "eip150Block": 2, 6 | "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000", 7 | "eip155Block": 3, 8 | "eip158Block": 3, 9 | "byzantiumBlock": 4, 10 | "constantinopleBlock": 5, 11 | "clique": { 12 | "period": 4, 13 | "epoch": 30000 14 | } 15 | }, 16 | "nonce": "0x0", 17 | "timestamp": "0x5cdbbf6d", 18 | "extraData": "0x000000000000000000000000000000000000000000000000000000000000000083a909262608c650bd9b0ae06e29d90d0f67ac5e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 19 | "gasLimit": "0x47b760", 20 | "difficulty": "0x1", 21 | "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 22 | "coinbase": "0x0000000000000000000000000000000000000000", 23 | "alloc": { 24 | "0000000000000000000000000000000000000000": { 25 | "balance": "0x1" 26 | }, 27 | "0000000000000000000000000000000000000001": { 28 | "balance": "0x1" 29 | }, 30 | "0000000000000000000000000000000000000002": { 31 | "balance": "0x1" 32 | }, 33 | "0000000000000000000000000000000000000003": { 34 | "balance": "0x1" 35 | }, 36 | "0000000000000000000000000000000000000004": { 37 | "balance": "0x1" 38 | }, 39 | "0000000000000000000000000000000000000005": { 40 | "balance": "0x1" 41 | }, 42 | "0000000000000000000000000000000000000006": { 43 | "balance": "0x1" 44 | }, 45 | "0000000000000000000000000000000000000007": { 46 | "balance": "0x1" 47 | }, 48 | "0000000000000000000000000000000000000008": { 49 | "balance": "0x1" 50 | }, 51 | "0000000000000000000000000000000000000009": { 52 | "balance": "0x1" 53 | }, 54 | "000000000000000000000000000000000000000a": { 55 | "balance": "0x1" 56 | }, 57 | "000000000000000000000000000000000000000b": { 58 | "balance": "0x1" 59 | }, 60 | "000000000000000000000000000000000000000c": { 61 | "balance": "0x1" 62 | }, 63 | "000000000000000000000000000000000000000d": { 64 | "balance": "0x1" 65 | }, 66 | "000000000000000000000000000000000000000e": { 67 | "balance": "0x1" 68 | }, 69 | "000000000000000000000000000000000000000f": { 70 | "balance": "0x1" 71 | }, 72 | "0000000000000000000000000000000000000010": { 73 | "balance": "0x1" 74 | }, 75 | "0000000000000000000000000000000000000011": { 76 | "balance": "0x1" 77 | }, 78 | "0000000000000000000000000000000000000012": { 79 | "balance": "0x1" 80 | }, 81 | "0000000000000000000000000000000000000013": { 82 | "balance": "0x1" 83 | }, 84 | "0000000000000000000000000000000000000014": { 85 | "balance": "0x1" 86 | }, 87 | "0000000000000000000000000000000000000015": { 88 | "balance": "0x1" 89 | }, 90 | "0000000000000000000000000000000000000016": { 91 | "balance": "0x1" 92 | }, 93 | "0000000000000000000000000000000000000017": { 94 | "balance": "0x1" 95 | }, 96 | "0000000000000000000000000000000000000018": { 97 | "balance": "0x1" 98 | }, 99 | "0000000000000000000000000000000000000019": { 100 | "balance": "0x1" 101 | }, 102 | "000000000000000000000000000000000000001a": { 103 | "balance": "0x1" 104 | }, 105 | "000000000000000000000000000000000000001b": { 106 | "balance": "0x1" 107 | }, 108 | "000000000000000000000000000000000000001c": { 109 | "balance": "0x1" 110 | }, 111 | "000000000000000000000000000000000000001d": { 112 | "balance": "0x1" 113 | }, 114 | "000000000000000000000000000000000000001e": { 115 | "balance": "0x1" 116 | }, 117 | "000000000000000000000000000000000000001f": { 118 | "balance": "0x1" 119 | }, 120 | "0000000000000000000000000000000000000020": { 121 | "balance": "0x1" 122 | }, 123 | "0000000000000000000000000000000000000021": { 124 | "balance": "0x1" 125 | }, 126 | "0000000000000000000000000000000000000022": { 127 | "balance": "0x1" 128 | }, 129 | "0000000000000000000000000000000000000023": { 130 | "balance": "0x1" 131 | }, 132 | "0000000000000000000000000000000000000024": { 133 | "balance": "0x1" 134 | }, 135 | "0000000000000000000000000000000000000025": { 136 | "balance": "0x1" 137 | }, 138 | "0000000000000000000000000000000000000026": { 139 | "balance": "0x1" 140 | }, 141 | "0000000000000000000000000000000000000027": { 142 | "balance": "0x1" 143 | }, 144 | "0000000000000000000000000000000000000028": { 145 | "balance": "0x1" 146 | }, 147 | "0000000000000000000000000000000000000029": { 148 | "balance": "0x1" 149 | }, 150 | "000000000000000000000000000000000000002a": { 151 | "balance": "0x1" 152 | }, 153 | "000000000000000000000000000000000000002b": { 154 | "balance": "0x1" 155 | }, 156 | "000000000000000000000000000000000000002c": { 157 | "balance": "0x1" 158 | }, 159 | "000000000000000000000000000000000000002d": { 160 | "balance": "0x1" 161 | }, 162 | "000000000000000000000000000000000000002e": { 163 | "balance": "0x1" 164 | }, 165 | "000000000000000000000000000000000000002f": { 166 | "balance": "0x1" 167 | }, 168 | "0000000000000000000000000000000000000030": { 169 | "balance": "0x1" 170 | }, 171 | "0000000000000000000000000000000000000031": { 172 | "balance": "0x1" 173 | }, 174 | "0000000000000000000000000000000000000032": { 175 | "balance": "0x1" 176 | }, 177 | "0000000000000000000000000000000000000033": { 178 | "balance": "0x1" 179 | }, 180 | "0000000000000000000000000000000000000034": { 181 | "balance": "0x1" 182 | }, 183 | "0000000000000000000000000000000000000035": { 184 | "balance": "0x1" 185 | }, 186 | "0000000000000000000000000000000000000036": { 187 | "balance": "0x1" 188 | }, 189 | "0000000000000000000000000000000000000037": { 190 | "balance": "0x1" 191 | }, 192 | "0000000000000000000000000000000000000038": { 193 | "balance": "0x1" 194 | }, 195 | "0000000000000000000000000000000000000039": { 196 | "balance": "0x1" 197 | }, 198 | "000000000000000000000000000000000000003a": { 199 | "balance": "0x1" 200 | }, 201 | "000000000000000000000000000000000000003b": { 202 | "balance": "0x1" 203 | }, 204 | "000000000000000000000000000000000000003c": { 205 | "balance": "0x1" 206 | }, 207 | "000000000000000000000000000000000000003d": { 208 | "balance": "0x1" 209 | }, 210 | "000000000000000000000000000000000000003e": { 211 | "balance": "0x1" 212 | }, 213 | "000000000000000000000000000000000000003f": { 214 | "balance": "0x1" 215 | }, 216 | "0000000000000000000000000000000000000040": { 217 | "balance": "0x1" 218 | }, 219 | "0000000000000000000000000000000000000041": { 220 | "balance": "0x1" 221 | }, 222 | "0000000000000000000000000000000000000042": { 223 | "balance": "0x1" 224 | }, 225 | "0000000000000000000000000000000000000043": { 226 | "balance": "0x1" 227 | }, 228 | "0000000000000000000000000000000000000044": { 229 | "balance": "0x1" 230 | }, 231 | "0000000000000000000000000000000000000045": { 232 | "balance": "0x1" 233 | }, 234 | "0000000000000000000000000000000000000046": { 235 | "balance": "0x1" 236 | }, 237 | "0000000000000000000000000000000000000047": { 238 | "balance": "0x1" 239 | }, 240 | "0000000000000000000000000000000000000048": { 241 | "balance": "0x1" 242 | }, 243 | "0000000000000000000000000000000000000049": { 244 | "balance": "0x1" 245 | }, 246 | "000000000000000000000000000000000000004a": { 247 | "balance": "0x1" 248 | }, 249 | "000000000000000000000000000000000000004b": { 250 | "balance": "0x1" 251 | }, 252 | "000000000000000000000000000000000000004c": { 253 | "balance": "0x1" 254 | }, 255 | "000000000000000000000000000000000000004d": { 256 | "balance": "0x1" 257 | }, 258 | "000000000000000000000000000000000000004e": { 259 | "balance": "0x1" 260 | }, 261 | "000000000000000000000000000000000000004f": { 262 | "balance": "0x1" 263 | }, 264 | "0000000000000000000000000000000000000050": { 265 | "balance": "0x1" 266 | }, 267 | "0000000000000000000000000000000000000051": { 268 | "balance": "0x1" 269 | }, 270 | "0000000000000000000000000000000000000052": { 271 | "balance": "0x1" 272 | }, 273 | "0000000000000000000000000000000000000053": { 274 | "balance": "0x1" 275 | }, 276 | "0000000000000000000000000000000000000054": { 277 | "balance": "0x1" 278 | }, 279 | "0000000000000000000000000000000000000055": { 280 | "balance": "0x1" 281 | }, 282 | "0000000000000000000000000000000000000056": { 283 | "balance": "0x1" 284 | }, 285 | "0000000000000000000000000000000000000057": { 286 | "balance": "0x1" 287 | }, 288 | "0000000000000000000000000000000000000058": { 289 | "balance": "0x1" 290 | }, 291 | "0000000000000000000000000000000000000059": { 292 | "balance": "0x1" 293 | }, 294 | "000000000000000000000000000000000000005a": { 295 | "balance": "0x1" 296 | }, 297 | "000000000000000000000000000000000000005b": { 298 | "balance": "0x1" 299 | }, 300 | "000000000000000000000000000000000000005c": { 301 | "balance": "0x1" 302 | }, 303 | "000000000000000000000000000000000000005d": { 304 | "balance": "0x1" 305 | }, 306 | "000000000000000000000000000000000000005e": { 307 | "balance": "0x1" 308 | }, 309 | "000000000000000000000000000000000000005f": { 310 | "balance": "0x1" 311 | }, 312 | "0000000000000000000000000000000000000060": { 313 | "balance": "0x1" 314 | }, 315 | "0000000000000000000000000000000000000061": { 316 | "balance": "0x1" 317 | }, 318 | "0000000000000000000000000000000000000062": { 319 | "balance": "0x1" 320 | }, 321 | "0000000000000000000000000000000000000063": { 322 | "balance": "0x1" 323 | }, 324 | "0000000000000000000000000000000000000064": { 325 | "balance": "0x1" 326 | }, 327 | "0000000000000000000000000000000000000065": { 328 | "balance": "0x1" 329 | }, 330 | "0000000000000000000000000000000000000066": { 331 | "balance": "0x1" 332 | }, 333 | "0000000000000000000000000000000000000067": { 334 | "balance": "0x1" 335 | }, 336 | "0000000000000000000000000000000000000068": { 337 | "balance": "0x1" 338 | }, 339 | "0000000000000000000000000000000000000069": { 340 | "balance": "0x1" 341 | }, 342 | "000000000000000000000000000000000000006a": { 343 | "balance": "0x1" 344 | }, 345 | "000000000000000000000000000000000000006b": { 346 | "balance": "0x1" 347 | }, 348 | "000000000000000000000000000000000000006c": { 349 | "balance": "0x1" 350 | }, 351 | "000000000000000000000000000000000000006d": { 352 | "balance": "0x1" 353 | }, 354 | "000000000000000000000000000000000000006e": { 355 | "balance": "0x1" 356 | }, 357 | "000000000000000000000000000000000000006f": { 358 | "balance": "0x1" 359 | }, 360 | "0000000000000000000000000000000000000070": { 361 | "balance": "0x1" 362 | }, 363 | "0000000000000000000000000000000000000071": { 364 | "balance": "0x1" 365 | }, 366 | "0000000000000000000000000000000000000072": { 367 | "balance": "0x1" 368 | }, 369 | "0000000000000000000000000000000000000073": { 370 | "balance": "0x1" 371 | }, 372 | "0000000000000000000000000000000000000074": { 373 | "balance": "0x1" 374 | }, 375 | "0000000000000000000000000000000000000075": { 376 | "balance": "0x1" 377 | }, 378 | "0000000000000000000000000000000000000076": { 379 | "balance": "0x1" 380 | }, 381 | "0000000000000000000000000000000000000077": { 382 | "balance": "0x1" 383 | }, 384 | "0000000000000000000000000000000000000078": { 385 | "balance": "0x1" 386 | }, 387 | "0000000000000000000000000000000000000079": { 388 | "balance": "0x1" 389 | }, 390 | "000000000000000000000000000000000000007a": { 391 | "balance": "0x1" 392 | }, 393 | "000000000000000000000000000000000000007b": { 394 | "balance": "0x1" 395 | }, 396 | "000000000000000000000000000000000000007c": { 397 | "balance": "0x1" 398 | }, 399 | "000000000000000000000000000000000000007d": { 400 | "balance": "0x1" 401 | }, 402 | "000000000000000000000000000000000000007e": { 403 | "balance": "0x1" 404 | }, 405 | "000000000000000000000000000000000000007f": { 406 | "balance": "0x1" 407 | }, 408 | "0000000000000000000000000000000000000080": { 409 | "balance": "0x1" 410 | }, 411 | "0000000000000000000000000000000000000081": { 412 | "balance": "0x1" 413 | }, 414 | "0000000000000000000000000000000000000082": { 415 | "balance": "0x1" 416 | }, 417 | "0000000000000000000000000000000000000083": { 418 | "balance": "0x1" 419 | }, 420 | "0000000000000000000000000000000000000084": { 421 | "balance": "0x1" 422 | }, 423 | "0000000000000000000000000000000000000085": { 424 | "balance": "0x1" 425 | }, 426 | "0000000000000000000000000000000000000086": { 427 | "balance": "0x1" 428 | }, 429 | "0000000000000000000000000000000000000087": { 430 | "balance": "0x1" 431 | }, 432 | "0000000000000000000000000000000000000088": { 433 | "balance": "0x1" 434 | }, 435 | "0000000000000000000000000000000000000089": { 436 | "balance": "0x1" 437 | }, 438 | "000000000000000000000000000000000000008a": { 439 | "balance": "0x1" 440 | }, 441 | "000000000000000000000000000000000000008b": { 442 | "balance": "0x1" 443 | }, 444 | "000000000000000000000000000000000000008c": { 445 | "balance": "0x1" 446 | }, 447 | "000000000000000000000000000000000000008d": { 448 | "balance": "0x1" 449 | }, 450 | "000000000000000000000000000000000000008e": { 451 | "balance": "0x1" 452 | }, 453 | "000000000000000000000000000000000000008f": { 454 | "balance": "0x1" 455 | }, 456 | "0000000000000000000000000000000000000090": { 457 | "balance": "0x1" 458 | }, 459 | "0000000000000000000000000000000000000091": { 460 | "balance": "0x1" 461 | }, 462 | "0000000000000000000000000000000000000092": { 463 | "balance": "0x1" 464 | }, 465 | "0000000000000000000000000000000000000093": { 466 | "balance": "0x1" 467 | }, 468 | "0000000000000000000000000000000000000094": { 469 | "balance": "0x1" 470 | }, 471 | "0000000000000000000000000000000000000095": { 472 | "balance": "0x1" 473 | }, 474 | "0000000000000000000000000000000000000096": { 475 | "balance": "0x1" 476 | }, 477 | "0000000000000000000000000000000000000097": { 478 | "balance": "0x1" 479 | }, 480 | "0000000000000000000000000000000000000098": { 481 | "balance": "0x1" 482 | }, 483 | "0000000000000000000000000000000000000099": { 484 | "balance": "0x1" 485 | }, 486 | "000000000000000000000000000000000000009a": { 487 | "balance": "0x1" 488 | }, 489 | "000000000000000000000000000000000000009b": { 490 | "balance": "0x1" 491 | }, 492 | "000000000000000000000000000000000000009c": { 493 | "balance": "0x1" 494 | }, 495 | "000000000000000000000000000000000000009d": { 496 | "balance": "0x1" 497 | }, 498 | "000000000000000000000000000000000000009e": { 499 | "balance": "0x1" 500 | }, 501 | "000000000000000000000000000000000000009f": { 502 | "balance": "0x1" 503 | }, 504 | "00000000000000000000000000000000000000a0": { 505 | "balance": "0x1" 506 | }, 507 | "00000000000000000000000000000000000000a1": { 508 | "balance": "0x1" 509 | }, 510 | "00000000000000000000000000000000000000a2": { 511 | "balance": "0x1" 512 | }, 513 | "00000000000000000000000000000000000000a3": { 514 | "balance": "0x1" 515 | }, 516 | "00000000000000000000000000000000000000a4": { 517 | "balance": "0x1" 518 | }, 519 | "00000000000000000000000000000000000000a5": { 520 | "balance": "0x1" 521 | }, 522 | "00000000000000000000000000000000000000a6": { 523 | "balance": "0x1" 524 | }, 525 | "00000000000000000000000000000000000000a7": { 526 | "balance": "0x1" 527 | }, 528 | "00000000000000000000000000000000000000a8": { 529 | "balance": "0x1" 530 | }, 531 | "00000000000000000000000000000000000000a9": { 532 | "balance": "0x1" 533 | }, 534 | "00000000000000000000000000000000000000aa": { 535 | "balance": "0x1" 536 | }, 537 | "00000000000000000000000000000000000000ab": { 538 | "balance": "0x1" 539 | }, 540 | "00000000000000000000000000000000000000ac": { 541 | "balance": "0x1" 542 | }, 543 | "00000000000000000000000000000000000000ad": { 544 | "balance": "0x1" 545 | }, 546 | "00000000000000000000000000000000000000ae": { 547 | "balance": "0x1" 548 | }, 549 | "00000000000000000000000000000000000000af": { 550 | "balance": "0x1" 551 | }, 552 | "00000000000000000000000000000000000000b0": { 553 | "balance": "0x1" 554 | }, 555 | "00000000000000000000000000000000000000b1": { 556 | "balance": "0x1" 557 | }, 558 | "00000000000000000000000000000000000000b2": { 559 | "balance": "0x1" 560 | }, 561 | "00000000000000000000000000000000000000b3": { 562 | "balance": "0x1" 563 | }, 564 | "00000000000000000000000000000000000000b4": { 565 | "balance": "0x1" 566 | }, 567 | "00000000000000000000000000000000000000b5": { 568 | "balance": "0x1" 569 | }, 570 | "00000000000000000000000000000000000000b6": { 571 | "balance": "0x1" 572 | }, 573 | "00000000000000000000000000000000000000b7": { 574 | "balance": "0x1" 575 | }, 576 | "00000000000000000000000000000000000000b8": { 577 | "balance": "0x1" 578 | }, 579 | "00000000000000000000000000000000000000b9": { 580 | "balance": "0x1" 581 | }, 582 | "00000000000000000000000000000000000000ba": { 583 | "balance": "0x1" 584 | }, 585 | "00000000000000000000000000000000000000bb": { 586 | "balance": "0x1" 587 | }, 588 | "00000000000000000000000000000000000000bc": { 589 | "balance": "0x1" 590 | }, 591 | "00000000000000000000000000000000000000bd": { 592 | "balance": "0x1" 593 | }, 594 | "00000000000000000000000000000000000000be": { 595 | "balance": "0x1" 596 | }, 597 | "00000000000000000000000000000000000000bf": { 598 | "balance": "0x1" 599 | }, 600 | "00000000000000000000000000000000000000c0": { 601 | "balance": "0x1" 602 | }, 603 | "00000000000000000000000000000000000000c1": { 604 | "balance": "0x1" 605 | }, 606 | "00000000000000000000000000000000000000c2": { 607 | "balance": "0x1" 608 | }, 609 | "00000000000000000000000000000000000000c3": { 610 | "balance": "0x1" 611 | }, 612 | "00000000000000000000000000000000000000c4": { 613 | "balance": "0x1" 614 | }, 615 | "00000000000000000000000000000000000000c5": { 616 | "balance": "0x1" 617 | }, 618 | "00000000000000000000000000000000000000c6": { 619 | "balance": "0x1" 620 | }, 621 | "00000000000000000000000000000000000000c7": { 622 | "balance": "0x1" 623 | }, 624 | "00000000000000000000000000000000000000c8": { 625 | "balance": "0x1" 626 | }, 627 | "00000000000000000000000000000000000000c9": { 628 | "balance": "0x1" 629 | }, 630 | "00000000000000000000000000000000000000ca": { 631 | "balance": "0x1" 632 | }, 633 | "00000000000000000000000000000000000000cb": { 634 | "balance": "0x1" 635 | }, 636 | "00000000000000000000000000000000000000cc": { 637 | "balance": "0x1" 638 | }, 639 | "00000000000000000000000000000000000000cd": { 640 | "balance": "0x1" 641 | }, 642 | "00000000000000000000000000000000000000ce": { 643 | "balance": "0x1" 644 | }, 645 | "00000000000000000000000000000000000000cf": { 646 | "balance": "0x1" 647 | }, 648 | "00000000000000000000000000000000000000d0": { 649 | "balance": "0x1" 650 | }, 651 | "00000000000000000000000000000000000000d1": { 652 | "balance": "0x1" 653 | }, 654 | "00000000000000000000000000000000000000d2": { 655 | "balance": "0x1" 656 | }, 657 | "00000000000000000000000000000000000000d3": { 658 | "balance": "0x1" 659 | }, 660 | "00000000000000000000000000000000000000d4": { 661 | "balance": "0x1" 662 | }, 663 | "00000000000000000000000000000000000000d5": { 664 | "balance": "0x1" 665 | }, 666 | "00000000000000000000000000000000000000d6": { 667 | "balance": "0x1" 668 | }, 669 | "00000000000000000000000000000000000000d7": { 670 | "balance": "0x1" 671 | }, 672 | "00000000000000000000000000000000000000d8": { 673 | "balance": "0x1" 674 | }, 675 | "00000000000000000000000000000000000000d9": { 676 | "balance": "0x1" 677 | }, 678 | "00000000000000000000000000000000000000da": { 679 | "balance": "0x1" 680 | }, 681 | "00000000000000000000000000000000000000db": { 682 | "balance": "0x1" 683 | }, 684 | "00000000000000000000000000000000000000dc": { 685 | "balance": "0x1" 686 | }, 687 | "00000000000000000000000000000000000000dd": { 688 | "balance": "0x1" 689 | }, 690 | "00000000000000000000000000000000000000de": { 691 | "balance": "0x1" 692 | }, 693 | "00000000000000000000000000000000000000df": { 694 | "balance": "0x1" 695 | }, 696 | "00000000000000000000000000000000000000e0": { 697 | "balance": "0x1" 698 | }, 699 | "00000000000000000000000000000000000000e1": { 700 | "balance": "0x1" 701 | }, 702 | "00000000000000000000000000000000000000e2": { 703 | "balance": "0x1" 704 | }, 705 | "00000000000000000000000000000000000000e3": { 706 | "balance": "0x1" 707 | }, 708 | "00000000000000000000000000000000000000e4": { 709 | "balance": "0x1" 710 | }, 711 | "00000000000000000000000000000000000000e5": { 712 | "balance": "0x1" 713 | }, 714 | "00000000000000000000000000000000000000e6": { 715 | "balance": "0x1" 716 | }, 717 | "00000000000000000000000000000000000000e7": { 718 | "balance": "0x1" 719 | }, 720 | "00000000000000000000000000000000000000e8": { 721 | "balance": "0x1" 722 | }, 723 | "00000000000000000000000000000000000000e9": { 724 | "balance": "0x1" 725 | }, 726 | "00000000000000000000000000000000000000ea": { 727 | "balance": "0x1" 728 | }, 729 | "00000000000000000000000000000000000000eb": { 730 | "balance": "0x1" 731 | }, 732 | "00000000000000000000000000000000000000ec": { 733 | "balance": "0x1" 734 | }, 735 | "00000000000000000000000000000000000000ed": { 736 | "balance": "0x1" 737 | }, 738 | "00000000000000000000000000000000000000ee": { 739 | "balance": "0x1" 740 | }, 741 | "00000000000000000000000000000000000000ef": { 742 | "balance": "0x1" 743 | }, 744 | "00000000000000000000000000000000000000f0": { 745 | "balance": "0x1" 746 | }, 747 | "00000000000000000000000000000000000000f1": { 748 | "balance": "0x1" 749 | }, 750 | "00000000000000000000000000000000000000f2": { 751 | "balance": "0x1" 752 | }, 753 | "00000000000000000000000000000000000000f3": { 754 | "balance": "0x1" 755 | }, 756 | "00000000000000000000000000000000000000f4": { 757 | "balance": "0x1" 758 | }, 759 | "00000000000000000000000000000000000000f5": { 760 | "balance": "0x1" 761 | }, 762 | "00000000000000000000000000000000000000f6": { 763 | "balance": "0x1" 764 | }, 765 | "00000000000000000000000000000000000000f7": { 766 | "balance": "0x1" 767 | }, 768 | "00000000000000000000000000000000000000f8": { 769 | "balance": "0x1" 770 | }, 771 | "00000000000000000000000000000000000000f9": { 772 | "balance": "0x1" 773 | }, 774 | "00000000000000000000000000000000000000fa": { 775 | "balance": "0x1" 776 | }, 777 | "00000000000000000000000000000000000000fb": { 778 | "balance": "0x1" 779 | }, 780 | "00000000000000000000000000000000000000fc": { 781 | "balance": "0x1" 782 | }, 783 | "00000000000000000000000000000000000000fd": { 784 | "balance": "0x1" 785 | }, 786 | "00000000000000000000000000000000000000fe": { 787 | "balance": "0x1" 788 | }, 789 | "00000000000000000000000000000000000000ff": { 790 | "balance": "0x1" 791 | }, 792 | "83a909262608c650bd9b0ae06e29d90d0f67ac5e": { 793 | "balance": "0x200000000000000000000000000000000000000000000000000000000000000" 794 | } 795 | }, 796 | "number": "0x0", 797 | "gasUsed": "0x0", 798 | "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000" 799 | } -------------------------------------------------------------------------------- /extra/geth-devnet/config/keystore/UTC--2019-05-15T07-25-50.175906751Z--83a909262608c650bd9b0ae06e29d90d0f67ac5e: -------------------------------------------------------------------------------- 1 | {"address":"83a909262608c650bd9b0ae06e29d90d0f67ac5e","crypto":{"cipher":"aes-128-ctr","ciphertext":"cd1c33b8fb58696529a4be99465172aee622d80ab1a743f507cd6d66c69331cd","cipherparams":{"iv":"9257c6c46628ff0512ec9d7b01158a16"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"32174b69df8f04656163c0bf9d06d48083ed8c26c9c1f3fcebb8b7e3041e5e9d"},"mac":"2363e05ec5588934f0a15ec5e87bb07abe7314548bbb61f62a12a18c50830f31"},"id":"da5aac09-9b70-4935-9682-72b34213c0da","version":3} -------------------------------------------------------------------------------- /extra/geth-devnet/config/passwd: -------------------------------------------------------------------------------- 1 | 111111 2 | -------------------------------------------------------------------------------- /extra/geth-devnet/config/tesseracts.toml: -------------------------------------------------------------------------------- 1 | # user iterface ----------------------------------- 2 | 3 | # title of the page, e.g. "tesseracts" 4 | ui_title = "testnet" 5 | 6 | # database ---------------------------------------- 7 | 8 | # where the database is located 9 | db_path = "/data/tesseracts" 10 | 11 | # true|false if we want to scan blocks and save it into db 12 | scan = true 13 | 14 | # the starting block to start to retrieve blocks (only iff scan==true) 15 | scan_start_block = 1 16 | 17 | # store with tx are contained in addr? (bool) 18 | db_store_addr = true 19 | 20 | # store the transactions and receipts? (bool) 21 | db_store_tx = false 22 | 23 | # store internal transactions? (bool) 24 | db_store_itx = true 25 | 26 | # store list of last non empty blocks? (bool) 27 | db_store_neb = true 28 | 29 | # web3 ---------------------------------------------- 30 | 31 | # web3 json-rpc port, e.g. http://localhost:8545 32 | web3_url = "http://geth:8545" 33 | 34 | # client type 35 | # "geth_clique" for geth PoS 36 | # "geth_pow" for geth PoW 37 | # "geth" to autodetect geth_clique and geth_pow 38 | web3_client = "geth" 39 | 40 | # process internal txs, true or false 41 | # in geth requieres: 42 | # --syncmode=full 43 | # --gcmode=archive 44 | # --rpcapi debug 45 | web3_itx = true 46 | 47 | # compiler ------------------------------------------ 48 | 49 | # the path where solc binaries are stored (optional) 50 | #solc_path = 51 | 52 | # solidity compiler can be bypassedi, by specifing the abi 53 | solc_bypass = true 54 | 55 | # server -------------------------------------------- 56 | 57 | # http server binding (e.g. "0.0.0.0:8000") 58 | bind = "0.0.0.0:8000" 59 | 60 | 61 | -------------------------------------------------------------------------------- /extra/geth-devnet/start.sh: -------------------------------------------------------------------------------- 1 | GETH_DOCKER_PARAMS="-v `pwd`/config:/config -v `pwd`/data:/data -p 8545:8545 -t ethereum/client-go:alltools-v1.8.27" 2 | 3 | if [ ! "$(docker ps -q -f name=geth)" ]; then 4 | echo [geth] Container does not exist 5 | if [ "$(docker ps -aq -f status=exited -f name=geth)" ]; then 6 | echo [geth] Found old one, cleaning up 7 | docker rm geth 8 | fi 9 | 10 | echo [geth] Starting new container... 11 | docker run $GETH_DOCKER_PARAMS geth --datadir data init config/genesis.json 12 | docker run -d --name geth $GETH_DOCKER_PARAMS geth --datadir data --mine --unlock 0x83a909262608c650bd9b0ae06e29d90d0f67ac5e --password config/passwd --keystore config/keystore --datadir data/ --rpc --rpcapi 'personal,db,eth,net,web3,txpool,miner,debug' --rpcvhosts '*' --rpccorsdomain '*' --rpcaddr '0.0.0.0' --networkid 63819 --syncmode=full --gcmode=archive --nodiscover 13 | else 14 | echo [geth] Container exists, starting... 15 | docker start geth 16 | fi 17 | 18 | echo [script] waiting 10 seconds... 19 | sleep 10 20 | 21 | if [ ! "$(docker ps -q -f name=tesseracts)" ]; then 22 | echo [tesseracts] Container does not exist 23 | if [ "$(docker ps -aq -f status=exited -f name=tesseracts)" ]; then 24 | echo [tesseracts] Found old one, cleaning up 25 | docker rm tesseracts 26 | fi 27 | 28 | echo [geth] Starting new container... 29 | docker run -d --name tesseracts --link geth -v `pwd`/config:/config -v `pwd`/data:/data -p 8000:8000 -t adriamb/tesseracts:v0.4 -vvv --cfg /config/tesseracts.toml 30 | else 31 | echo [geth] Container exists, starting... 32 | docker start tesseracts 33 | fi 34 | 35 | -------------------------------------------------------------------------------- /extra/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adria0/tesseracts/cba0221ddd4e089a4627ca23ea9550bb16827293/extra/screenshot.png -------------------------------------------------------------------------------- /extra/test.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.0; 2 | 3 | contract Inner { 4 | event InnerEvent(uint256); 5 | 6 | function docall(uint256 foo) external { 7 | emit InnerEvent(foo); 8 | } 9 | } 10 | 11 | contract Outer { 12 | 13 | event OuterEvent(string); 14 | Inner inner; 15 | 16 | constructor() public { 17 | emit OuterEvent("constructor"); 18 | } 19 | function create() external { 20 | inner = new Inner(); 21 | } 22 | function docall() external { 23 | inner.docall(11); 24 | emit OuterEvent("called"); 25 | } 26 | } -------------------------------------------------------------------------------- /src/bootstrap/config.rs: -------------------------------------------------------------------------------- 1 | use std::fs::File; 2 | use std::io::prelude::*; 3 | 4 | use super::error::{Error,Result}; 5 | 6 | /// allowed parameters for web3_client 7 | pub const GETH_CLIQUE : & str = "geth_clique"; 8 | pub const GETH_POW : & str = "geth_pow"; 9 | pub const GETH_AUTO : & str = "geth"; 10 | 11 | #[derive(Debug, Deserialize)] 12 | pub struct NamedAddress { 13 | pub address: String, 14 | pub name: String, 15 | } 16 | 17 | #[derive(Deserialize, Debug)] 18 | pub struct Config { 19 | /// the main page title 20 | pub ui_title: String, 21 | 22 | /// database location path 23 | pub db_path: String, 24 | 25 | /// flag to store internal transactions 26 | pub db_store_itx : bool, 27 | 28 | /// flag to store transaction 29 | pub db_store_tx : bool, 30 | 31 | /// flag to store addresses in txs 32 | pub db_store_addr : bool, 33 | 34 | /// flag to store non-empty blocks 35 | pub db_store_neb : bool, 36 | 37 | /// flag to store non-empty blocks 38 | pub web3_url: String, 39 | 40 | /// web3 client to use 41 | pub web3_client: String, 42 | 43 | /// flag is web3 is able to get internal transactions 44 | pub web3_itx: bool, 45 | 46 | /// flag to scan transactions 47 | pub scan: bool, 48 | 49 | /// when scan is true, the first block to scan 50 | pub scan_start_block: Option, 51 | 52 | /// network ip:port binding 53 | pub bind: String, 54 | 55 | /// path of solc (optional) 56 | pub solc_path : Option, 57 | 58 | /// allow abi when adding contracts 59 | pub solc_bypass : bool, 60 | 61 | /// set of named addresses 62 | pub named_address : Option>, 63 | } 64 | 65 | impl Config { 66 | /// read the .toml configutation 67 | pub fn read(path: &str) -> Result { 68 | 69 | // read the contents 70 | let mut contents = String::new(); 71 | File::open(path)?.read_to_string(&mut contents)?; 72 | 73 | // parse and check parameters 74 | let cfg : Config = toml::from_str(&contents)?; 75 | if cfg.web3_client != GETH_CLIQUE 76 | && cfg.web3_client != GETH_POW 77 | && cfg.web3_client != GETH_AUTO { 78 | Err(Error::InvalidOption(format!("only {} allowed in web3_client",GETH_CLIQUE))) 79 | } else { 80 | Ok(cfg) 81 | } 82 | } 83 | } 84 | 85 | -------------------------------------------------------------------------------- /src/bootstrap/error.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug)] 2 | pub enum Error { 3 | InvalidOption(String), 4 | Io(std::io::Error), 5 | Toml(toml::de::Error), 6 | } 7 | 8 | impl From for Error { 9 | fn from(err: std::io::Error) -> Self { 10 | Error::Io(err) 11 | } 12 | } 13 | 14 | impl From for Error { 15 | fn from(err: toml::de::Error) -> Self { 16 | Error::Toml(err) 17 | } 18 | } 19 | 20 | pub type Result = std::result::Result; 21 | -------------------------------------------------------------------------------- /src/bootstrap/mod.rs: -------------------------------------------------------------------------------- 1 | mod staticres; 2 | mod config; 3 | mod error; 4 | 5 | pub use self::error::{Error,Result}; 6 | pub use self::staticres::{load_handlebars_templates,get_resource}; 7 | pub use self::config::{Config,GETH_CLIQUE,GETH_POW,GETH_AUTO}; 8 | -------------------------------------------------------------------------------- /src/bootstrap/staticres.rs: -------------------------------------------------------------------------------- 1 | #[derive(RustEmbed)] 2 | #[folder = "static/tmpl"] 3 | struct Templates; 4 | 5 | #[derive(RustEmbed)] 6 | #[folder = "static/web"] 7 | struct WebResources; 8 | 9 | use handlebars::Handlebars; 10 | 11 | /// load html templates 12 | pub fn load_handlebars_templates(hb: &mut Handlebars) { 13 | 14 | for asset in Templates::iter() { 15 | 16 | let file = asset.into_owned(); 17 | let tmpl = String::from_utf8( 18 | Templates::get(file.as_str()) 19 | .unwrap_or_else(|| panic!("Unable to read file {}", file)) 20 | .to_vec(), 21 | ) 22 | .unwrap_or_else(|_| panic!("Unable to decode file {}", file)); 23 | 24 | hb.register_template_string(file.as_str(), &tmpl) 25 | .unwrap_or_else(|_| panic!("Invalid template {}", file)); 26 | } 27 | } 28 | 29 | /// get www resource file 30 | pub fn get_resource(name : &str) -> std::option::Option> { 31 | WebResources::get(name) 32 | } -------------------------------------------------------------------------------- /src/db/appdb.rs: -------------------------------------------------------------------------------- 1 | use rocksdb::{Direction, IteratorMode, DB}; 2 | use serde_cbor::{from_slice, to_vec}; 3 | use web3::types::{Address, Block, Transaction, TransactionReceipt, H256}; 4 | use rustc_hex::ToHex; 5 | 6 | use super::error::*; 7 | use super::types::*; 8 | use super::utils::*; 9 | use super::iterators::*; 10 | 11 | use super::super::eth::types::InternalTx; 12 | 13 | pub struct Options { 14 | pub store_itx : bool, 15 | pub store_tx : bool, 16 | pub store_addr : bool, 17 | pub store_neb : bool, 18 | } 19 | 20 | pub struct AppDB { 21 | db: DB, 22 | opt: Options, 23 | } 24 | 25 | /* 26 | 27 | Internal structure of the database 28 | ---------------------------------- 29 | Tx cbor-encoded-transactionwithreceipt 30 | IntTx cbor-encoded-{from,to,value,data} 31 | Receipt cbor-encoded-receipt 32 | AddrLink TxNewContract(contract_addr) 33 | TxTo(to_addr) 34 | TxFromTo() 35 | TxFrom(from_addr) 36 | AddrLinkCount u64 37 | Block cbor-encoded-block 38 | ContractAbi cbor-encoded abi and compile params 39 | NonEmptyBlock none 40 | NonEmptyBlockCount u64 41 | NextBlock u64 42 | 43 | if *inttx == 0 means a main transaction 44 | else means an internal transaction num n 45 | 46 | We need the following proprties: 47 | 48 | 1) Can be updated in paralel 49 | 2) Data cannot be manipulated 50 | 51 | inttx is the internal transaction count 52 | 53 | */ 54 | 55 | impl AppDB { 56 | 57 | /// open the datase 58 | pub fn open_default(path: &str, opt: Options) -> Result { 59 | Ok(DB::open_default(path).map(|x| AppDB{ opt, db: x })?) 60 | } 61 | 62 | /// add an address that has some relationship with a tx 63 | pub fn add_addrtx_link(&self, addr: &Address, tx: &Transaction, inttxno : u64) -> Result<()> { 64 | 65 | // construct the key 66 | 67 | let revblockno = u64_to_le(std::u64::MAX - tx.block_number.unwrap().low_u64()); 68 | let revtxindex = u64_to_le(std::u64::MAX - tx.block_number.unwrap().low_u64()); 69 | let revinttx = u64_to_le(std::u64::MAX - inttxno); 70 | 71 | let mut key: Vec = vec![RecordType::TxLink as u8]; 72 | key.extend_from_slice(&addr); 73 | key.extend_from_slice(&revblockno); 74 | key.extend_from_slice(&revtxindex); 75 | key.extend_from_slice(&tx.hash); 76 | key.extend_from_slice(&revinttx); 77 | 78 | // add the link 79 | let zero : Vec = vec![]; 80 | self.db.put(&key.to_owned(), &zero)?; 81 | 82 | // increment the number of links for this address 83 | self.inc_addr_tx_links(&addr)?; 84 | 85 | Ok(()) 86 | } 87 | 88 | /// add all links from a transaction to an address 89 | fn add_addrtx_links(&self, tx: &Transaction, from: Address, to:Option
, contract:Option
, int_tx_no : u64 ) -> Result<()> { 90 | 91 | // check preconditon 92 | if contract.is_none() && to.is_none() { 93 | unreachable!("broken add_addrtx_links precondition") 94 | } 95 | 96 | // add the related links 97 | if let Some(contract) = contract { 98 | self.add_addrtx_link(&from,&tx,int_tx_no)?; 99 | self.add_addrtx_link(&contract,&tx,int_tx_no)?; 100 | } else { 101 | let to = to.unwrap(); 102 | if from == to { 103 | self.add_addrtx_link(&from,&tx,int_tx_no)?; 104 | } else { 105 | self.add_addrtx_link(&from,&tx,int_tx_no)?; 106 | self.add_addrtx_link(&to,&tx,int_tx_no)?; 107 | } 108 | } 109 | Ok(()) 110 | } 111 | 112 | /// add an internal transaction 113 | fn add_itx(&self, tx: &Transaction, itx: &InternalTx, itx_no: u64) -> Result<()> { 114 | 115 | // store the internal transaction 116 | let mut itx_k = vec![RecordType::IntTx as u8]; 117 | let rev_itx_no = u64_to_le(std::u64::MAX - itx_no); 118 | itx_k.extend_from_slice(&tx.hash); 119 | itx_k.extend_from_slice(&rev_itx_no); 120 | 121 | self.db 122 | .put(itx_k.as_slice(), to_vec(itx).unwrap().as_slice())?; 123 | 124 | // store its addresslinks 125 | self.add_addrtx_links(&tx,itx.from, itx.to, itx.contract,itx_no)?; 126 | 127 | Ok(()) 128 | } 129 | 130 | pub fn add_tx(&self, tx: &Transaction, tr: &TransactionReceipt, itxs : Option<&[InternalTx]>) -> Result<()> { 131 | 132 | // check preconditon 133 | if tx.to.is_none() && tr.contract_address.is_none() { 134 | unreachable!("broken add_tx precondition") 135 | } 136 | 137 | // only store tx if config flag is set 138 | if self.opt.store_tx { 139 | 140 | // store tx 141 | let mut tx_k = vec![RecordType::Tx as u8]; 142 | tx_k.extend_from_slice(&tx.hash); 143 | self.db 144 | .put(tx_k.as_slice(), to_vec(tx).unwrap().as_slice())?; 145 | 146 | // store receipt 147 | let mut r_k = vec![RecordType::Receipt as u8]; 148 | r_k.extend_from_slice(&tx.hash); 149 | self.db.put(r_k.as_slice(), to_vec(tr).unwrap().as_slice())?; 150 | 151 | // store internal transactions 152 | if self.opt.store_itx { 153 | if let Some(itxs) = itxs { 154 | for (i, itx) in itxs.into_iter().enumerate() { 155 | self.add_itx(&tx,itx,i as u64 + 1)?; 156 | } 157 | } 158 | } 159 | } 160 | 161 | // only store address links if config flag is set 162 | if self.opt.store_addr { 163 | // TxLinks 164 | self.add_addrtx_links(&tx,tx.from,tx.to,tr.contract_address,0)?; 165 | } 166 | 167 | Ok(()) 168 | } 169 | 170 | /// get a transaction 171 | pub fn get_tx(&self, txhash: &H256) -> Result> { 172 | let mut tx_k = vec![RecordType::Tx as u8]; 173 | tx_k.extend_from_slice(&txhash); 174 | 175 | match self.db.get(&tx_k)? { 176 | None => Ok(None), 177 | Some(v) => Ok(Some(from_slice::(&v)?)) 178 | } 179 | } 180 | 181 | /// get an internal transaction 182 | pub fn get_itx(&self, txhash: &H256, itx_no: u64) -> Result> { 183 | let mut itx_k = vec![RecordType::IntTx as u8]; 184 | let rev_itx_no = u64_to_le(std::u64::MAX - itx_no); 185 | itx_k.extend_from_slice(&txhash); 186 | itx_k.extend_from_slice(&rev_itx_no); 187 | 188 | match self.db.get(&itx_k)? { 189 | None => Ok(None), 190 | Some(v) => Ok(Some(from_slice::(&v)?)) 191 | } 192 | } 193 | 194 | /// get a receipt 195 | pub fn get_receipt(&self, txhash: &H256) -> Result> { 196 | let mut rcpt_k = vec![RecordType::Receipt as u8]; 197 | rcpt_k.extend_from_slice(&txhash); 198 | 199 | match self.db.get(&rcpt_k)? { 200 | None => Ok(None), 201 | Some(v) => Ok(Some(from_slice::(&v)?)) 202 | } 203 | } 204 | 205 | /// add a new block 206 | pub fn add_block(&self, block: &Block) -> Result<()> { 207 | 208 | if self.opt.store_tx { 209 | // add the block 210 | let mut b_k = vec![RecordType::Block as u8]; 211 | let block_no = u64_to_le(block.number.unwrap().low_u64()); 212 | b_k.extend_from_slice(&block_no); 213 | 214 | self.db.put(b_k.as_slice(), to_vec(block)?.as_slice())?; 215 | } 216 | 217 | if self.opt.store_neb && !block.transactions.is_empty() { 218 | // annotate a non-empty-block 219 | let mut neb_k = vec![RecordType::NonEmptyBlock as u8]; 220 | let block_no_rev = u64_to_le(std::u64::MAX - block.number.unwrap().low_u64()); 221 | neb_k.extend_from_slice(&block_no_rev); 222 | self.db.put(neb_k.as_slice(), &[])?; 223 | 224 | // increment counter of non-empty-blocks 225 | self.inc_u64(&[RecordType::NonEmptyBlockCount as u8])?; 226 | } 227 | Ok(()) 228 | } 229 | 230 | /// create an iterator on internal transactions 231 | pub fn iter_itxs(&self, txhash: &H256) -> InternalTxs { 232 | let mut key = vec![RecordType::IntTx as u8]; 233 | key.extend_from_slice(&txhash); 234 | let iter = self 235 | .db 236 | .iterator(IteratorMode::From(&key, Direction::Forward)); 237 | 238 | InternalTxs::new(iter, key) 239 | } 240 | 241 | /// number of internal transactions 242 | pub fn _count_itxs(&self, txhash: &H256) -> u64 { 243 | match self.iter_itxs(txhash).next() { 244 | Some((n,_)) => n, 245 | None => 0 246 | } 247 | } 248 | 249 | /// create an iterator on non-empy blocks 250 | pub fn iter_non_empty_blocks(&self) -> Result { 251 | let key = vec![RecordType::NonEmptyBlock as u8]; 252 | let iter = self 253 | .db 254 | .iterator(IteratorMode::From(&key, Direction::Forward)); 255 | 256 | Ok(NonEmptyBlocks::new(iter, key)) 257 | } 258 | 259 | /// count the number of non empty blocks 260 | pub fn count_non_empty_blocks(&self) -> Result { 261 | let key = vec![RecordType::NonEmptyBlockCount as u8]; 262 | Ok(self.get_u64(&key)?.unwrap_or(0)) 263 | } 264 | 265 | /// get a block 266 | pub fn get_block(&self, blockno: u64) -> Result>> { 267 | let mut b_k = vec![RecordType::Block as u8]; 268 | b_k.extend_from_slice(&u64_to_le(blockno)); 269 | Ok(self 270 | .db 271 | .get(&b_k) 272 | .map(|bytes| bytes.map(|v| from_slice::>(&*v).unwrap()))?) 273 | } 274 | 275 | /// create an iterator on address links 276 | pub fn iter_addr_tx_links(&self, addr: &Address) -> AddrTxLinks { 277 | let mut key: Vec = vec![RecordType::TxLink as u8]; 278 | key.extend_from_slice(addr); 279 | 280 | let iter = self 281 | .db 282 | .iterator(IteratorMode::From(&key, Direction::Forward)); 283 | 284 | AddrTxLinks::new(iter, key) 285 | } 286 | 287 | /// get number of address links 288 | pub fn count_addr_tx_links(&self, addr: &Address) -> Result { 289 | let mut key: Vec = vec![RecordType::TxLinkCount as u8]; 290 | key.extend_from_slice(addr); 291 | Ok(self.get_u64(&key)?.unwrap_or(0)) 292 | } 293 | 294 | /// increment the number of address links 295 | fn inc_addr_tx_links(&self, addr: &Address) -> Result { 296 | let mut key: Vec = vec![RecordType::TxLinkCount as u8]; 297 | key.extend_from_slice(addr); 298 | self.inc_u64(&key) 299 | } 300 | 301 | /// set the address contract 302 | pub fn set_contract(&self, addr: &Address, contract: &Contract) -> Result<()> { 303 | let mut key: Vec = vec![RecordType::ContractAbi as u8]; 304 | key.extend_from_slice(addr); 305 | self.db.put(&key, &to_vec(contract)?)?; 306 | Ok(()) 307 | } 308 | 309 | /// get the address contract 310 | pub fn get_contract(&self, addr: &Address) -> Result> { 311 | let mut key: Vec = vec![RecordType::ContractAbi as u8]; 312 | key.extend_from_slice(addr); 313 | 314 | if let Some(bytes) = self.db.get(&key)? { 315 | Ok(Some(from_slice::(&bytes.to_vec())?)) 316 | } else { 317 | Ok(None) 318 | } 319 | } 320 | 321 | /// get the next block to scan 322 | pub fn get_next_block_to_scan(&self) -> Result> { 323 | self.get_u64(&[RecordType::NextBlock as u8]) 324 | } 325 | 326 | /// set the next block to scan 327 | pub fn set_next_block_to_scan(&self, n: u64) -> Result<()> { 328 | self.set_u64(&[RecordType::NextBlock as u8],n) 329 | } 330 | 331 | /// increment an u64 counter 332 | fn inc_u64(&self, key : &[u8]) -> Result { 333 | let value = 1+self.get_u64(&key)?.unwrap_or(0); 334 | self.set_u64(&key,value)?; 335 | Ok(value) 336 | } 337 | 338 | /// get an u64 counter 339 | fn get_u64(&self, key : &[u8]) -> Result> { 340 | Ok(self 341 | .db 342 | .get(&key) 343 | .map(|bytes| bytes.map(|v| u64_from_slice(&*v)))?) 344 | } 345 | 346 | /// set an u64 counter 347 | fn set_u64(&self, key: &[u8], n: u64) -> Result<()> { 348 | self.db.put(&key, &u64_to_le(n))?; 349 | Ok(()) 350 | } 351 | 352 | /// dump the database 353 | pub fn _dump(&self) -> Result<()> { 354 | let key = vec![RecordType::TxLink as u8]; 355 | let iter = self 356 | .db 357 | .iterator(IteratorMode::From(&key, Direction::Forward)); 358 | 359 | for (key,_value) in iter { 360 | println!("**Key.iter {}",key.to_hex::()); 361 | } 362 | 363 | Ok(()) 364 | } 365 | } 366 | 367 | -------------------------------------------------------------------------------- /src/db/error.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug)] 2 | pub enum Error { 3 | Rocks(rocksdb::Error), 4 | SerdeCbor(serde_cbor::error::Error), 5 | } 6 | impl PartialEq for Error { 7 | fn eq(&self, other: &Error) -> bool { 8 | format!("{:?}", self) == format!("{:?}", other) 9 | } 10 | } 11 | 12 | impl From for Error { 13 | fn from(err: rocksdb::Error) -> Self { 14 | Error::Rocks(err) 15 | } 16 | } 17 | impl From for Error { 18 | fn from(err: serde_cbor::error::Error) -> Self { 19 | Error::SerdeCbor(err) 20 | } 21 | } 22 | 23 | pub type Result = std::result::Result; 24 | -------------------------------------------------------------------------------- /src/db/iterators.rs: -------------------------------------------------------------------------------- 1 | use rocksdb::{DBIterator}; 2 | use web3::types::{H256}; 3 | use serde_cbor::{from_slice}; 4 | 5 | use super::utils::*; 6 | use super::super::eth::types::InternalTx; 7 | 8 | impl AddrTxLinks { 9 | pub fn new(iter: DBIterator, key: Vec) -> Self { 10 | AddrTxLinks { iter, key } 11 | } 12 | } 13 | 14 | pub struct AddrTxLinks { 15 | iter: DBIterator, 16 | key: Vec, 17 | } 18 | 19 | #[allow(deprecated)] 20 | impl<'a> Iterator for AddrTxLinks { 21 | type Item = (H256,u64); 22 | 23 | fn next(&mut self) -> Option<(H256,u64)> { 24 | if let Some((key,_)) = self.iter.next() { 25 | if key.len() > self.key.len() && key[..self.key.len()] == self.key[..] { 26 | let tx = H256::from_slice(&key[self.key.len()+16..self.key.len()+16+32]); 27 | let itx = u64_from_slice(&key[self.key.len()+16+32..self.key.len()+16+32+8]); 28 | return Some((tx,std::u64::MAX-itx)); 29 | } 30 | } 31 | None 32 | } 33 | } 34 | 35 | pub struct NonEmptyBlocks { 36 | iter: DBIterator, 37 | key: Vec, 38 | } 39 | 40 | 41 | impl NonEmptyBlocks { 42 | pub fn new(iter: DBIterator, key: Vec) -> Self { 43 | NonEmptyBlocks { iter, key } 44 | } 45 | } 46 | 47 | impl<'a> Iterator for NonEmptyBlocks { 48 | type Item = u64; 49 | 50 | fn next(&mut self) -> Option { 51 | if let Some((k,_)) = self.iter.next() { 52 | if k.len() > self.key.len() && k[..self.key.len()] == self.key[..] { 53 | let blockno = u64_from_slice(&k[self.key.len()..]); 54 | return Some(std::u64::MAX -blockno); 55 | } 56 | } 57 | None 58 | } 59 | } 60 | 61 | pub struct InternalTxs { 62 | iter: DBIterator, 63 | key: Vec, 64 | } 65 | 66 | impl InternalTxs { 67 | pub fn new(iter: DBIterator, key: Vec) -> Self { 68 | InternalTxs { iter, key } 69 | } 70 | } 71 | 72 | impl<'a> Iterator for InternalTxs { 73 | type Item = (u64,InternalTx); 74 | 75 | fn next(&mut self) -> Option<(u64,InternalTx)> { 76 | if let Some((k,v)) = self.iter.next() { 77 | if k.len() > self.key.len() && k[..self.key.len()] == self.key[..] { 78 | let no = std::u64::MAX - u64_from_slice(&k[self.key.len()..]); 79 | let data : InternalTx = from_slice(&v).unwrap(); 80 | return Some((no,data)); 81 | } 82 | } 83 | None 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/db/mod.rs: -------------------------------------------------------------------------------- 1 | mod appdb; 2 | mod error; 3 | mod tests; 4 | mod types; 5 | mod utils; 6 | mod iterators; 7 | 8 | pub use self::appdb::{AppDB,Options}; 9 | pub use self::types::*; 10 | pub use self::error::*; -------------------------------------------------------------------------------- /src/db/tests.rs: -------------------------------------------------------------------------------- 1 | #[cfg(test)] 2 | mod tests { 3 | use super::super::appdb::*; 4 | use super::super::super::eth::types::*; 5 | 6 | use rand::distributions::Alphanumeric; 7 | use rand::{thread_rng, Rng}; 8 | use std::iter; 9 | use web3::types::{Bytes, Transaction, Address, H256, TransactionReceipt,U128, U256, H2048}; 10 | 11 | fn init() -> AppDB { 12 | let mut rng = thread_rng(); 13 | let chars: String = iter::repeat(()) 14 | .map(|()| rng.sample(Alphanumeric)) 15 | .take(7) 16 | .collect(); 17 | 18 | let mut tmpfile = std::env::temp_dir(); 19 | tmpfile.push(chars); 20 | 21 | AppDB::open_default( 22 | tmpfile.as_os_str().to_str().expect("bad OS filename"), 23 | Options { 24 | store_itx : true, 25 | store_tx : true, 26 | store_addr : true, 27 | store_neb : true, 28 | } 29 | ).expect("unable to create db") 30 | } 31 | 32 | struct TestVars { 33 | one_u256 : U256, 34 | a1 : Address, 35 | a2 : Address, 36 | a3 : Address, 37 | a4 : Address, 38 | h1 : H256, 39 | h2 : H256, 40 | h3 : H256, 41 | tx_a1_to_a2 : Transaction, 42 | rcp_a1_to_a2 : TransactionReceipt, 43 | tx_a1_to_contract : Transaction, 44 | rcp_a1_to_contract : TransactionReceipt, 45 | tx_a1_to_a1 : Transaction, 46 | rcp_a1_to_a1 : TransactionReceipt, 47 | } 48 | 49 | fn vars() -> TestVars { 50 | let one_u128 = U128::from_dec_str("1").unwrap(); 51 | let one_u256 = U256::from_dec_str("1").unwrap(); 52 | let a1 = hex_to_addr("0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").unwrap(); 53 | let a2 = hex_to_addr("0bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb").unwrap(); 54 | let a3 = hex_to_addr("0xcccccccccccccccccccccccccccccccccccccccc").unwrap(); 55 | let a4 = hex_to_addr("0xdddddddddddddddddddddddddddddddddddddddd").unwrap(); 56 | let h1 = hex_to_h256("0x1111111111111111111111111111111111111111111111111111111111111111") 57 | .unwrap(); 58 | let h2 = hex_to_h256("0x2222222222222222222222222222222222222222222222222222222222222222") 59 | .unwrap(); 60 | let h3 = hex_to_h256("0x3333333333333333333333333333333333333333333333333333333333333333") 61 | .unwrap(); 62 | 63 | let tx_a1_to_a2 = Transaction { 64 | hash: h1, 65 | nonce: one_u256, 66 | block_hash: None, 67 | block_number: Some(U256::from_dec_str("10").unwrap()), 68 | transaction_index: Some(one_u128), 69 | from: a1, 70 | to: Some(a2), 71 | value: one_u256, 72 | gas_price: one_u256, 73 | gas: one_u256, 74 | input: Bytes(Vec::new()), 75 | }; 76 | let rcp_a1_to_a2 = TransactionReceipt { 77 | block_hash: None, 78 | block_number: tx_a1_to_a2.block_number, 79 | transaction_index: one_u128, 80 | contract_address: None, 81 | gas_used: Some(one_u256), 82 | cumulative_gas_used: one_u256, 83 | status: None, 84 | transaction_hash: tx_a1_to_a2.hash, 85 | logs: Vec::new(), 86 | logs_bloom: H2048::default() 87 | }; 88 | 89 | let tx_a1_to_contract = Transaction { 90 | hash: h2, 91 | nonce: one_u256, 92 | block_hash: None, 93 | block_number: Some(U256::from_dec_str("11").unwrap()), 94 | transaction_index: Some(one_u128), 95 | from: a1, 96 | to: None, 97 | value: one_u256, 98 | gas_price: one_u256, 99 | gas: one_u256, 100 | input: Bytes(Vec::new()), 101 | }; 102 | let rcp_a1_to_contract = TransactionReceipt { 103 | block_hash: None, 104 | block_number: tx_a1_to_contract.block_number, 105 | transaction_index: one_u128, 106 | contract_address: Some(a3), 107 | gas_used: Some(one_u256), 108 | cumulative_gas_used: one_u256, 109 | status: None, 110 | transaction_hash: tx_a1_to_contract.hash, 111 | logs: Vec::new(), 112 | logs_bloom: H2048::default() 113 | }; 114 | let tx_a1_to_a1 = Transaction { 115 | hash: h3, 116 | nonce: one_u256, 117 | block_hash: None, 118 | block_number: Some(U256::from_dec_str("12").unwrap()), 119 | transaction_index: Some(one_u128), 120 | from: a1, 121 | to: Some(a1), 122 | value: one_u256, 123 | gas_price: one_u256, 124 | gas: one_u256, 125 | input: Bytes(Vec::new()), 126 | }; 127 | let rcp_a1_to_a1 = TransactionReceipt { 128 | block_hash: None, 129 | block_number: tx_a1_to_a1.block_number, 130 | transaction_index: one_u128, 131 | contract_address: None, 132 | gas_used: Some(one_u256), 133 | cumulative_gas_used: one_u256, 134 | status: None, 135 | transaction_hash: tx_a1_to_a1.hash, 136 | logs: Vec::new(), 137 | logs_bloom: H2048::default() 138 | }; 139 | TestVars { 140 | one_u256, 141 | a1,a2,a3,a4,h1,h2,h3, 142 | tx_a1_to_a2,rcp_a1_to_a2, 143 | tx_a1_to_contract,rcp_a1_to_contract, 144 | tx_a1_to_a1, rcp_a1_to_a1 145 | } 146 | } 147 | 148 | #[test] 149 | fn test_add_and_iter_tx() { 150 | let appdb = init(); 151 | let v = vars(); 152 | 153 | // no txs 154 | 155 | assert_eq!(0, appdb.count_addr_tx_links(&v.a1).unwrap()); 156 | assert_eq!(0, appdb.count_addr_tx_links(&v.a2).unwrap()); 157 | assert_eq!(0, appdb.count_addr_tx_links(&v.a3).unwrap()); 158 | 159 | // + tx_a1_to_a2 160 | 161 | assert_eq!((), appdb.add_tx(&v.tx_a1_to_a2, &v.rcp_a1_to_a2, Some(&[])).unwrap()); 162 | assert_eq!(1, appdb.count_addr_tx_links(&v.a1).unwrap()); 163 | assert_eq!(1, appdb.count_addr_tx_links(&v.a2).unwrap()); 164 | 165 | let mut it_a1 = appdb.iter_addr_tx_links(&v.a1); 166 | assert_eq!(Some((v.h1,0)), it_a1.next()); 167 | assert_eq!(None, it_a1.next()); 168 | 169 | let mut it_a2 = appdb.iter_addr_tx_links(&v.a2); 170 | assert_eq!(Some((v.h1,0)), it_a2.next()); 171 | assert_eq!(None, it_a2.next()); 172 | 173 | // + tx_a1_to_contract 174 | 175 | assert_eq!((), appdb.add_tx(&v.tx_a1_to_contract, &v.rcp_a1_to_contract,Some(&[])).unwrap()); 176 | assert_eq!(2, appdb.count_addr_tx_links(&v.a1).unwrap()); 177 | assert_eq!(1, appdb.count_addr_tx_links(&v.a2).unwrap()); 178 | assert_eq!(1, appdb.count_addr_tx_links(&v.a3).unwrap()); 179 | 180 | let mut it_a1 = appdb.iter_addr_tx_links(&v.a1); 181 | assert_eq!(Some((v.h2,0)), it_a1.next()); 182 | assert_eq!(Some((v.h1,0)), it_a1.next()); 183 | assert_eq!(None, it_a1.next()); 184 | 185 | let mut it_a3 = appdb.iter_addr_tx_links(&v.a3); 186 | assert_eq!(Some((v.h2,0)), it_a3.next()); 187 | assert_eq!(None, it_a3.next()); 188 | 189 | // + tx_a1_to_a1 190 | 191 | assert_eq!((), appdb.add_tx(&v.tx_a1_to_a1, &v.rcp_a1_to_a1,Some(&[])).unwrap()); 192 | assert_eq!(3, appdb.count_addr_tx_links(&v.a1).unwrap()); 193 | 194 | let mut it_a1 = appdb.iter_addr_tx_links(&v.a1); 195 | assert_eq!(Some((v.h3,0)), it_a1.next()); 196 | assert_eq!(Some((v.h2,0)), it_a1.next()); 197 | assert_eq!(Some((v.h1,0)), it_a1.next()); 198 | assert_eq!(None, it_a1.next()); 199 | } 200 | 201 | #[test] 202 | fn test_add_and_iter_itx_a1_to_a2() { 203 | 204 | let appdb = init(); 205 | let v = vars(); 206 | 207 | assert_eq!((), appdb.add_tx(&v.tx_a1_to_a2, &v.rcp_a1_to_a2, Some(&[ 208 | InternalTx { from : v.a2, to: Some(v.a3), contract:None, input: Vec::new(), value:v.one_u256 } 209 | ])).unwrap()); 210 | 211 | let mut it_a2 = appdb.iter_addr_tx_links(&v.a2); 212 | assert_eq!(Some((v.h1,1)), it_a2.next()); 213 | assert_eq!(Some((v.h1,0)), it_a2.next()); 214 | assert_eq!(None, it_a2.next()); 215 | } 216 | 217 | #[test] 218 | fn test_add_and_iter_itx_a2_to_contract() { 219 | 220 | let appdb = init(); 221 | let v = vars(); 222 | 223 | assert_eq!((), appdb.add_tx(&v.tx_a1_to_a2, &v.rcp_a1_to_a2, Some(&[ 224 | InternalTx { from : v.a2, to: None, contract:Some(v.a4), input: Vec::new(), value:v.one_u256} 225 | ])).unwrap()); 226 | 227 | let mut it_a2 = appdb.iter_addr_tx_links(&v.a2); 228 | assert_eq!(Some((v.h1,1)), it_a2.next()); 229 | assert_eq!(Some((v.h1,0)), it_a2.next()); 230 | assert_eq!(None, it_a2.next()); 231 | 232 | let mut it_a4 = appdb.iter_addr_tx_links(&v.a4); 233 | assert_eq!(Some((v.h1,1)), it_a4.next()); 234 | assert_eq!(None, it_a4.next()); 235 | } 236 | 237 | #[test] 238 | fn test_add_and_iter_itx_a1_to_a1() { 239 | let appdb = init(); 240 | let v = vars(); 241 | 242 | assert_eq!((), appdb.add_tx(&v.tx_a1_to_a1, &v.rcp_a1_to_a1, Some(&[ 243 | InternalTx { from : v.a1, to: Some(v.a1), contract:None, input: Vec::new(), value:v.one_u256 } 244 | ])).unwrap()); 245 | 246 | let mut it_a1 = appdb.iter_addr_tx_links(&v.a1); 247 | assert_eq!(Some((v.h3,1)), it_a1.next()); 248 | assert_eq!(Some((v.h3,0)), it_a1.next()); 249 | assert_eq!(None, it_a1.next()); 250 | } 251 | 252 | #[test] 253 | fn test_add_and_iter_itx_a1_to_a1_2itx() { 254 | let appdb = init(); 255 | let v = vars(); 256 | 257 | assert_eq!((), appdb.add_tx(&v.tx_a1_to_a1, &v.rcp_a1_to_a1, Some(&[ 258 | InternalTx { from : v.a3, to: Some(v.a1), contract:None, input: Vec::new(), value:v.one_u256 }, 259 | InternalTx { from : v.a2, to: None, contract:Some(v.a3), input: Vec::new(), value:v.one_u256 } 260 | ])).unwrap()); 261 | 262 | assert_eq!(0,appdb._count_itxs(&v.h1)); 263 | assert_eq!(2,appdb._count_itxs(&v.h3)); 264 | 265 | let mut i_itx = appdb.iter_itxs(&v.h3); 266 | assert_eq!(i_itx.next().map(|(n,itx)| (n,itx.from,itx.contract)),Some((2,v.a2,Some(v.a3)))); 267 | assert_eq!(i_itx.next().map(|(n,itx)| (n,itx.from,itx.to)),Some((1,v.a3,Some(v.a1)))); 268 | assert_eq!(None, i_itx.next()); 269 | } 270 | 271 | #[test] 272 | fn test_set_get_block() { 273 | let appdb = init(); 274 | assert_eq!(Ok(None), appdb.get_next_block_to_scan()); 275 | assert_eq!(Ok(()), appdb.set_next_block_to_scan(1)); 276 | assert_eq!(Ok(Some(1)), appdb.get_next_block_to_scan()); 277 | assert_eq!(Ok(()), appdb.set_next_block_to_scan(0xaabbccdd11223344)); 278 | assert_eq!(Ok(Some(0xaabbccdd11223344)), appdb.get_next_block_to_scan()); 279 | } 280 | 281 | } 282 | -------------------------------------------------------------------------------- /src/db/types.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug,Copy, Clone, PartialEq)] 2 | #[repr(u8)] 3 | pub enum RecordType { 4 | TxLink = 1, 5 | NextBlock = 2, 6 | Tx = 3, 7 | Block = 4, 8 | Receipt = 5, 9 | ContractAbi = 6, 10 | TxLinkCount = 7, 11 | NonEmptyBlock = 8, 12 | NonEmptyBlockCount = 9, 13 | IntTx = 10, 14 | } 15 | 16 | #[derive(Debug,Serialize,Deserialize)] 17 | pub struct Contract { 18 | pub source : String, 19 | pub abi : String, 20 | pub name : String, 21 | pub compiler: String, 22 | pub optimized: bool, 23 | pub constructor : Vec, 24 | } 25 | -------------------------------------------------------------------------------- /src/db/utils.rs: -------------------------------------------------------------------------------- 1 | /// get u64 as litte endian 2 | pub fn u64_to_le(v: u64) -> [u8; 8] { 3 | [ 4 | ((v >> 56) & 0xff) as u8, 5 | ((v >> 48) & 0xff) as u8, 6 | ((v >> 40) & 0xff) as u8, 7 | ((v >> 32) & 0xff) as u8, 8 | ((v >> 24) & 0xff) as u8, 9 | ((v >> 16) & 0xff) as u8, 10 | ((v >> 8) & 0xff) as u8, 11 | ((v ) & 0xff) as u8, 12 | ] 13 | } 14 | 15 | /// get u64 from litte endian 16 | pub fn le_to_u64(v: [u8; 8]) -> u64 { 17 | u64::from(v[7]) 18 | + (u64::from(v[6]) << 8 ) 19 | + (u64::from(v[5]) << 16) 20 | + (u64::from(v[4]) << 24) 21 | + (u64::from(v[3]) << 32) 22 | + (u64::from(v[2]) << 40) 23 | + (u64::from(v[1]) << 48) 24 | + (u64::from(v[0]) << 56) 25 | } 26 | 27 | /// get u64 from litte endian slice 28 | pub fn u64_from_slice(v: &[u8]) -> u64 { 29 | let mut le = [0; 8]; 30 | le[..].copy_from_slice(v); 31 | le_to_u64(le) 32 | } 33 | 34 | -------------------------------------------------------------------------------- /src/eth/contract/error.rs: -------------------------------------------------------------------------------- 1 | use db; 2 | use std::io; 3 | 4 | #[derive(Debug)] 5 | pub enum Error { 6 | Web3(web3::Error), 7 | DB(db::Error), 8 | FromHex(rustc_hex::FromHexError), 9 | EthAbi(ethabi::Error), 10 | SerdeJson(serde_json::Error), 11 | ContractInvalid, 12 | ContractNotFound, 13 | FunctionNotFound, 14 | CodeDoesNotMatch, 15 | CompilerNotFound, 16 | EventNotFound, 17 | Io(std::io::Error), 18 | } 19 | 20 | impl From for Error { 21 | fn from(err: io::Error) -> Self { 22 | Error::Io(err) 23 | } 24 | } 25 | impl From for Error { 26 | fn from(err: rustc_hex::FromHexError) -> Self { 27 | Error::FromHex(err) 28 | } 29 | } 30 | impl From for Error { 31 | fn from(err: ethabi::Error) -> Self { 32 | Error::EthAbi(err) 33 | } 34 | } 35 | 36 | impl From for Error { 37 | fn from(err: serde_json::Error) -> Self { 38 | Error::SerdeJson(err) 39 | } 40 | } 41 | 42 | impl From for Error { 43 | fn from(err: web3::Error) -> Self { 44 | Error::Web3(err) 45 | } 46 | } 47 | impl From for Error { 48 | fn from(err: db::Error) -> Self { 49 | Error::DB(err) 50 | } 51 | } 52 | 53 | pub type Result = std::result::Result; 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/eth/contract/mod.rs: -------------------------------------------------------------------------------- 1 | mod parser; 2 | mod verifier; 3 | mod error; 4 | 5 | pub use self::{ 6 | error::Error, 7 | parser::ContractParser, 8 | verifier::installed_compilers, 9 | verifier::verify_abi, 10 | verifier::compile_and_verify, 11 | verifier::ONLY_ABI 12 | }; -------------------------------------------------------------------------------- /src/eth/contract/parser.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | use keccak_hash; 4 | use ethabi; 5 | use ethabi::param_type::{Writer, ParamType}; 6 | use web3::types::Address; 7 | 8 | use super::error::{Error,Result}; 9 | 10 | static FALLBACK : &str = "()"; 11 | 12 | pub struct ContractParser { 13 | pub abis : HashMap, 14 | } 15 | 16 | pub struct CallInfo<'a> { 17 | pub func : &'a str, 18 | pub params : Vec<(&'a String,ethabi::Token)>, 19 | } 20 | 21 | impl ContractParser { 22 | 23 | /// create a new contract parser 24 | pub fn new() -> Self { 25 | ContractParser { abis : HashMap::new() } 26 | } 27 | 28 | /// add a new contract and its abi 29 | pub fn add(&mut self, addr: Address, abistr : &str) -> Result<()> { 30 | self.abis.entry(addr) 31 | .or_insert(ethabi::Contract::load(abistr.as_bytes())?); 32 | Ok(()) 33 | } 34 | 35 | /// return true if the contract has been already added 36 | pub fn contains(&self, addr: &Address)-> bool { 37 | self.abis.contains_key(addr) 38 | } 39 | 40 | /// parse a function call 41 | pub fn tx_funcparams(&self, addr: &Address, input: &[u8], parse_params: bool) -> Result { 42 | if let Some(abi) = self.abis.get(addr) { 43 | for func in abi.functions() { 44 | let paramtypes : &Vec = &func.inputs.iter().map(|p| p.kind.clone()).collect(); 45 | let sig = short_signature(&func.name,¶mtypes); 46 | 47 | if input.len() >= 4 && input[0..4] == sig[0..4] { 48 | 49 | let params = if parse_params { 50 | func.inputs.iter() 51 | .map(|input| &input.name) 52 | .zip(ethabi::decode(¶mtypes, &input[4..])?) 53 | .collect::>() 54 | } else { 55 | Vec::new() 56 | }; 57 | 58 | return Ok(CallInfo{ 59 | func : &func.name, 60 | params 61 | }); 62 | } 63 | } 64 | if abi.fallback { 65 | return Ok(CallInfo{ 66 | func : FALLBACK, 67 | params : Vec::new(), 68 | }); 69 | } else { 70 | Err(Error::FunctionNotFound) 71 | } 72 | } else { 73 | Err(Error::ContractNotFound) 74 | } 75 | } 76 | 77 | /// find the event that matches with the current log 78 | fn log_findevent(&self, txlog: &web3::types::Log) -> Result<ðabi::Event> { 79 | if let Some(abi) = self.abis.get(&txlog.address) { 80 | let event = abi.events().find(|e| e.signature()==txlog.topics[0]); 81 | 82 | if let Some(event) = event { 83 | Ok(&event) 84 | } else { 85 | Err(Error::EventNotFound) 86 | } 87 | } else { 88 | Err(Error::ContractNotFound) 89 | } 90 | } 91 | 92 | /// get the event name and parameters of a log 93 | pub fn log_eventparams(&self, txlog: web3::types::Log) -> Result<(&str,ethabi::Log)> { 94 | let event = self.log_findevent(&txlog)?; 95 | let rawlog = ethabi::RawLog{topics: txlog.topics,data: txlog.data.0}; 96 | let log = event.parse_log(rawlog)?; 97 | Ok((&event.name,log)) 98 | } 99 | 100 | } 101 | 102 | /// taken from libraries, return a method 4-byte signature 103 | fn short_signature(name: &str, params: &[ParamType]) -> [u8; 4] { 104 | 105 | fn fill_signature(name: &str, params: &[ParamType], result: &mut [u8]) { 106 | let types = params.iter() 107 | .map(Writer::write) 108 | .collect::>() 109 | .join(","); 110 | 111 | let data: Vec = From::from(format!("{}({})", name, types).as_str()); 112 | keccak_hash::keccak_256(&data,result); 113 | } 114 | 115 | let mut result = [0u8; 4]; 116 | fill_signature(name, params, &mut result); 117 | result 118 | } 119 | -------------------------------------------------------------------------------- /src/eth/contract/verifier.rs: -------------------------------------------------------------------------------- 1 | use std::process::Command; 2 | use std::collections::HashMap; 3 | use std::io::prelude::*; 4 | use std::fs; 5 | use std::fs::File; 6 | 7 | use rand::{thread_rng, Rng}; 8 | use rand::distributions::Alphanumeric; 9 | use rustc_hex::{FromHex,ToHex}; 10 | 11 | use ethabi; 12 | 13 | use bootstrap::Config; 14 | use super::error::{Error,Result}; 15 | 16 | pub static ONLY_ABI : &str = "abi-only"; 17 | 18 | #[derive(Serialize, Deserialize, Clone, Debug)] 19 | pub struct SolcContract { 20 | pub abi : String, 21 | #[serde(rename = "bin-runtime")] 22 | pub binruntime : String, 23 | } 24 | 25 | #[derive(Serialize, Deserialize, Debug)] 26 | pub struct SolcJson { 27 | contracts : HashMap, 28 | version : String, 29 | } 30 | 31 | /// get the solc complilers intalled in config solc_path 32 | pub fn installed_compilers(cfg : &Config) -> Result> { 33 | if let Some(path) = &cfg.solc_path { 34 | Ok(fs::read_dir(path)? 35 | .filter_map(|entry| entry.ok()) 36 | .filter(|entry| entry.file_type().unwrap().is_file()) 37 | .map(|entry| entry.file_name().into_string().unwrap()) 38 | .collect() 39 | ) 40 | } else { 41 | Ok(Vec::new()) 42 | } 43 | } 44 | 45 | /// verify if an abi is ok 46 | pub fn verify_abi(source: &str) -> Result<()>{ 47 | ethabi::Contract::load(source.as_bytes())?; 48 | Ok(()) 49 | } 50 | 51 | /// compile a contract and check if it maches with blockchain bytecode 52 | pub fn compile_and_verify( 53 | cfg : &Config, 54 | source: &str, 55 | contractname: &str, 56 | compiler: &str, 57 | optimized: bool, 58 | code: &[u8]) 59 | 60 | -> Result { 61 | 62 | if installed_compilers(&cfg)?.into_iter().find(|c| c==compiler).is_none() { 63 | return Err(Error::CompilerNotFound); 64 | } 65 | 66 | let mut rng = thread_rng(); 67 | let chars: String = std::iter::repeat(()) 68 | .map(|()| rng.sample(Alphanumeric)) 69 | .take(12) 70 | .collect(); 71 | 72 | let mut tmp_dir_path = std::env::temp_dir(); 73 | tmp_dir_path.push(chars); 74 | 75 | std::fs::create_dir(&tmp_dir_path)?; 76 | let tmp_dir = tmp_dir_path.into_os_string().into_string().unwrap(); 77 | let input = format!("{}/contract.sol",tmp_dir); 78 | let output = format!("{}/combined.json",tmp_dir); 79 | 80 | File::create(&input)?.write_all(source.as_bytes())?; 81 | 82 | let args : Vec<&str> = if optimized { 83 | vec![&input,"-o",&tmp_dir,"--combined-json","abi,bin-runtime","--optimize","--optimize-runs","200"] 84 | } else { 85 | vec![&input,"-o",&tmp_dir,"--combined-json","abi,bin-runtime","--optimize-runs","200"] 86 | }; 87 | 88 | let cmdoutput = Command::new( 89 | format!("{}/{}",&cfg.solc_path.clone().unwrap(),compiler) 90 | ).args(args).output()?; 91 | 92 | println!("stdout: {}", String::from_utf8_lossy(&cmdoutput.stdout)); 93 | println!("stderr: {}", String::from_utf8_lossy(&cmdoutput.stderr)); 94 | 95 | let mut contents = String::new(); 96 | File::open(&output)?.read_to_string(&mut contents)?; 97 | 98 | let deserialized: SolcJson = serde_json::from_str(&contents)?; 99 | let key = format!("{}:{}",&input,contractname); 100 | 101 | if let Some(contract) = deserialized.contracts.get(&key) { 102 | code_equals(&contract, &code)?; 103 | Ok(contract.abi.clone()) 104 | } else { 105 | Err(Error::ContractNotFound) 106 | } 107 | } 108 | 109 | 110 | /// check if two bytecodes matches 111 | fn code_equals(contract : &SolcContract, code: &[u8]) -> Result<()> { 112 | let binruntime : Vec = contract.binruntime.from_hex()?; 113 | 114 | // compiled code may have multiple swam hashes in the following 115 | // way a1 65 62 7a 7a 72 30 58 20 + hash(32bytes) + 0029 116 | 117 | let mut l = code.len(); 118 | while l > 50 119 | && code[l-1]==0x29 && code[l-2]==0x00 120 | && code[l-35]==0x20 && code[l-36]==0x58 121 | && code[l-37]==0x30 && code[l-38]==0x72 122 | && code[l-39]==0x7a && code[l-40]==0x7a 123 | && code[l-41]==0x62 && code[l-42]==0x65 124 | && code[l-43]==0xa1 { 125 | 126 | l -= 43; 127 | } 128 | 129 | // compiled code includes the swarm hash (32 bytes) + 00 29 130 | if code.len() != binruntime.len() || code.len() < 34 { 131 | warn!("blockchain {}",code.to_hex::()); 132 | warn!("compiled {}",binruntime.to_hex::()); 133 | Err(Error::ContractInvalid) 134 | } else if code[0..l] != binruntime[0..l] { 135 | warn!("blockchain {}",code.to_hex::()); 136 | warn!("compiled {}",binruntime.to_hex::()); 137 | Err(Error::CodeDoesNotMatch) 138 | } else { 139 | Ok(()) 140 | } 141 | } -------------------------------------------------------------------------------- /src/eth/error.rs: -------------------------------------------------------------------------------- 1 | use db; 2 | use std::io; 3 | 4 | #[derive(Debug)] 5 | pub enum Error { 6 | Web3(web3::Error), 7 | DB(db::Error), 8 | FromHex(rustc_hex::FromHexError), 9 | EthAbi(ethabi::Error), 10 | SerdeJson(serde_json::Error), 11 | Io(std::io::Error), 12 | } 13 | 14 | impl From for Error { 15 | fn from(err: io::Error) -> Self { 16 | Error::Io(err) 17 | } 18 | } 19 | impl From for Error { 20 | fn from(err: rustc_hex::FromHexError) -> Self { 21 | Error::FromHex(err) 22 | } 23 | } 24 | impl From for Error { 25 | fn from(err: ethabi::Error) -> Self { 26 | Error::EthAbi(err) 27 | } 28 | } 29 | 30 | impl From for Error { 31 | fn from(err: serde_json::Error) -> Self { 32 | Error::SerdeJson(err) 33 | } 34 | } 35 | 36 | impl From for Error { 37 | fn from(err: web3::Error) -> Self { 38 | Error::Web3(err) 39 | } 40 | } 41 | impl From for Error { 42 | fn from(err: db::Error) -> Self { 43 | Error::DB(err) 44 | } 45 | } 46 | 47 | pub type Result = std::result::Result; 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/eth/geth/clique.rs: -------------------------------------------------------------------------------- 1 | use rlp::RlpStream; 2 | use keccak_hash::keccak; 3 | use ethkey::{Signature,recover}; 4 | use web3::types::{H256, Address}; 5 | 6 | /* example header 7 | ----------------------------------------------- 8 | Block: 7269 9 | vanity: d683010810846765746886676f312e3131856c696e7578000000000000000000 10 | sig: c5b1f7978f1ac8acfdf7fd7c3b1cd0c154d4bd934e0c8ec6c17c6de160c42d1c 11 | 218cce60293226fee8bdb5292720afd452932706ad673f707eb3486a8a8084e8 12 | 00 13 | Hash: 0x6adaaeb02efa0aced16e5931a2935b43da653d12e978c130bbdda1fb6214ff7e 14 | rtl: f90216a012e8a425926ba32afd3d55e0dbdf083de02e96845041914129e3d03e3bd461faa01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a0093b304253d9f02698a68d410803c4cf922b8a12f9f15ceed0208ec31cd1f431a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001821c65837a120080845c087102a0d683010810846765746886676f312e3131856c696e7578000000000000000000a00000000000000000000000000000000000000000000000000000000000000000880000000000000000 15 | Signature: 332dfeffacf8eb84d09fc22df6862673b57ad721648c81c577976513386bd80a4c3c581664196dd83866165ae6f57fff59b31d63788867cf2ac77904d09c5b4901 16 | pubkey: 043665cb2b553b888403b7b16107159804af66095ef4b50e7e2cbaa9ef1a5294445f86cfc4a82ff816786cfc0c780bb492cc7c36ca4662a04790a9fbe56e330a1e 17 | signer: 0xF979Deb61F2E982761Ac22b2a647cafDc5263fFc 18 | ----------------------------------------------- 19 | */ 20 | 21 | /// get the block author from the clique header 22 | #[allow(deprecated)] 23 | pub fn parse_clique_header(block : &web3::types::Block) -> Option
{ 24 | const EXTRA_SEAL : usize = 65; 25 | let vanity = &block.extra_data.0[..block.extra_data.0.len()-EXTRA_SEAL]; 26 | let mut stream = RlpStream::new_list(15); 27 | stream 28 | .append(&block.parent_hash) 29 | .append(&block.uncles_hash) 30 | .append(&block.author) 31 | .append(&block.state_root) 32 | .append(&block.transactions_root) 33 | .append(&block.receipts_root) 34 | .append(&block.logs_bloom) 35 | .append(&block.difficulty) 36 | .append(&block.number.unwrap()) 37 | .append(&block.gas_limit) 38 | .append(&block.gas_used) 39 | .append(&block.timestamp) 40 | .append(&vanity.to_vec()) 41 | .append(&block.mix_hash.unwrap()) 42 | .append(&block.nonce.unwrap()); 43 | 44 | let rlp = &stream.out(); 45 | 46 | let seal_hash = keccak(&rlp); 47 | 48 | let signature = &block.extra_data.0[block.extra_data.0.len()-EXTRA_SEAL..]; 49 | 50 | let r = H256::from_slice(&signature[0..32]); 51 | let s = H256::from_slice(&signature[32..]); 52 | let v = signature[64]; 53 | 54 | let sig = Signature::from_rsv(&r, &s, v); 55 | 56 | if sig.is_valid() { 57 | if let Ok(pbk) = recover(&sig, &seal_hash) { 58 | let pbk_hash = keccak(pbk); 59 | let signer = Address::from_slice(&pbk_hash.0[12..]); 60 | return Some(signer); 61 | } 62 | } 63 | None 64 | } 65 | -------------------------------------------------------------------------------- /src/eth/geth/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod web3; 2 | pub mod clique; 3 | -------------------------------------------------------------------------------- /src/eth/geth/web3.rs: -------------------------------------------------------------------------------- 1 | use web3::api::Namespace; 2 | use web3::helpers::{CallFuture}; 3 | use web3::types::{U256,Address,Transaction}; 4 | use web3::Transport; 5 | use rustc_hex::{FromHexError}; 6 | 7 | use super::super::types::*; 8 | 9 | /// `Debug` namespace 10 | #[derive(Debug, Clone)] 11 | pub struct Debug { 12 | transport: T, 13 | } 14 | 15 | /// A transport for debug_ calls 16 | impl Namespace for Debug { 17 | fn new(transport: T) -> Self 18 | where 19 | Self: Sized, 20 | { 21 | Debug { transport } 22 | } 23 | 24 | fn transport(&self) -> &T { 25 | &self.transport 26 | } 27 | } 28 | 29 | /// Entry returned by calltracer 30 | #[derive(Clone,Debug,Serialize,Deserialize)] 31 | pub struct DbgCallEntry { 32 | pub from: String, 33 | pub input: String, 34 | pub to: String, 35 | #[serde(rename = "type")] 36 | pub op: String, 37 | pub value: String, 38 | } 39 | 40 | /// The structure returned by debug_traceTransaction(calltracer) 41 | #[derive(Debug,Serialize,Deserialize)] 42 | pub struct DbgInternalTxs { 43 | calls : Option>, 44 | } 45 | 46 | impl DbgInternalTxs { 47 | 48 | /// Parse hex string address 49 | fn opthex_to_addr(&self, s:&str) -> Result,FromHexError> { 50 | if s.is_empty() { 51 | Ok(None) 52 | } else { 53 | Ok(Some(hex_to_addr(s)?)) 54 | } 55 | } 56 | 57 | /// Parse debug_ call and return a vector of InternalTx 58 | pub fn parse(&self) -> Result,FromHexError> { 59 | let zero_u256 = U256::default(); 60 | let mut itxs = Vec::new(); 61 | 62 | if let Some(calls) = &self.calls { 63 | for call in calls { 64 | if call.op == "CREATE" || call.op == "CREATE2" { 65 | itxs.push(InternalTx{ 66 | from : hex_to_addr(&call.from)?, 67 | to : None, 68 | contract : self.opthex_to_addr(&call.to)?, 69 | input : hex_to_vec(&call.input)?, 70 | value : if call.value == "0x0" { zero_u256 } else { hex_to_u256(&call.value)? } 71 | }) 72 | } else { 73 | itxs.push(InternalTx{ 74 | from : hex_to_addr(&call.from)?, 75 | to : self.opthex_to_addr(&call.to)?, 76 | contract : None, 77 | input : hex_to_vec(&call.input)?, 78 | value : if call.value == "0x0" { zero_u256 } else { hex_to_u256(&call.value)? } 79 | }) 80 | } 81 | } 82 | } 83 | Ok(itxs) 84 | } 85 | } 86 | 87 | impl Debug { 88 | 89 | /// Retrieve internal transactions by calling debug_traceTransaction 90 | pub fn internal_txs(&self, tx: &Transaction) -> CallFuture { 91 | CallFuture::new( 92 | self.transport.execute ( 93 | "debug_traceTransaction", 94 | vec![ 95 | web3::helpers::serialize(&tx.hash), 96 | serde_json::from_str("{\"tracer\":\"callTracer\"}").unwrap(), 97 | ] 98 | )) 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/eth/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod geth; 2 | 3 | mod reader; 4 | mod error; 5 | pub mod contract; 6 | pub mod types; 7 | 8 | pub use self::error::{Error,Result}; 9 | pub use self::reader::BlockchainReader; 10 | -------------------------------------------------------------------------------- /src/eth/reader.rs: -------------------------------------------------------------------------------- 1 | use state::*; 2 | use std::collections::HashMap; 3 | use web3::futures::Future; 4 | use web3::types::{ 5 | Address, Block, BlockId, BlockNumber, Bytes, Transaction, TransactionId, TransactionReceipt, 6 | H256, U256, 7 | }; 8 | 9 | use super::error::Result; 10 | use super::types::*; 11 | 12 | use super::super::eth::geth; 13 | use super::super::state::GlobalState; 14 | 15 | pub struct BlockchainReader<'a> { 16 | wc: Web3Client, 17 | pub ge: &'a GlobalState, 18 | } 19 | 20 | /// Blockchain reader provides an unified way to access to the blockchain data 21 | impl<'a> BlockchainReader<'a> { 22 | pub fn new(ge: &'a GlobalState) -> Self { 23 | let wc = ge.new_web3client(); 24 | BlockchainReader { wc, ge } 25 | } 26 | 27 | /// retrieve the current block 28 | pub fn current_block_number(&self) -> Result{ 29 | Ok(self.wc.web3.eth().block_number().wait()?.low_u64()) 30 | } 31 | 32 | /// retrieve the current balance for an address 33 | pub fn current_balance(&self, addr: &Address) -> Result{ 34 | Ok(self.wc.web3.eth().balance(*addr, None).wait()?) 35 | } 36 | 37 | /// retrieve the current code for an address 38 | pub fn current_code(&self, addr: &Address) -> Result{ 39 | Ok(self.wc.web3.eth().code(*addr, None).wait()?) 40 | } 41 | 42 | /// retrieve a block 43 | pub fn block(&self, blockno: u64) -> Result>>{ 44 | if let Some(blk) = self.ge.db.get_block(blockno)? { 45 | Ok(Some(blk)) 46 | } else { 47 | let blockid = BlockId::Number(BlockNumber::Number(blockno)); 48 | if let Some(blk) = self.wc.web3.eth().block(blockid).wait()? { 49 | Ok(Some(blk)) 50 | } else { 51 | Ok(None) 52 | } 53 | } 54 | } 55 | /// retrieve a block with its transactions 56 | pub fn block_with_txs(&self, blockno: u64) -> Result>>{ 57 | // assume that if the block exists all transactions will also exist 58 | if let Some(blk) = self.ge.db.get_block(blockno)? { 59 | let mut txs = HashMap::new(); 60 | for txhash in &blk.transactions { 61 | let tx = self.ge.db.get_tx(&txhash)?.unwrap(); // TODO: remove unwrap 62 | txs.insert(tx.hash, tx); 63 | } 64 | Ok(Some(into_block(blk, move |h: H256| { 65 | txs.remove(&h).unwrap() 66 | }))) 67 | } else { 68 | let blockid = BlockId::Number(BlockNumber::Number(blockno)); 69 | if let Some(blk) = self.wc.web3.eth().block_with_txs(blockid).wait()? { 70 | Ok(Some(blk)) 71 | } else { 72 | Ok(None) 73 | } 74 | } 75 | } 76 | 77 | /// retrieve a transaction 78 | pub fn tx( 79 | &self, 80 | txhash: H256, 81 | ) -> Result)>>{ 82 | let mut tx = self.ge.db.get_tx(&txhash)?; 83 | if tx.is_none() { 84 | tx = self 85 | .wc 86 | .web3 87 | .eth() 88 | .transaction(TransactionId::Hash(txhash)) 89 | .wait()?; 90 | } 91 | if let Some(tx) = tx { 92 | let mut receipt = self.ge.db.get_receipt(&txhash)?; 93 | if receipt.is_none() { 94 | receipt = self.wc.web3.eth().transaction_receipt(txhash).wait()? 95 | } 96 | Ok(Some((tx, receipt))) 97 | } else { 98 | Ok(None) 99 | } 100 | } 101 | 102 | /// retrieve an internal transaction 103 | pub fn itx( 104 | &self, 105 | tx: &Transaction 106 | ) -> Result> { 107 | let mut itxs : Vec = self.ge.db.iter_itxs(&tx.hash).map(|(_,t)| t).collect(); 108 | if itxs.is_empty() && self.ge.cfg.web3_itx { 109 | let dbg : geth::web3::Debug<_> = self.wc.web3.api(); 110 | itxs = dbg.internal_txs(&tx).wait()?.parse()?; 111 | } 112 | Ok(itxs) 113 | } 114 | 115 | } 116 | -------------------------------------------------------------------------------- /src/eth/types.rs: -------------------------------------------------------------------------------- 1 | use rustc_hex::{FromHex, FromHexError}; 2 | use web3::types::{Address, Block, H256,U256}; 3 | 4 | #[derive(Debug,PartialEq,Serialize,Deserialize)] 5 | pub struct InternalTx { 6 | pub from : Address, 7 | pub to : Option
, 8 | pub contract : Option
, 9 | pub value : U256, 10 | pub input : Vec, 11 | } 12 | 13 | pub fn hex_to_vec(s: &str) -> Result, FromHexError> { 14 | s.to_owned() 15 | .chars() 16 | .skip(2) 17 | .collect::() 18 | .from_hex() 19 | } 20 | 21 | #[allow(deprecated)] 22 | pub fn hex_to_addr(s: &str) -> Result { 23 | hex_to_vec(s).map(|v| Address::from_slice(&v)) 24 | } 25 | 26 | #[allow(deprecated)] 27 | pub fn hex_to_h256(s: &str) -> Result { 28 | hex_to_vec(s).map(|v| H256::from_slice(&v)) 29 | } 30 | 31 | pub fn hex_to_u256(s: &str) -> Result { 32 | hex_to_vec(s).map(|v| U256::from_big_endian(&v)) // TODO: check 33 | } 34 | 35 | pub fn into_block(block: Block, f: F) -> Block 36 | where 37 | F: FnMut(T1) -> T2, 38 | { 39 | Block { 40 | hash: block.hash, 41 | parent_hash: block.parent_hash, 42 | uncles_hash: block.uncles_hash, 43 | author: block.author, 44 | state_root: block.state_root, 45 | transactions_root: block.transactions_root, 46 | receipts_root: block.receipts_root, 47 | number: block.number, 48 | gas_used: block.gas_used, 49 | gas_limit: block.gas_limit, 50 | extra_data: block.extra_data, 51 | logs_bloom: block.logs_bloom, 52 | timestamp: block.timestamp, 53 | difficulty: block.difficulty, 54 | total_difficulty: block.total_difficulty, 55 | seal_fields: block.seal_fields, 56 | uncles: block.uncles, 57 | transactions: block.transactions.into_iter().map(f).collect(), 58 | size: block.size, 59 | nonce : block.nonce, 60 | mix_hash : block.mix_hash, 61 | } 62 | } -------------------------------------------------------------------------------- /src/explorer/address.rs: -------------------------------------------------------------------------------- 1 | use web3::types::Address; 2 | 3 | use super::error::*; 4 | use super::html::*; 5 | 6 | use super::super::eth::{ 7 | BlockchainReader, 8 | contract::{installed_compilers,ONLY_ABI} 9 | }; 10 | 11 | use super::super::state::GlobalState; 12 | use super::utils; 13 | 14 | /// render the address info 15 | pub fn render( 16 | ge: &GlobalState, 17 | addr: &Address, 18 | page_no : u64, 19 | ) -> Result { 20 | 21 | let cfg = &ge.cfg; 22 | let mut hr = HtmlRender::new(&ge); 23 | let reader = BlockchainReader::new(&ge); 24 | let db = &ge.db; 25 | let hb = &ge.hb; 26 | 27 | // get current blockchain data 28 | 29 | let balance = reader.current_balance(addr)?; 30 | let code = reader.current_code(addr)?; 31 | 32 | // get linked transactions (internal and external) 33 | 34 | let count_addr_tx_links = db.count_addr_tx_links(&addr)?; 35 | let limit = if count_addr_tx_links > 200 { 36 | 200 37 | } else { 38 | count_addr_tx_links 39 | }; 40 | 41 | let pg = utils::paginate(limit,15,page_no); 42 | let mut txs = Vec::new(); 43 | if pg.from <= pg.to { 44 | let it = db.iter_addr_tx_links(&addr).skip(pg.from as usize); 45 | for (txhash,itx_no) in it.take((pg.to-pg.from) as usize) { 46 | let tx = reader.tx(txhash)?.unwrap(); 47 | if itx_no == 0 { 48 | txs.push(hr.tx(&tx.0,&tx.1)?); 49 | } else { 50 | let itx = db.get_itx(&txhash,itx_no)?.unwrap(); 51 | txs.push(hr.tx_itx(&tx.0,&itx)?) 52 | } 53 | } 54 | } 55 | 56 | // render 57 | 58 | if !code.0.is_empty() { 59 | 60 | let mut solcversions = installed_compilers(&cfg)?; 61 | if cfg.solc_bypass { 62 | solcversions.push(ONLY_ABI.to_string()); 63 | } 64 | 65 | let rawcode = hr.bytes(&code.0,50); 66 | let contract = db.get_contract(addr)?; 67 | 68 | if let Some(contract) = contract { 69 | 70 | let can_set_source = contract.compiler == ONLY_ABI; 71 | 72 | Ok(hb.render( 73 | "address.handlebars", 74 | &json!({ 75 | "ui_title" : ge.cfg.ui_title, 76 | "address" : format!("0x{:x}",addr), 77 | "balance" : hr.ether(&balance,false), 78 | "txs" : txs, 79 | "txs_count" : count_addr_tx_links, 80 | "has_next_page": pg.next_page.is_some(), 81 | "next_page": pg.next_page.unwrap_or(0), 82 | "has_prev_page": pg.prev_page.is_some(), 83 | "prev_page": pg.prev_page.unwrap_or(0), 84 | "hascode" : true, 85 | "rawcode" : rawcode, 86 | "can_set_source" : can_set_source, 87 | "solcversions" : solcversions, 88 | "contract_source" : contract.source, 89 | "contract_name" : contract.name, 90 | "contract_abi" : contract.abi, 91 | "contract_compiler" : contract.compiler, 92 | "contract_optimized": contract.optimized 93 | }) 94 | )?) 95 | 96 | } else { 97 | 98 | Ok(hb.render( 99 | "address.handlebars", 100 | &json!({ 101 | "ui_title" : ge.cfg.ui_title, 102 | "address" : format!("0x{:x}",addr), 103 | "balance" : hr.ether(&balance,false), 104 | "txs" : txs, 105 | "txs_count" : count_addr_tx_links, 106 | "has_next_page": pg.next_page.is_some(), 107 | "next_page": pg.next_page.unwrap_or(0), 108 | "has_prev_page": pg.prev_page.is_some(), 109 | "prev_page": pg.prev_page.unwrap_or(0), 110 | "hascode" : true, 111 | "rawcode" : rawcode, 112 | "can_set_source" : true, 113 | "solcversions" : solcversions, 114 | }) 115 | )?) 116 | 117 | } 118 | 119 | } else { 120 | 121 | Ok(hb.render( 122 | "address.handlebars", 123 | &json!({ 124 | "ui_title" : ge.cfg.ui_title, 125 | "address" : format!("0x{:x}",addr), 126 | "balance" : hr.ether(&balance,false), 127 | "txs" : txs, 128 | "txs_count" : count_addr_tx_links, 129 | "has_next_page": pg.next_page.is_some(), 130 | "next_page": pg.next_page.unwrap_or(0), 131 | "has_prev_page": pg.prev_page.is_some(), 132 | "prev_page": pg.prev_page.unwrap_or(0), 133 | "hascode" : false, 134 | }) 135 | )?) 136 | } 137 | } -------------------------------------------------------------------------------- /src/explorer/block.rs: -------------------------------------------------------------------------------- 1 | use super::error::*; 2 | use super::html::*; 3 | use super::utils; 4 | 5 | use super::super::eth::BlockchainReader; 6 | use super::super::state::GlobalState; 7 | 8 | /// render the block page 9 | pub fn render( 10 | ge: &GlobalState, 11 | blockno: u64, 12 | ) -> Result { 13 | 14 | let mut hr = HtmlRender::new(&ge); 15 | let reader = BlockchainReader::new(&ge); 16 | let hb = &ge.hb; 17 | 18 | if let Some(block) = reader.block_with_txs(blockno)? { 19 | 20 | let author = utils::block_author(&ge.cfg,&block); 21 | let rawextra = hr.bytes(&block.extra_data.0,32); 22 | 23 | // get transactions 24 | 25 | let mut txs = Vec::new(); 26 | for tx in &block.transactions { 27 | if tx.to.is_some() { 28 | txs.push(hr.tx(&tx,&None)?); 29 | } else { 30 | let (tx,rcpt) = reader.tx(tx.hash)?.unwrap(); 31 | txs.push(hr.tx(&tx,&rcpt)?); 32 | } 33 | } 34 | 35 | // render 36 | 37 | Ok(hb.render( 38 | "block.handlebars", 39 | &json!({ 40 | "ui_title" : ge.cfg.ui_title, 41 | "blockno" : hr.blockno(blockno).text, 42 | "parent_hash" : block.parent_hash, 43 | "uncles_hash" : block.uncles_hash, 44 | "author" : hr.addr(&author), 45 | "state_root" : block.state_root, 46 | "receipts_root" : block.receipts_root, 47 | "gas_used" : block.gas_used.low_u64(), 48 | "gas_limit" : block.gas_limit.low_u64(), 49 | "extra_data" : rawextra, 50 | "timestamp" : hr.timestamp(&block.timestamp), 51 | "difficulty" : block.difficulty, 52 | "total_difficulty" : block.total_difficulty, 53 | "seal_fields" : block.seal_fields, 54 | "uncles" : block.uncles, 55 | "txs" : txs 56 | }), 57 | )?) 58 | } else { 59 | Err(Error::NotFound) 60 | } 61 | } -------------------------------------------------------------------------------- /src/explorer/error.rs: -------------------------------------------------------------------------------- 1 | use reqwest; 2 | use ethabi; 3 | 4 | use super::super::db; 5 | use super::super::eth; 6 | 7 | #[derive(Debug)] 8 | pub enum Error { 9 | Unexpected, 10 | NotFound, 11 | Handlebars(handlebars::RenderError), 12 | Reqwest(reqwest::Error), 13 | Eth(eth::Error), 14 | Io(std::io::Error), 15 | Db(db::Error), 16 | EthAbi(ethabi::Error), 17 | Contract(eth::contract::Error), 18 | } 19 | 20 | impl From for Error { 21 | fn from(err: handlebars::RenderError) -> Self { 22 | Error::Handlebars(err) 23 | } 24 | } 25 | impl From for Error { 26 | fn from(err: eth::Error) -> Self { 27 | Error::Eth(err) 28 | } 29 | } 30 | impl From for Error { 31 | fn from(err: reqwest::Error) -> Self { 32 | Error::Reqwest(err) 33 | } 34 | } 35 | impl From for Error { 36 | fn from(err: std::io::Error) -> Self { 37 | Error::Io(err) 38 | } 39 | } 40 | impl From for Error { 41 | fn from(err: db::Error) -> Self { 42 | Error::Db(err) 43 | } 44 | } 45 | impl From for Error { 46 | fn from(err: ethabi::Error) -> Self { 47 | Error::EthAbi(err) 48 | } 49 | } 50 | 51 | impl From for Error { 52 | fn from(err: eth::contract::Error) -> Self { 53 | Error::Contract(err) 54 | } 55 | } 56 | 57 | pub type Result = std::result::Result; 58 | 59 | -------------------------------------------------------------------------------- /src/explorer/home.rs: -------------------------------------------------------------------------------- 1 | use super::error::Error; 2 | use super::html::HtmlRender; 3 | use super::utils; 4 | 5 | use super::super::eth::BlockchainReader; 6 | use super::super::state::GlobalState; 7 | 8 | /// render home page 9 | pub fn render( 10 | ge: &GlobalState, 11 | page_no : u64, 12 | ) -> Result { 13 | 14 | let hr = HtmlRender::new(&ge); 15 | let reader = BlockchainReader::new(&ge); 16 | let hb = &ge.hb; 17 | let db = &ge.db; 18 | 19 | let last_blockno = reader.current_block_number()?; 20 | let mut blocks = Vec::new(); 21 | 22 | // get blocks 23 | 24 | let pg = utils::paginate(last_blockno,15,page_no); 25 | for n in pg.from..pg.to { 26 | let block_no = last_blockno - n; 27 | if let Some(block) = reader.block(block_no)? { 28 | let author = utils::block_author(&ge.cfg,&block); 29 | let gas_used_p = (100*block.gas_used.low_u64())/block.gas_limit.low_u64(); 30 | let gas_limit = block.gas_limit.low_u64() / 100_000; 31 | blocks.push(json!({ 32 | "block" : hr.blockno(block_no), 33 | "tx_count" : block.transactions.len(), 34 | "author" : hr.addr(&author), 35 | "timestamp" : hr.timestamp(&block.timestamp), 36 | "gas_used" : format!("{}%",gas_used_p), 37 | "gas_limit" : format!("{}.{}M",gas_limit/10,gas_limit%10) 38 | })); 39 | } else { 40 | return Err(Error::Unexpected); 41 | } 42 | } 43 | 44 | // render 45 | 46 | Ok(hb.render( 47 | "home.handlebars", 48 | &json!({ 49 | "ui_title" : ge.cfg.ui_title, 50 | "last_indexed_block" : db.get_next_block_to_scan().unwrap(), 51 | "blocks": blocks, 52 | "has_next_page": pg.next_page.is_some(), 53 | "next_page": pg.next_page.unwrap_or(0), 54 | "has_prev_page": pg.prev_page.is_some(), 55 | "prev_page": pg.prev_page.unwrap_or(0), 56 | }), 57 | )?) 58 | } -------------------------------------------------------------------------------- /src/explorer/html.rs: -------------------------------------------------------------------------------- 1 | use web3::types::{Address, H256, Transaction, TransactionReceipt, U256}; 2 | use rustc_hex::ToHex; 3 | use serde_derive::Serialize; 4 | use chrono::prelude::*; 5 | use std::collections::HashMap; 6 | use ethabi; 7 | 8 | use super::error::Result; 9 | 10 | use super::super::eth::types::InternalTx; 11 | use super::super::state::GlobalState; 12 | use super::super::eth::contract::ContractParser; 13 | 14 | const DATETIME_FORMAT : &str = "%Y-%m-%d %H:%M:%S"; 15 | 16 | lazy_static! { 17 | static ref GWEI: U256 = U256::from_dec_str("1000000000").unwrap(); 18 | static ref ETHER: U256 = U256::from_dec_str("1000000000000000000").unwrap(); 19 | static ref TENPOW5: U256 = U256::from(100_000); 20 | static ref TENPOW1: U256 = U256::from(10); 21 | } 22 | 23 | #[derive(Serialize)] 24 | pub struct TextWithLink { 25 | pub text: String, 26 | pub link: Option, 27 | } 28 | 29 | impl TextWithLink { 30 | fn new_link(text: String, link: String) -> Self { 31 | TextWithLink { 32 | text, 33 | link: Some(link), 34 | } 35 | } 36 | fn new_text(text: String) -> Self { 37 | TextWithLink { 38 | text, 39 | link: None, 40 | } 41 | } 42 | pub fn blank() -> Self { 43 | TextWithLink { 44 | text: "".to_string(), 45 | link: None, 46 | } 47 | } 48 | } 49 | 50 | pub struct HtmlRender<'a> { 51 | ge : &'a GlobalState, 52 | parser : ContractParser, 53 | parsed : HashMap, 54 | 55 | } 56 | 57 | impl<'a> HtmlRender<'a> { 58 | 59 | pub fn new(ge :&'a GlobalState) -> HtmlRender<'a> { 60 | HtmlRender { 61 | ge, 62 | parser : ContractParser::new(), 63 | parsed : HashMap::new(), 64 | } 65 | } 66 | 67 | /// render an address 68 | pub fn addr(&self, addr : &Address) -> TextWithLink { 69 | TextWithLink::new_link( 70 | self.ge.named_address.get(addr).unwrap_or(&format!("0x{:x}", addr)).to_string(), 71 | format!("/0x{:x}", addr) 72 | ) 73 | } 74 | 75 | /// render an address or show a text 76 | pub fn addr_or(&self, optaddr : &Option
, or : &str) -> TextWithLink { 77 | if let Some(addr) = optaddr { 78 | self.addr(&addr) 79 | } else { 80 | TextWithLink::new_text(or.to_string()) 81 | } 82 | } 83 | 84 | /// render byte array chunked 85 | pub fn bytes(&self, bytes : &[u8], chunk_size: usize) -> Vec { 86 | bytes.chunks(chunk_size) 87 | .map(|c| c.to_hex::()) 88 | .collect() 89 | } 90 | 91 | /// render a transaction hash 92 | pub fn txid(&self, txid : &H256) -> TextWithLink { 93 | TextWithLink::new_link( 94 | format!("{:x}", txid), 95 | format!("/0x{:x}", txid), 96 | ) 97 | } 98 | 99 | /// render a block number 100 | pub fn blockno(&self, no : u64) -> TextWithLink { 101 | TextWithLink::new_link(format!("{}", no), format!("/{}", no)) 102 | } 103 | 104 | /// render gigaweis 105 | pub fn gwei(&self, wei : &U256, short : bool) -> String { 106 | let m = ((wei * *TENPOW1) / *GWEI).low_u64(); 107 | if short { 108 | format!("{}.{}", m/10,m%10) 109 | } else { 110 | format!("{}.{} GWei", m/10,m%10) 111 | } 112 | } 113 | 114 | /// render ether amount 115 | pub fn ether(&self, wei : &U256, short: bool) -> String { 116 | if *wei == U256::zero() { 117 | String::from("0 Ξ") 118 | } else if short { 119 | let tenmilliethers = (wei * *TENPOW5) / *ETHER; 120 | let div = TENPOW5.as_u64() as f64; 121 | if tenmilliethers.low_u64() > 0 { 122 | format!("{} Ξ", tenmilliethers.as_u64() as f64 / div) 123 | } else { 124 | String::from(">0.0001 Ξ") 125 | } 126 | } else { 127 | let ether = wei / *ETHER; 128 | let mut remain = wei % *ETHER; 129 | while remain > U256::zero() && remain % 10 == U256::zero() { 130 | remain /= 10; 131 | } 132 | format!("{}.{} Ξ", ether, remain) 133 | } 134 | } 135 | 136 | /// render a timestamp 137 | pub fn timestamp(&self, sec1970 : &U256) -> String { 138 | let dt = Utc.timestamp(sec1970.low_u64() as i64, 0); 139 | format!("{}",dt.format(DATETIME_FORMAT)) 140 | } 141 | 142 | /// render a transaction 143 | pub fn tx(&mut self,tx: &Transaction, rcpt: &Option) -> Result { 144 | 145 | let shortdata = if let Some(to) = tx.to { 146 | if self.register_contract(&to)? { 147 | let callinfo = self.parser.tx_funcparams(&to, &tx.input.0,false)?; 148 | callinfo.func.to_string() 149 | } else { 150 | tx.input.0.to_hex::() 151 | .chars().take(8).collect::() 152 | } 153 | } else { 154 | String::from("") 155 | }; 156 | 157 | let (to_link,to_label) = if let Some(to) = tx.to { 158 | (self.addr(&to),"") 159 | } else if let Some(rcpt) = rcpt { 160 | (self.addr_newcontract(&rcpt.contract_address.unwrap()),"") 161 | } else { 162 | (TextWithLink::blank(),"New contract") 163 | }; 164 | 165 | Ok(json!({ 166 | "type" : "EXT", 167 | "gas_price" : self.gwei(&tx.gas_price,true), 168 | "blockno" : self.blockno(tx.block_number.unwrap().low_u64()), 169 | "tx" : self.txid(&tx.hash), 170 | "from" : self.addr(&tx.from), 171 | "to_link" : to_link, 172 | "to_label" : to_label, 173 | "shortdata" : shortdata, 174 | "value" : self.ether(&tx.value,true) 175 | })) 176 | } 177 | 178 | /// render an address that is a contract 179 | fn addr_newcontract(&self, addr: &Address) -> TextWithLink { 180 | let mut twl = self.addr(&addr); 181 | twl.text = format!("🆕 {}",twl.text); 182 | twl 183 | } 184 | 185 | /// render an address that is a destination or a new contract (from a tx) 186 | fn addr_to(&self, to: &Option
, contract: &Option
) -> TextWithLink { 187 | if let Some(to) = to { 188 | self.addr(&to) 189 | } else { 190 | self.addr_newcontract(&contract.unwrap()) 191 | } 192 | } 193 | 194 | /// render an internal transaction 195 | pub fn tx_itx(&mut self,tx: &Transaction, itx: &InternalTx) -> Result { 196 | 197 | let shortdata = if let Some(to) = itx.to { 198 | if self.register_contract(&to)? { 199 | let callinfo = self.parser.tx_funcparams(&to, &itx.input,false)?; 200 | callinfo.func.to_string() 201 | } else { 202 | itx.input.to_hex::() 203 | .chars().take(8).collect::() 204 | } 205 | } else { 206 | String::from("") 207 | }; 208 | 209 | Ok(json!({ 210 | "type" : "int", 211 | "blockno" : self.blockno(tx.block_number.unwrap().low_u64()), 212 | "tx" : self.txid(&tx.hash), 213 | "from" : self.addr(&itx.from), 214 | "to_link" : self.addr_to(&itx.to,&itx.contract), 215 | "shortdata" : shortdata, 216 | "value" : self.ether(&itx.value,true) 217 | })) 218 | } 219 | 220 | /// render a tx call 221 | pub fn tx_abi_call(&mut self, addr: &Address, input: &[u8]) -> Result>> { 222 | if self.register_contract(addr)? { 223 | let callinfo = self.parser.tx_funcparams(addr, input,true)?; 224 | 225 | let mut out = Vec::new(); 226 | out.push(format!("function {}",&callinfo.func)); 227 | 228 | if !callinfo.params.is_empty() { 229 | let max_param_length = callinfo.params.iter().map(|p| p.0.len()).max().unwrap(); 230 | 231 | for (name,value) in callinfo.params { 232 | let padding = (name.len()..max_param_length) 233 | .map(|_| " ").collect::(); 234 | let token = self.abi_token(&value); 235 | out.push(format!(" [{}{}] {}",name,padding,token)); 236 | } 237 | } 238 | Ok(Some(out)) 239 | } else { 240 | Ok(None) 241 | } 242 | } 243 | 244 | /// render a tx log 245 | pub fn tx_abi_log(&mut self, addr: &Address, txlog: web3::types::Log) -> Result>> { 246 | if self.register_contract(addr)? { 247 | let (name,log) = self.parser.log_eventparams(txlog)?; 248 | 249 | let mut out = Vec::new(); 250 | out.push(format!("event {}",&name)); 251 | 252 | if !log.params.is_empty() { 253 | let max_param_length = log.params.iter().map(|p| p.name.len()).max().unwrap(); 254 | for param in log.params { 255 | let padding = (param.name.len()..max_param_length) 256 | .map(|_| " ").collect::(); 257 | let token = self.abi_token(¶m.value); 258 | out.push(format!(" [{}{}] {}",param.name,padding,token)); 259 | } 260 | } 261 | Ok(Some(out)) 262 | } else { 263 | Ok(None) 264 | } 265 | } 266 | 267 | /// render a token (basic ethereum type) 268 | fn abi_token(&self, token : ðabi::Token) -> String { 269 | match token { 270 | ethabi::Token::Address(v) => 271 | format!("0x{:x}",v), 272 | 273 | ethabi::Token::Int(v) | ethabi::Token::Uint(v) => 274 | format!("{:} (0x{:x})",v,v), 275 | 276 | ethabi::Token::Bool(v) => 277 | format!("{:}",v), 278 | 279 | ethabi::Token::FixedBytes(v) | ethabi::Token::Bytes(v) => 280 | format!("0x{}",v.to_hex::()), 281 | 282 | _ => 283 | format!("{:?}",token) 284 | } 285 | } 286 | 287 | /// check if is a contract and has an abi defined 288 | fn register_contract(&mut self, addr: &Address) -> Result { 289 | if !self.parsed.contains_key(addr) { 290 | self.parsed.insert(*addr, true); 291 | if let Some(contract) = self.ge.db.get_contract(&addr)? { 292 | self.parser.add(*addr, &contract.abi)?; 293 | Ok(true) 294 | } else { 295 | Ok(false) 296 | } 297 | } else { 298 | Ok(self.parser.contains(addr)) 299 | } 300 | } 301 | } 302 | -------------------------------------------------------------------------------- /src/explorer/mod.rs: -------------------------------------------------------------------------------- 1 | mod address; 2 | mod block; 3 | mod error; 4 | mod home; 5 | mod html; 6 | mod tx; 7 | mod neb; 8 | mod utils; 9 | mod server; 10 | 11 | pub use self::server::start_explorer; -------------------------------------------------------------------------------- /src/explorer/neb.rs: -------------------------------------------------------------------------------- 1 | use super::error::{Error,Result}; 2 | use super::html::HtmlRender; 3 | use super::utils; 4 | 5 | use super::super::state::GlobalState; 6 | use super::super::eth::BlockchainReader; 7 | 8 | /// render the non-empty-blocks page 9 | pub fn render( 10 | ge: &GlobalState, 11 | page_no : u64, 12 | ) -> Result { 13 | 14 | let hr = HtmlRender::new(&ge); 15 | let reader = BlockchainReader::new(&ge); 16 | let db = &ge.db; 17 | let hb = &ge.hb; 18 | 19 | let mut blocks = Vec::new(); 20 | 21 | let count_non_empty_blocks = db.count_non_empty_blocks()?; 22 | let limit = if count_non_empty_blocks > 200 { 23 | 200 24 | } else { 25 | count_non_empty_blocks 26 | }; 27 | let pg = utils::paginate(limit,15,page_no); 28 | 29 | if pg.from <= pg.to { 30 | let it = db.iter_non_empty_blocks()?.skip(pg.from as usize); 31 | for n in it.take((pg.to-pg.from) as usize) { 32 | if let Some(block) = reader.block(n)? { 33 | let author = utils::block_author(&ge.cfg,&block); 34 | let gas_used_p = (100*block.gas_used.low_u64())/block.gas_limit.low_u64(); 35 | let gas_limit = block.gas_limit.low_u64() / 100_000; 36 | blocks.push(json!({ 37 | "block" : hr.blockno(n), 38 | "author" : hr.addr(&author), 39 | "tx_count" : block.transactions.len(), 40 | "timestamp" : hr.timestamp(&block.timestamp), 41 | "gas_used" : format!("{}%",gas_used_p), 42 | "gas_limit" : format!("{}.{}M",gas_limit/10,gas_limit%10) 43 | })); 44 | } else { 45 | return Err(Error::Unexpected); 46 | } 47 | } 48 | } 49 | 50 | Ok(hb.render( 51 | "neb.handlebars", 52 | &json!({ 53 | "ui_title" : ge.cfg.ui_title, 54 | "last_indexed_block" : db.get_next_block_to_scan().unwrap(), 55 | "blocks": blocks, 56 | "has_next_page": pg.next_page.is_some(), 57 | "next_page": pg.next_page.unwrap_or(0), 58 | "has_prev_page": pg.prev_page.is_some(), 59 | "prev_page": pg.prev_page.unwrap_or(0), 60 | }), 61 | )?) 62 | } 63 | -------------------------------------------------------------------------------- /src/explorer/server.rs: -------------------------------------------------------------------------------- 1 | #![cfg_attr(feature = "cargo-clippy", allow(clippy::mem_replace_option_with_none))] 2 | 3 | use std::sync::Arc; 4 | use web3::types::{Address,H256}; 5 | use rouille::{Request,Response}; 6 | 7 | use super::super::state::GlobalState; 8 | use super::super::bootstrap::get_resource; 9 | 10 | use super::super::eth::{ 11 | BlockchainReader, 12 | contract::{verify_abi,compile_and_verify,ONLY_ABI} 13 | }; 14 | 15 | use super::super::eth::types::{hex_to_addr,hex_to_h256}; 16 | use super::super::db; 17 | 18 | #[derive(Serialize)] 19 | pub enum Id { 20 | Addr(Address), 21 | Tx(H256), 22 | Block(u64), 23 | } 24 | 25 | impl Id { 26 | pub fn from(id: &str) -> Option { 27 | if id.len() == 42 /* address */ 28 | { 29 | hex_to_addr(id).map(Id::Addr).ok() 30 | } else if id.len() == 66 /* tx */ 31 | { 32 | hex_to_h256(id).map(Id::Tx).ok() 33 | } else if let Ok(blockno_u64) = id.parse::() { 34 | Some(Id::Block(blockno_u64)) 35 | } else { 36 | None 37 | } 38 | } 39 | } 40 | 41 | pub fn error_page(innerhtml: &str) -> String { 42 | let mut html = String::from(""); 43 | html.push_str(""); 44 | html.push_str(&innerhtml.replace(" ", " ").replace("_", " ")); 45 | html.push_str(""); 46 | html 47 | } 48 | 49 | fn get_home(request: &Request, ge: &GlobalState) -> Response { 50 | let page_no = request.get_param("p").unwrap_or_else(|| "0".to_string()).parse::(); 51 | if let Ok(page_no) = page_no { 52 | Response::html( 53 | match super::home::render(&ge,page_no) { 54 | Ok(html) => html, 55 | Err(err) => error_page(format!("Error: {:?}", err).as_str()) 56 | } 57 | ) 58 | } else { 59 | Response::html(error_page("invalid parameter")) 60 | } 61 | } 62 | 63 | fn get_object(request: &Request,ge: &GlobalState, id: &str) -> Response { 64 | 65 | if id == "neb" { 66 | let page_no = request.get_param("p").unwrap_or_else(|| "0".to_string()).parse::().unwrap(); 67 | let html = super::neb::render(&ge,page_no); 68 | Response::html(match html { 69 | Ok(html) => html, 70 | Err(err) => error_page(format!("Error: {:?}", err).as_str()) 71 | }) 72 | } else if let Some(id) = Id::from(&id) { 73 | let page_no = request.get_param("p").unwrap_or_else(|| "0".to_string()).parse::().unwrap(); 74 | let html = match id { 75 | Id::Addr(addr) => super::address::render(&ge,&addr,page_no), 76 | Id::Tx(txid) => super::tx::render(&ge,txid), 77 | Id::Block(block) => super::block::render(&ge,block) 78 | }; 79 | Response::html(match html { 80 | Ok(html) => html, 81 | Err(err) => error_page(format!("Error: {:?}", err).as_str()) 82 | }) 83 | } else { 84 | Response::html(error_page("Not found")) 85 | } 86 | } 87 | 88 | fn post_contract( 89 | ge: &GlobalState, 90 | id: &str, 91 | contract_source: &str, 92 | contract_compiler: &str, 93 | contract_optimized: bool, 94 | contract_name: &str 95 | 96 | ) -> Response { 97 | 98 | if let Some(Id::Addr(addr)) = Id::from(&id) { 99 | let reader = BlockchainReader::new(&ge); 100 | 101 | let code = reader.current_code(&addr).expect("failed to read contract code").0; 102 | 103 | let contractentry = db::Contract{ 104 | source : contract_source.to_string(), 105 | compiler : contract_compiler.to_string(), 106 | optimized: contract_optimized, 107 | name : contract_name.to_string(), 108 | constructor : Vec::new(), 109 | abi : if ge.cfg.solc_bypass && contract_compiler==ONLY_ABI { 110 | verify_abi(contract_source).expect("cannot verify abi"); 111 | contract_source.to_string() 112 | } else { 113 | compile_and_verify(&ge.cfg, 114 | &contract_source, 115 | &contract_name, 116 | &contract_compiler, 117 | contract_optimized, 118 | &code 119 | ).expect("cannot verify contract code") 120 | } 121 | }; 122 | ge.db.set_contract(&addr,&contractentry).expect("cannot update db"); 123 | 124 | Response::redirect_302(format!("/{}",id)) 125 | } else { 126 | Response::html(error_page("bad input")) 127 | } 128 | } 129 | 130 | pub fn start_explorer(gs: Arc) { 131 | 132 | rouille::start_server(gs.cfg.bind.clone(), move |request| router!(request, 133 | (GET) (/) => { 134 | get_home(&request,&gs) 135 | }, 136 | (GET) (/s/{name: String}) => { 137 | if let Some(res) = get_resource(&name) { 138 | rouille::Response::from_data("", res) 139 | } else { 140 | rouille::Response::empty_404() 141 | } 142 | }, 143 | (GET) (/{id: String}) => { 144 | get_object(&request,&gs,&id) 145 | }, 146 | (POST) (/{id: String}/contract) => { 147 | let data = try_or_400!(post_input!(request, { 148 | contract_source: String, 149 | contract_compiler: String, 150 | contract_optimized: bool, 151 | contract_name: String, 152 | })); 153 | post_contract(&gs, &id, 154 | &data.contract_source, &data.contract_compiler, 155 | data.contract_optimized, &data.contract_name 156 | ) 157 | }, 158 | _ => rouille::Response::empty_404() 159 | )); 160 | 161 | } 162 | -------------------------------------------------------------------------------- /src/explorer/tx.rs: -------------------------------------------------------------------------------- 1 | use web3::types::H256; 2 | 3 | use super::error::*; 4 | use super::html::*; 5 | 6 | use super::super::eth::{BlockchainReader}; 7 | use super::super::state::GlobalState; 8 | 9 | /// render the transaction page 10 | pub fn render( 11 | ge: &GlobalState, 12 | txid: H256) -> Result { 13 | 14 | let mut hr = HtmlRender::new(&ge); 15 | let reader = BlockchainReader::new(&ge); 16 | let hb = &ge.hb; 17 | 18 | if let Some((tx, receipt)) = reader.tx(txid)? { 19 | 20 | let mut logs = Vec::new(); 21 | let mut cumulative_gas_used = String::from(""); 22 | let mut gas_used = String::from(""); 23 | let mut contract_address = TextWithLink::blank(); 24 | let mut status = String::from(""); 25 | 26 | if let Some(receipt) = receipt { 27 | 28 | cumulative_gas_used = format!("{}", receipt.cumulative_gas_used.low_u64()); 29 | gas_used = format!("{}", receipt.gas_used.unwrap().low_u64()); 30 | 31 | if let Some(contract) = receipt.contract_address { 32 | contract_address = hr.addr(&contract); 33 | } 34 | 35 | status = receipt.status.map_or( 36 | "".to_string(), 37 | |x| if x.as_u64() == 1 { "Success".to_string() } else { "Failed".to_string() } 38 | ); 39 | 40 | for (_, log) in receipt.logs.into_iter().enumerate() { 41 | 42 | let mut txt = Vec::new(); 43 | 44 | if let Some(loginfo) = hr.tx_abi_log(&log.address,log.clone())? { 45 | txt.extend_from_slice(&loginfo); 46 | txt.push(String::from("")); 47 | } else { 48 | txt.push("data".to_string()); 49 | for ll in hr.bytes(&log.data.0,50) { 50 | txt.push(format!(" {}",ll)); 51 | } 52 | 53 | txt.push("topics".to_string()); 54 | for (t, topic) in log.topics.into_iter().enumerate() { 55 | txt.push(format!(" [{}] {:?}",t,topic)); 56 | } 57 | } 58 | 59 | logs.push(json!({ 60 | "address" : hr.addr(&log.address), 61 | "txt" : txt, 62 | })); 63 | } 64 | } 65 | 66 | // log_to_string 67 | let mut input: Vec = Vec::new(); 68 | if let Some(to) = tx.to { 69 | 70 | if let Some(callinfo) = hr.tx_abi_call(&to,&tx.input.0)? { 71 | input.extend_from_slice(&callinfo); 72 | input.push(String::from("")); 73 | } 74 | 75 | let inputvec = hr.bytes(&tx.input.0,50); 76 | input.extend_from_slice(&inputvec); 77 | } 78 | 79 | // internal transactions 80 | let itxs : Result>= reader.itx(&tx)? 81 | .into_iter() 82 | .map(|itx| hr.tx_itx(&tx,&itx)) 83 | .collect(); 84 | 85 | // render page 86 | Ok(hb.render( 87 | "tx.handlebars", 88 | &json!({ 89 | "ui_title" : ge.cfg.ui_title, 90 | "txhash" : format!("0x{:x}",txid), 91 | "from" : hr.addr(&tx.from), 92 | "tonewcontract" : tx.to.is_none(), 93 | "to" : hr.addr_or(&tx.to,"New contract"), 94 | "value" : hr.ether(&tx.value,true), 95 | "block" : hr.blockno(tx.block_number.unwrap().low_u64()), 96 | "gas" : tx.gas.low_u64(), 97 | "gas_price" : hr.gwei(&tx.gas_price,false), 98 | "cumulative_gas_used" : cumulative_gas_used, 99 | "gas_used" : gas_used, 100 | "contract_address" : contract_address, 101 | "status" : status, 102 | "input" : input, 103 | "logs" : logs, 104 | "itxs" : itxs?, 105 | }), 106 | )?) 107 | } else { 108 | Err(Error::NotFound) 109 | } 110 | } -------------------------------------------------------------------------------- /src/explorer/utils.rs: -------------------------------------------------------------------------------- 1 | use web3::types::{Address,Block,H160}; 2 | 3 | use super::super::bootstrap::{Config,GETH_CLIQUE,GETH_POW,GETH_AUTO}; 4 | use super::super::eth::geth::clique; 5 | 6 | #[derive(Debug)] 7 | pub struct Pagination { 8 | pub from : u64, 9 | pub to : u64, 10 | pub prev_page : Option, 11 | pub next_page : Option, 12 | } 13 | 14 | /// calc the pagination for a set of results 15 | pub fn paginate( max : u64, page_size : u64, page_no : u64 ) -> Pagination { 16 | let from = page_no*page_size; 17 | let to = if (page_no+1)*page_size > max { 18 | max 19 | } else { 20 | (page_no+1)*page_size 21 | }; 22 | let prev_page = if page_no > 0 { 23 | Some(page_no-1) 24 | } else { 25 | None 26 | }; 27 | let next_page = if to < max { 28 | Some(page_no+1) 29 | } else { 30 | None 31 | }; 32 | Pagination{from,to,prev_page,next_page} 33 | } 34 | 35 | /// get the author of a block 36 | pub fn block_author(cfg: &Config, block: &Block) -> Address { 37 | 38 | let client = if cfg.web3_client == GETH_AUTO { 39 | if block.author == H160::default() { 40 | GETH_CLIQUE 41 | } else { 42 | GETH_POW 43 | } 44 | } else { 45 | &cfg.web3_client 46 | }; 47 | 48 | if client == GETH_CLIQUE { 49 | clique::parse_clique_header(&block).unwrap() 50 | } else { 51 | block.author 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | #[macro_use] 2 | extern crate rust_embed; 3 | #[macro_use] 4 | extern crate lazy_static; 5 | #[macro_use] 6 | extern crate serde_json; 7 | #[macro_use] 8 | extern crate serde_derive; 9 | #[macro_use] 10 | extern crate rouille; 11 | #[macro_use] 12 | extern crate log; 13 | extern crate structopt; 14 | 15 | extern crate stderrlog; 16 | extern crate ctrlc; 17 | extern crate handlebars; 18 | extern crate rand; 19 | extern crate rocksdb; 20 | extern crate rustc_hex; 21 | extern crate serde; 22 | extern crate serde_cbor; 23 | extern crate toml; 24 | extern crate web3; 25 | extern crate ethabi; 26 | extern crate reqwest; 27 | extern crate rlp; 28 | extern crate chrono; 29 | extern crate keccak_hash; 30 | extern crate ethkey; 31 | 32 | mod db; 33 | mod explorer; 34 | mod scrapper; 35 | mod state; 36 | mod bootstrap; 37 | mod eth; 38 | 39 | use std::sync::atomic::Ordering; 40 | use std::sync::Arc; 41 | use std::thread; 42 | 43 | use structopt::StructOpt; 44 | 45 | /// A StructOpt example 46 | #[derive(StructOpt, Debug)] 47 | #[structopt()] 48 | struct Opt { 49 | /// Verbose mode (-v, -vv, -vvv, etc) 50 | #[structopt(short = "v", long = "verbose", parse(from_occurrences))] 51 | verbose: usize, 52 | 53 | /// Timestamp (sec, ms, ns, none) 54 | #[structopt(short = "t", long = "timestamp")] 55 | ts: Option, 56 | 57 | /// Timestamp (sec, ms, ns, none) 58 | #[structopt(short = "cfg", long = "cfg")] 59 | cfg: String, 60 | } 61 | 62 | fn main() { 63 | 64 | // load cmdline parameters 65 | 66 | let opt = Opt::from_args(); 67 | stderrlog::new() 68 | .module(module_path!()) 69 | .verbosity(opt.verbose) 70 | .timestamp(opt.ts.unwrap_or(stderrlog::Timestamp::Off)) 71 | .init() 72 | .unwrap(); 73 | 74 | // load configuration 75 | let cfg = bootstrap::Config::read(&opt.cfg) 76 | .expect("cannot read config"); 77 | 78 | // create the (arc) global state 79 | let globalstate = Arc::new(state::GlobalState::new(cfg).unwrap()); 80 | 81 | // start scrap the blockchain (if requiered) 82 | if globalstate.cfg.scan { 83 | let shared_ge_scan = globalstate.clone(); 84 | thread::spawn(move || scrapper::start_scrapper(&shared_ge_scan)); 85 | } 86 | 87 | // set the control-c handler 88 | let shared_ge_controlc = globalstate.clone(); 89 | ctrlc::set_handler(move || { 90 | info!("Got Ctrl-C handler signal. Stopping..."); 91 | shared_ge_controlc.stop_signal.store(true, Ordering::SeqCst); 92 | if !shared_ge_controlc.cfg.scan { 93 | std::process::exit(0); 94 | } 95 | }) 96 | .expect("Error setting Ctrl-C handler"); 97 | 98 | // start the http server 99 | info!("Lisening to {}...", &globalstate.cfg.bind.clone()); // TODO: remove clones 100 | 101 | //let shared_ge_explorer = shared_ge.0.clone(); 102 | explorer::start_explorer(globalstate); 103 | 104 | } -------------------------------------------------------------------------------- /src/scrapper/error.rs: -------------------------------------------------------------------------------- 1 | use db; 2 | use std::io; 3 | 4 | #[derive(Debug)] 5 | pub enum Error { 6 | Web3(web3::Error), 7 | DB(db::Error), 8 | FromHex(rustc_hex::FromHexError), 9 | EthAbi(ethabi::Error), 10 | SerdeJson(serde_json::Error), 11 | Io(std::io::Error), 12 | Time(std::time::SystemTimeError), 13 | } 14 | 15 | impl From for Error { 16 | fn from(err: io::Error) -> Self { 17 | Error::Io(err) 18 | } 19 | } 20 | impl From for Error { 21 | fn from(err: rustc_hex::FromHexError) -> Self { 22 | Error::FromHex(err) 23 | } 24 | } 25 | impl From for Error { 26 | fn from(err: ethabi::Error) -> Self { 27 | Error::EthAbi(err) 28 | } 29 | } 30 | 31 | impl From for Error { 32 | fn from(err: serde_json::Error) -> Self { 33 | Error::SerdeJson(err) 34 | } 35 | } 36 | 37 | impl From for Error { 38 | fn from(err: web3::Error) -> Self { 39 | Error::Web3(err) 40 | } 41 | } 42 | impl From for Error { 43 | fn from(err: db::Error) -> Self { 44 | Error::DB(err) 45 | } 46 | } 47 | impl From for Error { 48 | fn from(err: std::time::SystemTimeError) -> Self { 49 | Error::Time(err) 50 | } 51 | } 52 | 53 | 54 | 55 | pub type Result = std::result::Result; 56 | 57 | -------------------------------------------------------------------------------- /src/scrapper/mod.rs: -------------------------------------------------------------------------------- 1 | mod scrap; 2 | mod error; 3 | 4 | pub use self::scrap::start_scrapper; -------------------------------------------------------------------------------- /src/scrapper/scrap.rs: -------------------------------------------------------------------------------- 1 | use state::{GlobalState, Web3Client}; 2 | use std::sync::atomic::Ordering; 3 | use std::{thread, time}; 4 | use std::time::{Duration, SystemTime}; 5 | 6 | use web3::futures::Future; 7 | use web3::types::{BlockId, BlockNumber, Transaction}; 8 | 9 | use eth::geth; 10 | 11 | use super::super::eth::types::*; 12 | use super::error::Result; 13 | 14 | /// scan the blockchain 15 | fn scrap_blocks(gs: &GlobalState, wc: &Web3Client) -> Result<()>{ 16 | 17 | // get next block to scan 18 | let mut next_block = gs.db.get_next_block_to_scan()?.unwrap(); 19 | 20 | if let Some(cfg_start_block) = gs.cfg.scan_start_block { 21 | if cfg_start_block > next_block { 22 | next_block = cfg_start_block; 23 | } 24 | } 25 | 26 | // loop until last block number or stop_signal 27 | let mut last_output = SystemTime::UNIX_EPOCH; 28 | let until_block = wc.web3.eth().block_number().wait()?.low_u64(); 29 | while next_block <= until_block && !gs.stop_signal.load(Ordering::SeqCst) { 30 | 31 | // show progress 32 | if SystemTime::now().duration_since(last_output)? > Duration::from_secs(5) { 33 | let progress = (next_block * 1000) / until_block; 34 | info!( 35 | "Adding block {}/{} ({}‰)...", 36 | next_block, until_block, progress 37 | ); 38 | last_output = SystemTime::now(); 39 | } 40 | 41 | // read block and with its transactions 42 | let block = wc 43 | .web3 44 | .eth() 45 | .block_with_txs(BlockId::Number(BlockNumber::Number(next_block))) 46 | .wait()? 47 | .unwrap(); 48 | 49 | // process each transaction 50 | for tx in &block.transactions { 51 | 52 | // read transaction receipt 53 | let re = wc.web3.eth().transaction_receipt(tx.hash).wait()?.unwrap(); 54 | 55 | // read internal transactions 56 | if gs.cfg.db_store_itx && gs.cfg.web3_itx { 57 | let dbg : geth::web3::Debug<_> = wc.web3.api(); 58 | let itxs = dbg.internal_txs(&tx).wait()?.parse()?; 59 | gs.db.add_tx(&tx, &re, Some(&itxs))?; 60 | } else { 61 | gs.db.add_tx(&tx, &re, None)?; 62 | }; 63 | } 64 | 65 | // write to the db the receieved data 66 | gs.db 67 | .add_block(&into_block(block, |tx: Transaction| tx.hash))?; 68 | 69 | // process next block 70 | next_block += 1; 71 | gs.db.set_next_block_to_scan(next_block)?; 72 | } 73 | Ok(()) 74 | } 75 | 76 | /// scan the blockchain until the stop_signal is recieved 77 | pub fn start_scrapper(gs: &GlobalState) { 78 | let wc = gs.new_web3client(); 79 | 80 | while !gs.stop_signal.load(Ordering::SeqCst) { 81 | thread::sleep(time::Duration::from_secs(5)); 82 | if let Err(err) = scrap_blocks(&gs, &wc) { 83 | error!("Scan result failed: {:?}", err); 84 | } 85 | } 86 | 87 | info!("Finished scanning transactions, self-killing."); 88 | std::process::exit(0); 89 | } 90 | -------------------------------------------------------------------------------- /src/state.rs: -------------------------------------------------------------------------------- 1 | #![cfg_attr(feature = "cargo-clippy", allow(clippy::new_ret_no_self))] 2 | 3 | use db; 4 | 5 | use std::collections::HashMap; 6 | use web3::types::{Address}; 7 | use std::sync::atomic::AtomicBool; 8 | use bootstrap::{Config,load_handlebars_templates}; 9 | use handlebars::Handlebars; 10 | use eth::types::hex_to_addr; 11 | use web3::futures::Future; 12 | 13 | #[derive(Debug)] 14 | pub enum Error { 15 | Web3(web3::Error), 16 | FromHex(rustc_hex::FromHexError), 17 | } 18 | 19 | impl From for Error { 20 | fn from(err: web3::Error) -> Self { 21 | Error::Web3(err) 22 | } 23 | } 24 | impl From for Error { 25 | fn from(err: rustc_hex::FromHexError) -> Self { 26 | Error::FromHex(err) 27 | } 28 | } 29 | 30 | pub type Result = std::result::Result; 31 | 32 | pub struct GlobalState { 33 | pub stop_signal: AtomicBool, 34 | pub db: db::AppDB, 35 | pub cfg: Config, 36 | pub hb: Handlebars, 37 | pub named_address : HashMap, 38 | } 39 | 40 | pub struct Web3Client { 41 | pub eloop: web3::transports::EventLoopHandle, 42 | pub web3: web3::Web3, 43 | } 44 | 45 | impl GlobalState { 46 | 47 | pub fn new(cfg: Config) -> Result { 48 | 49 | let transport = web3::transports::Http::new(cfg.web3_url.as_str())?; 50 | let web3 = web3::Web3::new(transport.1); 51 | let network_id = web3.net().version().wait()?; 52 | info!("Network id is {}",network_id); 53 | 54 | let mut hb = Handlebars::new(); 55 | load_handlebars_templates(&mut hb); 56 | 57 | // create global stop signal 58 | let stop_signal = AtomicBool::new(false); 59 | 60 | // load database & init if not 61 | let db = db::AppDB::open_default( 62 | &format!("{}{}",cfg.db_path,network_id), 63 | db::Options { 64 | store_itx : cfg.db_store_itx, 65 | store_tx : cfg.db_store_tx, 66 | store_addr : cfg.db_store_addr, 67 | store_neb : cfg.db_store_neb, 68 | } 69 | ).expect("cannot open database"); 70 | 71 | // set the last block if not set 72 | if None == db.get_next_block_to_scan().expect("error reading last block") { 73 | db.set_next_block_to_scan(cfg.scan_start_block.unwrap_or(1)) 74 | .expect("error setting last block"); 75 | } 76 | 77 | // read named addresses 78 | let mut named_address = HashMap::new(); 79 | if let Some(nas) = &cfg.named_address { 80 | for na in nas { 81 | named_address.insert(hex_to_addr(&na.address)?, na.name.clone()); 82 | } 83 | } 84 | 85 | Ok(GlobalState { cfg, db, hb, stop_signal, named_address }) 86 | } 87 | pub fn new_web3client(&self) -> Web3Client { 88 | let (eloop, transport) = web3::transports::Http::new(self.cfg.web3_url.as_str()) 89 | .expect("opening http connection"); 90 | 91 | Web3Client { 92 | eloop, 93 | web3: web3::Web3::new(transport), 94 | } 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /static/tmpl/address.handlebars: -------------------------------------------------------------------------------- 1 | {{ > header.handlebars }} 2 | 3 |
Address {{ address }}
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
Balance{{balance}}
12 | 13 | {{#if txs}} 14 |
Transactions ({{ txs_count }}) 15 | {{#if has_prev_page}} 16 | 17 | {{else}} 18 | 19 | {{/if}} 20 | {{#if has_next_page}} 21 | 22 | {{else}} 23 | 24 | {{/if}} 25 |
26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | {{#each txs}} 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | {{/each}} 48 | 49 |
BlockTxTypeFromToValueData
{{blockno.text}}{{tx.text}}{{type}}{{from.text}}{{to_label.link}}{{to_link.text}}{{value.text}}{{shortdata}}
50 | {{/if}} 51 | 52 | {{ #if hascode }} 53 | 54 |
Contract
55 | 56 |
57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 |
65 |
66 | 67 | 68 | {{ #if can_set_source }} 69 | 70 | 86 | 87 |
88 | 89 | 91 | 92 | 93 | 96 | 102 | 105 | 106 |
94 | 95 | 97 | 101 | 103 | 104 |
107 |
108 | 109 | 110 | 111 | 112 | 113 | 114 |
Optimized
115 |
116 | 117 |
118 | 119 | {{ else }} 120 | 121 | Compiler version {{ contract_compiler }}, optimized {{ contract_optimized }}
122 | Contract name {{ contract_name }}
123 |
125 | 126 | {{ /if }} 127 | 128 | 129 |
130 |
131 | 132 | 135 | 136 |
137 |
138 | 139 | 140 |
141 | {{ /if }} 142 | 143 | 144 | {{ > footer.handlebars }} -------------------------------------------------------------------------------- /static/tmpl/block.handlebars: -------------------------------------------------------------------------------- 1 | {{ > header.handlebars }} 2 | 3 |
Block #{{ blockno }}
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 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 |
Parent hash{{parent_hash}}
Uncles hash{{uncles_hash}}
Author{{author.text}}
State root{{state_root}}
Receipts root{{receipts_root}}
Gas used{{gas_used}}
Gas limit{{gas_limit}}
Extra data{{#each extra_data}}{{this}}
37 | {{/each}}
Timestamp{{timestamp}}
Difficulty{{difficulty}}
Total difficulty{{total_difficulty}}
53 | {{#if txs}} 54 |
Transactions
55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | {{#each txs}} 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | {{/each}} 75 | 76 |
TxGPriceFromToValueData
{{tx.text}}{{gas_price}}{{from.text}}{{to_label}}{{to_link.text}}{{value}}{{shortdata}}
77 | {{/if}} 78 | 79 | {{ > footer.handlebars }} -------------------------------------------------------------------------------- /static/tmpl/config.handlebars: -------------------------------------------------------------------------------- 1 | {{ > header.handlebars }} 2 | 3 | 8 | 9 |
Configuration
10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
Balance{{balance}}
18 | 19 |
function foo(items) { 20 | var x = "All this is syntax highlighted"; 21 | return x; 22 | }
23 | 24 |
25 | 26 |
27 | 28 | {{ > footer.handlebars }} -------------------------------------------------------------------------------- /static/tmpl/footer.handlebars: -------------------------------------------------------------------------------- 1 |

2 |

5 | 6 |
7 | 8 | 9 | -------------------------------------------------------------------------------- /static/tmpl/header.handlebars: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 13 | 17 | 21 | 22 | 23 | 29 | 33 | 37 | 38 | 39 | 44 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 |
57 |
58 |
59 |

60 | {{ui_title}} 61 |

62 |
63 |
64 | 67 |
68 |
69 |
70 | 71 |
72 |
73 |
74 | -------------------------------------------------------------------------------- /static/tmpl/home.handlebars: -------------------------------------------------------------------------------- 1 | {{ > header.handlebars }} 2 | 3 |
4 | Blocks 5 | {{#if has_prev_page}} 6 | 7 | {{else}} 8 | 9 | {{/if}} 10 | {{#if has_next_page}} 11 | 12 | {{else}} 13 | 14 | {{/if}} 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | {{#each blocks}} 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | {{/each}} 36 | 37 |
BlockAuthor#txsDatetimeGas usedGas limit
{{block.text}}{{author.text}}{{tx_count}}{{timestamp}}{{gas_used}}{{gas_limit}}
38 |
39 | 42 | {{ > footer.handlebars }} -------------------------------------------------------------------------------- /static/tmpl/neb.handlebars: -------------------------------------------------------------------------------- 1 | {{ > header.handlebars }} 2 | 3 |
4 | Non-empty-blocks 5 | {{#if has_prev_page}} 6 | 7 | {{else}} 8 | 9 | {{/if}} 10 | {{#if has_next_page}} 11 | 12 | {{else}} 13 | 14 | {{/if}} 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | {{#each blocks}} 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | {{/each}} 36 | 37 |
BlockAuthor#txsDatetimeGas usedGas limit
{{block.text}}{{author.text}}{{tx_count}}{{timestamp}}{{gas_used}}{{gas_limit}}
38 |
39 | 42 | {{ > footer.handlebars }} -------------------------------------------------------------------------------- /static/tmpl/tx.handlebars: -------------------------------------------------------------------------------- 1 | {{ > header.handlebars }} 2 | 3 |
Tx {{ txhash }}
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 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 |
Status{{status}}
From{{from.text}}
To 17 | {{ #if tonewcontract }} 18 | New contract 19 | {{ else }} 20 | {{to.text}} 21 | {{ /if }} 22 |
Value{{value}}
Block{{block.text}}
Gas{{gas}}
Gas price{{gas_price}}
Cumulative gas used{{cumulative_gas_used}}
Gas used{{gas_used}}
Contract created{{contract_address.text}}
54 | 55 |
Input
56 |
57 | {{#each input}}{{this}}
58 | {{/each}}
59 | 
60 | 61 |
Logs
62 | {{#each logs}} 63 | {{address.text}} 64 |
65 | {{#each txt}}{{this}}
66 | {{/each}}
67 | 
68 | {{/each}} 69 | 70 | {{#if itxs}} 71 |
Internal transactions
72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | {{#each itxs}} 81 | 82 | 83 | 84 | 85 | 86 | 87 | {{/each}} 88 | 89 |
FromToValueData
{{from.text}}{{to_link.text}}{{value.text}}{{shortdata}}
90 | 91 | 92 | {{/if}} 93 | 94 | 95 | {{ > footer.handlebars }} -------------------------------------------------------------------------------- /static/web/common.js: -------------------------------------------------------------------------------- 1 | $(function () { 2 | $( '.searchTerm' ).bind('keypress', function(e){ 3 | if ( e.keyCode == 13 ) { 4 | window.location.href = "/"+$('.searchTerm').val() 5 | } 6 | }); 7 | $('.searchButton').on('click',function(){ 8 | window.location.href = "/"+$('.searchTerm').val() 9 | }); 10 | }); 11 | -------------------------------------------------------------------------------- /static/web/purecss-tabs.css: -------------------------------------------------------------------------------- 1 | /* 2 | CSS for the main interaction 3 | */ 4 | .tabset > input[type="radio"] { 5 | position: absolute; 6 | left: -200vw; 7 | } 8 | 9 | .tabset .tab-panel { 10 | display: none; 11 | } 12 | 13 | .tabset > input:first-child:checked ~ .tab-panels > .tab-panel:first-child, 14 | .tabset > input:nth-child(3):checked ~ .tab-panels > .tab-panel:nth-child(2), 15 | .tabset > input:nth-child(5):checked ~ .tab-panels > .tab-panel:nth-child(3), 16 | .tabset > input:nth-child(7):checked ~ .tab-panels > .tab-panel:nth-child(4), 17 | .tabset > input:nth-child(9):checked ~ .tab-panels > .tab-panel:nth-child(5), 18 | .tabset > input:nth-child(11):checked ~ .tab-panels > .tab-panel:nth-child(6) { 19 | display: block; 20 | } 21 | 22 | .tabset > label { 23 | position: relative; 24 | display: inline-block; 25 | padding: 5px 5px 5px; 26 | border: 1px solid transparent; 27 | border-bottom: 0; 28 | cursor: pointer; 29 | font-weight: 600; 30 | } 31 | 32 | .tabset > label::after { 33 | content: ""; 34 | position: absolute; 35 | left: 15px; 36 | bottom: 10px; 37 | width: 22px; 38 | height: 4px; 39 | background: #8d8d8d; 40 | } 41 | 42 | .tabset > label:hover, 43 | .tabset > input:focus + label { 44 | color: #06c; 45 | } 46 | 47 | .tabset > label:hover::after, 48 | .tabset > input:focus + label::after, 49 | .tabset > input:checked + label::after { 50 | background: #06c; 51 | } 52 | 53 | .tabset > input:checked + label { 54 | border-color: #ccc; 55 | border-bottom: 1px solid #fff; 56 | margin-bottom: -1px; 57 | } 58 | 59 | .tab-panel { 60 | padding: 30px 0; 61 | border-top: 1px solid #ccc; 62 | } 63 | 64 | .tabset { 65 | max-width: 65em; 66 | } -------------------------------------------------------------------------------- /static/web/style.css: -------------------------------------------------------------------------------- 1 | .pure-g , .pure-g [class*="pure-u"], html { 2 | font-family: Helvetica Neue,Helvetica,Arial,sans-serif; 3 | } 4 | 5 | a, a:active, a:focus { 6 | color: #3498db; 7 | text-decoration-line: none; 8 | } 9 | a:hover { 10 | color: #3498db; 11 | text-decoration-line: underline; 12 | } 13 | .code { 14 | font-size: 1 00%; 15 | font-family:monospace; 16 | line-height: 1.2; 17 | color: #222; 18 | } 19 | 20 | td { 21 | padding-left: 8px !important; 22 | padding-right: 8px !important; 23 | } 24 | 25 | h5 { 26 | margin-block-start: 1.36em; 27 | margin-block-end: 0.5em; 28 | font-size: 1.2rem; 29 | color: #036dd5; 30 | } 31 | 32 | h6 { 33 | margin-block-start: 0em; 34 | margin-block-end: 0.5em; 35 | font-size: 1rem; 36 | color: #777; 37 | } 38 | textarea { 39 | height: 200px; 40 | } 41 | .disabled { 42 | color: #fff; 43 | } 44 | 45 | .search { 46 | width: 100%; 47 | position: relative; 48 | } 49 | .search:before { 50 | position: absolute; 51 | top: 0; 52 | right: 0; 53 | width: 40px; 54 | height: 40px; 55 | line-height: 40px; 56 | font-family: 'FontAwesome'; 57 | content: '\f002'; 58 | background: #3498db; 59 | text-align: center; 60 | color: #fff; 61 | border-radius: 5px; 62 | -webkit-font-smoothing: subpixel-antialiased; 63 | font-smooth: always; 64 | } 65 | 66 | .searchTerm { 67 | -moz-box-sizing: border-box; 68 | -webkit-box-sizing: border-box; 69 | box-sizing: border-box; 70 | width: 100%; 71 | border: 5px solid #3498db; 72 | padding: 5px; 73 | height: 40px; 74 | border-radius: 5px; 75 | outline: none; 76 | } 77 | 78 | .searchButton { 79 | position: absolute; 80 | top: 0; 81 | right: 0; 82 | width: 40px; 83 | height: 40px; 84 | opacity: 0; 85 | cursor: pointer; 86 | padding-top: 8px; 87 | } 88 | 89 | .majorfont { 90 | font-family: 'Major Mono Display', monospace; 91 | } 92 | 93 | .pure-table { 94 | border: 1px; 95 | } 96 | 97 | .pure-table td, .pure-table th { 98 | padding: .3em .5em; 99 | border-left: 0px; 100 | } 101 | 102 | .text-truncate { 103 | overflow: hidden !important; 104 | text-overflow: ellipsis !important; 105 | white-space: nowrap !important; 106 | } 107 | 108 | .type-tx { 109 | max-width: 100; 110 | } 111 | 112 | .type-addr { 113 | max-width: 200; 114 | } 115 | 116 | .type-gas , .type-txcount, .type-value { 117 | text-align: right; 118 | } 119 | 120 | .tabset > label { 121 | font-size: 80%; 122 | } 123 | 124 | .tabset > input:checked + label { 125 | font-size: 80%; 126 | border-bottom: 1px solid #000; 127 | border-radius: 4px; 128 | margin-bottom: 1px; 129 | } 130 | 131 | .tabset > label::after { 132 | content: none; 133 | } 134 | 135 | .type-data { 136 | font-size: 120% !important; 137 | font-family: monospace; 138 | color: #222; 139 | } 140 | 141 | .tab-panel { 142 | padding: 5px 5px; 143 | border-top: 0px; 144 | } 145 | 146 | .footer { 147 | font-size: 80%; 148 | } 149 | --------------------------------------------------------------------------------