Skip to content

Commit

Permalink
BMP 0.2-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
JavierGonzalez committed Aug 9, 2019
1 parent 12851b6 commit 4f74a7c
Show file tree
Hide file tree
Showing 39 changed files with 395 additions and 262 deletions.
2 changes: 2 additions & 0 deletions .htaccess
Expand Up @@ -3,7 +3,9 @@
RewriteEngine on
RewriteBase /


RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

61 changes: 31 additions & 30 deletions README.md
Expand Up @@ -4,7 +4,16 @@ THIS IS AN OPEN-SOURCE TOOL WITH NO RESPONSIBILITY FOR ACTIONS TAKEN BY THIRD PA

---

###### A Hashpower Voting System for Bitcoin Global Adoption.
##### BMP is a Hashpower Voting System for Bitcoin Global Adoption
- [x] Hardware-wallet auth.
- [x] Multi-blockchain SHA-256 merge.
- [x] Real-time hashpower chat.
- [x] Nick change.
- [x] Voting, with multiple points and options.
- [x] Votes with hashpower.
- [x] Rectifiable votes (in open votings).
- [x] 100% verifiable, on-chain, open-source.


## Why

Expand Down Expand Up @@ -64,65 +73,57 @@ Extract from [ABC vs BSV Hash War (Part III)](https://medium.com/@jiangzhuoer/ab

## How

Talking and voting with hashpower -to discover consensus- in the most secure voting system known.
Talking and voting with hashpower -to discover consensus- in the most secure voting system ever known.


## What

#### [bmp.virtualpol.com](https://bmp.virtualpol.com)
#### [bmp.virtualpol.com](https://bmp.virtualpol.com) [version 0.2-beta]

<br />

[BMP](https://bmp.virtualpol.com) is a [LAMP](https://en.wikipedia.org/wiki/LAMP_(software_bundle)) web system, completely on-chain, verifiable, replicable and driven by hashpower.

BMP works connected to a Bitcoin Cash client by RPC to read blocks and transactions.
Blockchain data is transformed [with this PHP](https://github.com/JavierGonzalez/BMP/blob/master/autoload/bmp.php) in 3 SQL tables: **[Blocks](https://bmp.virtualpol.com/info/blocks)**, **[Miners](https://bmp.virtualpol.com/info/miners)** and **[Actions](https://bmp.virtualpol.com/info/actions)**.
[BMP](https://bmp.virtualpol.com) is a voting system, completely on-chain, verifiable, replicable and driven by hashpower. A robust and expandable base system. Merge all Bitcoin SHA-256 hashpower. Expanding the vision of Satoshi Nakamoto [whitepaper](https://www.bitcoin.com/bitcoin.pdf).

BMP is a [LAMP](https://en.wikipedia.org/wiki/LAMP_(software_bundle)) web system connected to a multiple Bitcoin client -via RPC- to read blocks and transactions. Blockchain data is processed [with this PHP](https://github.com/JavierGonzalez/BMP/blob/master/autoload/bmp.php) in three SQL tables: **[Blocks](https://bmp.virtualpol.com/info/blocks)**, **[Miners](https://bmp.virtualpol.com/info/miners)** and **[Actions](https://bmp.virtualpol.com/info/actions)**.

Actions without hashpower are ignored. Miners power changes with each block. Actions power never changes.

Actions are composed in JavaScript and broadcast with [Trezor Connect](https://github.com/trezor/connect/blob/develop/docs/methods/composeTransaction.md) (more hardware wallets in future).

BMP does not store private keys. The entire BMP database is public information.
Actions are stored in Bitcoin Cash (BCH) because is fast, cheap and stable.

More in **[BMP Protocol](https://bmp.virtualpol.com/protocol)** and paper in [Chinese](https://virtualpol.com/BMP_CN.pdf), [English](https://virtualpol.com/BMP_EN.pdf) and [Spanish](https://virtualpol.com/BMP_ES.pdf).
Actions without hashpower are ignored. Miners power (%) changes with each block. Actions power never changes.

Actions are composed in JavaScript and broadcast with [Trezor Connect](https://github.com/trezor/connect/blob/develop/docs/methods/composeTransaction.md) (more hardware wallets in future).

#### Features
BMP does not store private keys and the database is public information.

* Hardware-wallet authentication.
* Real-time chat with hashpower.
* Nick change.
* Voting with multiple config, points and options.
* Votes with hashpower.
* Rectifiable votes (in open voting).
* 100% verifiable on-chain.
More in **[BMP Protocol](https://bmp.virtualpol.com/protocol)** and the BMP paper in [English](https://virtualpol.com/BMP_EN.pdf), [Chinese](https://virtualpol.com/BMP_CN.pdf) and [Spanish](https://virtualpol.com/BMP_ES.pdf).


#### Requirements to participate

1. Your address in a coinbase output in the last `2,016` blocks of BCH.
1. Your address in a coinbase output in the last `2,016` blocks of BTC, BCH or BSV.
2. Trezor hardware wallet.


#### Hashpower signaling

1. **power_by_value**
By default, BMP calculates the hashpower percentage of each output address with the coinbase `value`. This makes it compatible with all blocks and with P2Pool even the smallest miner can participate right now.
By default, BMP calculates the hashpower percentage of each output address with the coinbase `value`. This makes it compatible with all blocks. With P2Pool, even the smallest miner can participate, right now.

2. **power_by_opreturn**
In order not to interfere with mining operations, there is a second method that allows to signal hashpower quotas in one or more addresses in coinbase OP_RETURN output. This ignores the value and allows the delegation of hashpower with simplicity.

In this way, miners can easily delegate hashpower to anyone else.

In this way, with simplicity, miners can delegate hashpower in other people to participate.

#### Requirements to deploy

1. Bitcoin ABC client, with `-txindex`
2. GNU/Linux
3. Apache
4. MariaDB database
5. PHP
1. GNU/Linux
2. Apache
3. MariaDB SQL database
4. PHP
5. Bitcoin BCH client, with `-txindex` (main for actions)
6. Bitcoin BTC client
7. Bitcoin BSV client


#### Tested environment

Expand All @@ -144,7 +145,7 @@ In this way, miners can easily delegate hashpower to anyone else.
2. Configure RPC and SQL access by renaming `autoload/_password.php`.
3. Execute `scheme.sql` in a new SQL database.
4. Set a `crontab` every minute with: `curl https://bmp.domain.com/update`.
5. Wait synchronization.
5. Wait synchronizations.

#### Known problems

Expand Down
2 changes: 2 additions & 0 deletions __maximum_simplicity/config.php
@@ -1,6 +1,8 @@
<?php # maximum_simplicity — Javier González González


define('__MAXIMUM_SIMPLICITY_VERSION', 1);

error_reporting(E_ALL ^ E_NOTICE);

ini_set('display_errors', 1);
Expand Down
67 changes: 43 additions & 24 deletions __maximum_simplicity/functions.php
Expand Up @@ -2,37 +2,62 @@



function __profiler($hrtime=false) {
global $__, $__sql, $__rpc;

if (!$hrtime)
$hrtime = $__['crono'];

$output[] = num((hrtime(true)-$hrtime)/1000/1000).' ms';

if (is_numeric($__sql['count']))
$output[] = num($__sql['count']).' sql';

if (is_numeric($__rpc['count']))
$output[] = num($__rpc['count']).' rpc';

$output[] = num(memory_get_usage(false)/1024).' kb';

return $output;
}



// For debug and benchmarking.
function ___($echo='', $scroll_down=false) {
$now = hrtime(true);
global $_;
global $__;

if (!$_['crono'])
$_['crono'] = $now;

if ($scroll_down) {
if (function_exists('apache_setenv'))
@apache_setenv('no-gzip', 1);
echo '<br />'."\n";
echo ++$__['___'].'. &nbsp; '.date('Y-m-d H:i:s').' &nbsp; '.implode(' &nbsp; ', __profiler()).' &nbsp; ';

ob_end_flush();
echo '<script>function Az1() { window.scrollTo(0,document.body.scrollHeight); }</script>';
}


echo '<br />'.++$_['crono_count'].'. &nbsp; '.date('Y-m-d H:i:s').' &nbsp; ';
echo number_format(($now-$_['crono'])/1000000, 2).' ms &nbsp; ';

if (is_array($echo) OR is_object($echo))
if (is_string($echo))
echo $echo;
else if (is_array($echo) OR is_object($echo))
print_r2($echo);
else if ($echo!=='')
else
var_dump($echo);


if ($scroll_down) {
echo '<script>Az1();</script>';

if ($__['___']==1) {

if (function_exists('apache_setenv'))
@apache_setenv('no-gzip', 1);

ob_end_flush();
echo '<script>function __sd() { window.scrollTo(0,document.body.scrollHeight); }</script>';
}

echo '<script>__sd();</script>';
flush();
ob_flush();
}

$_['crono'] = hrtime(true);
$__['crono'] = hrtime(true);
}


Expand Down Expand Up @@ -75,12 +100,6 @@ function every($seconds=60, $id=0) {



function ram() {
return number_format(memory_get_usage(true)/1024).' kb';
}



function redirect($url='/') {
header('Location: '.$url);
exit;
Expand All @@ -95,5 +114,5 @@ function shell($command) {


function num($number, $decimals=0) {
return number_format($number, $decimals, '.', ',');
return number_format((float)$number, $decimals, '.', ',');
}
1 change: 0 additions & 1 deletion __maximum_simplicity/router.php
Expand Up @@ -34,7 +34,6 @@
foreach ($public AS $_module) {
if (file_exists($_module)) {

// Sub-autoload
if (file_exists(dirname($_module).'/*.php'))
include(dirname($_module).'/*.php');

Expand Down
24 changes: 9 additions & 15 deletions __maximum_simplicity/start.php
@@ -1,31 +1,25 @@
<?php # maximum_simplicity — Javier González González


$_['crono'] = hrtime(true);
$__['crono'] = hrtime(true);
$__['crono_start'] = $__['crono'];


ob_start(NULL, 1024*1024*10);
ob_start(NULL, 10485760);


include('__maximum_simplicity/config.php');


include('__maximum_simplicity/functions.php');


foreach (glob('autoload/*.php') AS $_file)
include($_file);

foreach (glob('autoload/*.php') AS $__file)
include($__file);

include('__maximum_simplicity/router.php');


if (isset($_['template']['output']))
include('template/'.$_['template']['output'].'.php');


$_output_html_content = ob_get_contents();
ob_end_clean();
include('template/index.php');
if (isset($__['template']['output']))
include('template/'.$__['template']['output'].'.php');
else
include('template/index.php');

exit;
12 changes: 7 additions & 5 deletions autoload/_config.php
@@ -1,16 +1,18 @@
<?php # BMP — Javier González González


define('BMP_VERSION', '0.1-beta');
define('BMP_VERSION', '0.2-beta');

define('BLOCK_WINDOW', 2016); // Blocks

define('BLOCKCHAINS', ['BTC', 'BCH', 'BSV']);

define('BLOCKCHAIN_ACTIONS', 'BCH');

define('BLOCK_WINDOW', 2016); // Blocks
define('POWER_PRECISION', 5); // Decimals of %

define('BMP_GENESIS_BLOCK', 588996 - BLOCK_WINDOW);

define('POWER_PRECISION', 4); // Decimals of %

define('OP_RETURN_MAX_SIZE', 220); // Bytes

define('FEE_PER_BYTE', 0.00002); // BCH/KB
define('FEE_PER_BYTE', 0.00002); // Bitcoin/kb
6 changes: 2 additions & 4 deletions autoload/_passwords.php.sample
Expand Up @@ -3,10 +3,8 @@

define('DEV', false);

define('URL_SQL', 'mysql://root@localhost:3306/bmp');
define('URL_SQL', 'mysql://user:pass@host:port/database');

define('URL_RPC_BTC', 'rpc://user:pass@host:port');
define('URL_RPC_BCH', 'rpc://user:pass@host:port');
define('URL_RPC_BSV', 'rpc://user:pass@host:port');

define('BLOCKCHAINS', ['BCH']);
define('URL_RPC_BSV', 'rpc://user:pass@host:port');

0 comments on commit 4f74a7c

Please sign in to comment.