Skip to content

Commit

Permalink
mtp running on testnet wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
djm34 committed Jun 6, 2018
1 parent fcb6df5 commit 011bf45
Show file tree
Hide file tree
Showing 42 changed files with 5,791 additions and 1,748 deletions.
3 changes: 0 additions & 3 deletions MINAURYIMPEU.BAT

This file was deleted.

40 changes: 38 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,38 @@
# ccminer-dev
mtp ccminer developpment
ccminer
=======

Based on Christian Buchner's & Christian H.'s CUDA project, no more active on github recently.

Fork by tpruvot@github with X14,X15,X17,Blake256,BlakeCoin,Lyra2RE,Skein,ZR5 and others, check the [README.txt](README.txt)

BTC donation address: 1AJdfCpLWPNoAMDfHF1wD5y8VgKSSTHxPo
[![tip for next commit](https://tip4commit.com/projects/927.svg)](https://tip4commit.com/github/tpruvot/ccminer)

A part of the recent algos were originally written by [djm34](https://github.com/djm34).

This variant was tested and built on Linux (ubuntu server 14.04) and VStudio 2013 on Windows 7.

Note that the x86 releases are generally faster than x64 ones on Windows.

The recommended CUDA Toolkit version is [6.5.19](http://developer.download.nvidia.com/compute/cuda/6_5/rel/installers/cuda_6.5.19_windows_general_64.exe), but some light algos could be faster with the version 7.5 (like blake and skein).

About source code dependencies
------------------------------

This project requires some libraries to be built :

- OpenSSL (prebuilt for win)

- Curl (prebuilt for win)

- pthreads (prebuilt for win)

The tree now contains recent prebuilt openssl and curl .lib for both x86 and x64 platforms (windows).

To rebuild them, you need to clone this repository and its submodules :
git clone https://github.com/peters/curl-for-windows.git compat/curl-for-windows

On Linux, you can use the helper ./build.sh (edit it if required)

There is also an old [Tutorial for windows](http://cudamining.co.uk/url/tutorials/id/3) on [CudaMining](http://cudamining.co.uk) website.

6 changes: 3 additions & 3 deletions RUN-LYRA2Z-testnet.cmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
rem Release\ccminer -a lyra2Z -o http://13.76.210.1:18888 -u zcoindev -p EDk1vvzAx6N67DND9YqyzwSUbhVvZPecVvQHmXc8MPRtest1
rem x64\Release\ccminer -a lyra2Z -o stratum+tcp://xzc.suprnova.cc:1598 -u djm34.1 -p password -i 22
x64\Release\ccminer -a lyra2rev2 -o stratum+tcp://mona.suprnova.cc:2995 -u djm34.1 -p password -i 22 -d 1070
rem x64\Release\ccminer -a lyra2Z -o http://127.0.0.1:9898 -u djm34 -p password -d gtx1080 --debug --protocol-dump --no-getwork --no-longpoll
x64\Release\ccminer -a mtp -o http://127.0.0.1:8382 -u djm34 -p password --coinbase-addr TFGK4rUcabyrj9ZdPDNq8EznCb4YCAxz4Q -d gtx1080 --debug --no-getwork --no-longpoll
rem Release\ccminer -a lyra2 -o stratum+tcp://dash80.suprnova.cc:80 -u djm34.1 -p password --cpu-priority 4
pause
2 changes: 0 additions & 2 deletions algos.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

enum sha_algos {
ALGO_BLAKECOIN = 0,
ALGO_ARGON2,
ALGO_BLAKE,
ALGO_BLAKE2S,
ALGO_BMW,
Expand Down Expand Up @@ -61,7 +60,6 @@ extern volatile enum sha_algos opt_algo;

static const char *algo_names[] = {
"blakecoin",
"argon2",
"blake",
"blake2s",
"bmw",
Expand Down
2 changes: 2 additions & 0 deletions argon2ref/argon2.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ int argon2_ctx_from_mtp(argon2_context *context, argon2_instance_t *instance) {
instance->lanes = context->lanes;
instance->threads = context->threads;
instance->type = Argon2_d;
/*
instance->block_header[0] = ((uint32_t*)context->pwd)[0];
instance->block_header[1] = ((uint32_t*)context->pwd)[1];
instance->block_header[2] = ((uint32_t*)context->pwd)[2];
Expand All @@ -136,6 +137,7 @@ int argon2_ctx_from_mtp(argon2_context *context, argon2_instance_t *instance) {
instance->block_header[5] = ((uint32_t*)context->pwd)[5];
instance->block_header[6] = ((uint32_t*)context->pwd)[6];
instance->block_header[7] = ((uint32_t*)context->pwd)[7];
*/
// printf("3. Initializatio n: Hashing inputs, allocating memory, filling first blocks\n");
/* 3. Initialization: Hashing inputs, allocating memory, filling first blocks */
result = initialize(instance, context);
Expand Down
4 changes: 2 additions & 2 deletions argon2ref/argon2.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ typedef enum Argon2_version {
} argon2_version;
// big hack
typedef struct block_ { uint64_t v[128]; uint64_t prev_block; uint64_t ref_block;} block;

typedef struct blockS_ { uint64_t v[128];} blockS;
/*
typedef struct block_with_offset_ {
block memory;
Expand All @@ -256,7 +256,7 @@ typedef struct Argon2_instance_t {
argon2_type type;
int print_internals; /* whether to print the memory blocks */
argon2_context *context_ptr; /* points back to original context */
uint32_t block_header[8]; // takes 256 first bits of the blockheader
uint32_t block_header[18]; // takes 256 first bits of the blockheader //hash_0
} argon2_instance_t;


Expand Down
3 changes: 3 additions & 0 deletions argon2ref/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,9 @@ int initialize(argon2_instance_t *instance, argon2_context *context) {
ARGON2_PREHASH_SEED_LENGTH -
ARGON2_PREHASH_DIGEST_LENGTH);

for (int i = 0; i < ARGON2_PREHASH_SEED_LENGTH/4; i++)
instance->block_header[i] = ((uint32_t*)blockhash)[i];

#ifdef GENKAT
initial_kat(blockhash, context, instance->type);
#endif
Expand Down
51 changes: 48 additions & 3 deletions argon2ref/ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,45 @@
* @param with_xor Whether to XOR into the new block (1) or just overwrite (0)
* @pre all block pointers must be valid
*/
void getBlockIndex(uint32_t ij, argon2_instance_t *instance, uint32_t *Index)
{
uint32_t ij_prev = 0;
if (ij%instance->lane_length == 0)
ij_prev = ij + instance->lane_length - 1;
else
ij_prev = ij - 1;

if (ij % instance->lane_length == 1)
ij_prev = ij - 1;

uint64_t prev_block_opening = instance->memory[ij_prev].v[0];
uint32_t ref_lane = (uint32_t)((prev_block_opening >> 32) % instance->lanes);

uint32_t pseudo_rand = (uint32_t)(prev_block_opening & 0xFFFFFFFF);

uint32_t Lane = ((ij) / instance->lane_length);
uint32_t Slice = (ij - (Lane * instance->lane_length)) / instance->segment_length;
uint32_t posIndex = ij - Lane * instance->lane_length - Slice * instance->segment_length;


uint32_t rec_ij = Slice*instance->segment_length + Lane *instance->lane_length + (ij % instance->segment_length);

if (Slice == 0)
ref_lane = Lane;


argon2_position_t position = { 0, Lane , (uint8_t)Slice, posIndex };

uint32_t ref_index = index_alpha(instance, &position, pseudo_rand, ref_lane == position.lane);

uint32_t computed_ref_block = instance->lane_length * ref_lane + ref_index;

Index[0] = ij_prev;
Index[1] = computed_ref_block;
}



static void fill_block(const block *prev_block, const block *ref_block,
block *next_block, int with_xor, uint32_t block_header[4]) {
block blockR, block_tmp;
Expand Down Expand Up @@ -87,9 +126,9 @@ static void fill_block(const block *prev_block, const block *ref_block,
}

static void fill_block_withIndex(const block *prev_block, const block *ref_block,
block *next_block, int with_xor, uint32_t block_header[8], uint64_t index) {
block *next_block, int with_xor, uint32_t block_header[8], uint32_t index) {
block blockR, block_tmp;
uint64_t TheIndex[2] = {0,index};
uint32_t TheIndex[2] = {0,index};
unsigned i;

copy_block(&blockR, ref_block);
Expand All @@ -106,7 +145,7 @@ static void fill_block_withIndex(const block *prev_block, const block *ref_block
}
// blockR.v[16] = ((uint64_t*)block_header)[0];
// blockR.v[17] = ((uint64_t*)block_header)[1];
memcpy(&blockR.v[14], TheIndex, 2 * sizeof(uint64_t)); //index here
memcpy(&blockR.v[14], TheIndex, sizeof(uint64_t)); //index here
memcpy(&blockR.v[16], (uint64_t*)block_header, 2 * sizeof(uint64_t));
memcpy(&blockR.v[18], (uint64_t*)(block_header + 4), 2 * sizeof(uint64_t));
//printf("block header in cpu %llx %llx %llx %llx\n", blockR.v[15], blockR.v[16], blockR.v[17], blockR.v[18]);
Expand Down Expand Up @@ -249,6 +288,12 @@ truc++;
curr_block = instance->memory + curr_offset;
uint64_t TheBlockIndex = instance->lane_length * ref_lane + ref_index;

// uint32_t TheCompBlockIndex[2] = { 0 };
// getBlockIndex(curr_offset, instance, TheCompBlockIndex);

//if (TheCompBlockIndex[1]!=(uint32_t)(TheBlockIndex & 0xFFFFFFFF))
//printf("curr_offset = %d prev_offset = %d ref_block = %d \n", curr_offset ,prev_offset, instance->lane_length * ref_lane + ref_index);
// printf("computed value: prev_block %f ref_block %f prev_offset %f Standard one %f\n", (double)TheCompBlockIndex[0], (double)TheCompBlockIndex[1],(double)prev_offset, (double)TheBlockIndex);

/*
zRefBlock = &instance->TheRefBlock + curr_offset;
Expand Down
125 changes: 125 additions & 0 deletions base58.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/*
* Copyright 2012 Luke Dashjr
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the standard MIT license. See COPYING for more details.
*/
//#include <arpa/inet.h>

#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <jansson.h>
//uint32_t htonla(uint32_t);

static const int8_t b58digits[] = {
-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8,-1,-1,-1,-1,-1,-1,
-1, 9,10,11,12,13,14,15, 16,-1,17,18,19,20,21,-1,
22,23,24,25,26,27,28,29, 30,31,32,-1,-1,-1,-1,-1,
-1,33,34,35,36,37,38,39, 40,41,42,43,-1,44,45,46,
47,48,49,50,51,52,53,54, 55,56,57,-1,-1,-1,-1,-1,
};

static bool _blkmk_b58tobin(void *bin, size_t binsz, const char *b58, size_t b58sz)
{
const unsigned char *b58u = (const unsigned char*)b58;
unsigned char *binu = (unsigned char *)bin;
const size_t outisz = ( ((size_t)26) + 3) / 4;
uint32_t outi[outisz];
uint64_t t;
uint32_t c;
size_t i, j;
uint8_t bytesleft = binsz % 4;
uint32_t zeromask = ~((1 << ((bytesleft) * 8)) - 1);

if (!b58sz)
b58sz = strlen(b58);

memset(outi, 0, outisz * sizeof(*outi));

for (i = 0; i < b58sz; ++i)
{
if (b58u[i] & 0x80)
// High-bit set on invalid digit
return false;
if (b58digits[b58u[i]] == -1)
// Invalid base58 digit
return false;
c = b58digits[b58u[i]];
for (j = outisz; j--; )
{
t = ((uint64_t)outi[j]) * 58 + c;
c = (t & 0x3f00000000) >> 32;
outi[j] = t & 0xffffffff;
}
if (c)
// Output number too big (carry to the next int32)
return false;
if (outi[0] & zeromask)
// Output number too big (last int32 filled too far)
return false;
}

j = 0;
switch (bytesleft) {
case 3:
*(binu++) = (outi[0] & 0xff0000) >> 16;
case 2:
*(binu++) = (outi[0] & 0xff00) >> 8;
case 1:
*(binu++) = (outi[0] & 0xff);
++j;
default:
break;
}

for (; j < outisz; ++j)
{

*((uint32_t*)binu) = _byteswap_ulong(outi[j]);
binu += sizeof(uint32_t);
}
return true;
}

extern "C" bool base58_decode(const char *input, char *output)
{
unsigned char output_bin[32] = { 0 };
bool b = _blkmk_b58tobin(output_bin, 26, input, 0);
output[0] = '\0';

if(!b) return false;

for(int i=2; i < 22; i++)
sprintf(output+strlen(output), "%02x", output_bin[i]);

return true;
}


#define TX_VALUE(v, s) ((unsigned int)(v>>s)&0xff)

extern "C" void encode_tx_value(char *encoded, json_int_t value)
{
sprintf(encoded, "%02x%02x%02x%02x%02x%02x%02x%02x",
TX_VALUE(value, 0), TX_VALUE(value, 8), TX_VALUE(value, 16), TX_VALUE(value, 24),
TX_VALUE(value, 32), TX_VALUE(value, 40), TX_VALUE(value, 48), TX_VALUE(value, 56));
}

extern "C" void job_pack_tx(char *data, json_int_t amount, char *key)
{
int ol = strlen(data);
char evalue[32];
encode_tx_value(evalue, amount);

sprintf(data + strlen(data), "%s", evalue);

// sprintf(data + strlen(data), "1976a914%s88ac", key ? key : coind->script_pubkey);
sprintf(data + strlen(data), "1976a914%s88ac", key );

}

4 changes: 2 additions & 2 deletions bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ void algo_free_all(int thr_id)
free_x17(thr_id);
free_zr5(thr_id);
//free_sha256d(thr_id);
//free_scrypt(thr_id);
//free_scrypt_jane(thr_id);
// free_scrypt(thr_id);
// free_scrypt_jane(thr_id);
}

// benchmark all algos (called once per mining thread)
Expand Down
Loading

0 comments on commit 011bf45

Please sign in to comment.