Browse Source

Hardfork 3 Ready 2.1.0-0.alpha.atlantis+19092018

webwallet
Captain Dero 3 years ago
parent
commit
05081d365b
11 changed files with 572103 additions and 769829 deletions
  1. +5
    -1
      blockchain/blockchain.go
  2. +3
    -2
      blockchain/hardfork_core.go
  3. +13
    -1
      blockchain/outputs_index.go
  4. +22
    -9
      checkpoints/checkpoints.go
  5. BIN
      checkpoints/mainnet_checksums.dat
  6. +570970
    -764516
      checkpoints/mainnet_checksums.go
  7. +1061
    -5295
      checkpoints/testnet_checksums.go
  8. +4
    -3
      cmd/dero-wallet-cli/prompt.go
  9. +1
    -1
      cmd/derod/main.go
  10. +1
    -1
      config/version.go
  11. +23
    -0
      walletapi/wallet.go

+ 5
- 1
blockchain/blockchain.go View File

@@ -1206,7 +1206,11 @@ skip_checks:
// lower reward for byzantine behaviour
// for as many block as added
if chain.isblock_SideBlock(dbtx, bl_current_hash, highest_topo) { // lost race (or byzantine behaviour)
if hard_fork_version_current == 2 {
base_reward = (base_reward * 67) / 100 // give only 67 % reward
}else{
base_reward = (base_reward * 8) / 100 // give only 8 % reward
}
}

// logger.Infof("past coins generated %d base reward %d", past_coins_generated, base_reward)
@@ -1243,7 +1247,7 @@ skip_checks:
// we will start where the previous block vouts ended
_, output_index_start = chain.Get_Block_Output_Index(dbtx, previous_block)
}
if !chain.write_output_index(dbtx, bl_current_hash, output_index_start) {
if !chain.write_output_index(dbtx, bl_current_hash, output_index_start, hard_fork_version_current) {
logger.Warnf("Since output index data cannot be wrritten, skipping block")
return errormsg.ErrInvalidBlock, false
}


+ 3
- 2
blockchain/hardfork_core.go View File

@@ -44,9 +44,10 @@ type Hard_fork struct {
// current mainnet_hard_forks
var mainnet_hard_forks = []Hard_fork{
// {0, 0,0,0,0,true}, // dummy entry so as we can directly use the fork index into this entry
{1, 0, 0, 0, 0, true}, // version 1 hard fork where genesis block landed and chain migration occurs
{1, 0, 0, 0, 0, true}, // version 1 hard fork where genesis block landed and chain migration occurs
// version 1 has difficulty hardcoded to 1
{2, 95551, 0, 0, 0, true}, // version 2 hard fork where Atlantis bootstraps , it's mandatory
{2, 95551, 0, 0, 0, true}, // version 2 hard fork where Atlantis bootstraps , it's mandatory
{3, 721000, 0, 0, 0, true}, // version 3 hard fork emission fix, it's mandatory
}

// current testnet_hard_forks


+ 13
- 1
blockchain/outputs_index.go View File

@@ -94,7 +94,7 @@ func init() {
// 8 bytes blockheight to which this output belongs
// this function should always succeed or panic showing something is not correct
// NOTE: this function should only be called after all the tx and the block has been stored to DB
func (chain *Blockchain) write_output_index(dbtx storage.DBTX, block_id crypto.Hash, index_start int64) (result bool) {
func (chain *Blockchain) write_output_index(dbtx storage.DBTX, block_id crypto.Hash, index_start int64, hard_fork_version_current int64) (result bool) {

// load the block
bl, err := chain.Load_BL_FROM_ID(dbtx, block_id)
@@ -233,6 +233,18 @@ func (chain *Blockchain) write_output_index(dbtx storage.DBTX, block_id crypto.H
o.Unlock_Height = tx.Unlock_Time
}

if hard_fork_version_current >= 3 && o.Unlock_Height != 0 {
if o.Unlock_Height < config.CRYPTONOTE_MAX_BLOCK_NUMBER {
if o.Unlock_Height < (o.Height + 1000) {
o.Unlock_Height = o.Height + 1000
}
}else{
if o.Unlock_Height < (o.Block_Time + 12000) {
o.Unlock_Height = o.Block_Time + 12000
}
}
}

// include the key image list in the first output itself
// rest all the outputs donot contain the keyimage
if j != 0 && len(o.Key_Images) > 0 {


+ 22
- 9
checkpoints/checkpoints.go View File

@@ -20,27 +20,26 @@ package checkpoints

// generate blank file if no testnet checkpoints
//go:generate sh -c "echo package checkpoints > testnet_checksums.go"
//go:generate sh -c "if [ ! -s testnet_checksums.dat ]; then echo var testnet_checksums = []byte{} >> testnet_checksums.go; fi;"
//go:generate sh -c " if [ -s testnet_checksums.dat ]; then echo var testnet_checksums = []byte{ >> testnet_checksums.go; fi"
//go:generate sh -c "if [ -s testnet_checksums.dat ]; then xxd -i < testnet_checksums.dat >> testnet_checksums.go;fi"
//go:generate sh -c "if [ -s testnet_checksums.dat ]; then truncate -s-1 testnet_checksums.go; fi"
//go:generate sh -c "if [ -s testnet_checksums.dat ]; then echo ,} >> testnet_checksums.go;fi "
//go:generate sh -c "if [ ! -s testnet_checksums.dat ]; then echo var testnet_checksums_base64 = \"\" >> testnet_checksums.go; fi;"
//go:generate sh -c " if [ -s testnet_checksums.dat ]; then echo var testnet_checksums_base64 = \\\x60 >> testnet_checksums.go; fi"
//go:generate sh -c "if [ -s testnet_checksums.dat ]; then base64 -w 80 < testnet_checksums.dat >> testnet_checksums.go;fi"
//go:generate sh -c "if [ -s testnet_checksums.dat ]; then echo \\\x60 >> testnet_checksums.go;fi "

//go:generate sh -c "echo // Code generated by go generate DO NOT EDIT. > mainnet_checksums.go"
//go:generate sh -c "echo // This file contains all the mainnet checksums > mainnet_checksums.go"
//go:generate sh -c "echo // please read checkpoints.go comments > mainnet_checksums.go"
//go:generate sh -c "echo package checkpoints >> mainnet_checksums.go"
//go:generate sh -c "echo >> mainnet_checksums.go"
//go:generate sh -c "echo var mainnet_checksums = []byte{ >> mainnet_checksums.go"
//go:generate sh -c "xxd -i < mainnet_checksums.dat >> mainnet_checksums.go"
//go:generate sh -c "truncate -s-1 mainnet_checksums.go"
//go:generate sh -c "echo ,} >> mainnet_checksums.go"
//go:generate sh -c "echo var mainnet_checksums_base64 = \\\x60 >> mainnet_checksums.go"
//go:generate sh -c "base64 -w 80 < mainnet_checksums.dat >> mainnet_checksums.go"
//go:generate sh -c "echo \\\x60 >> mainnet_checksums.go"

import "fmt"

//import "bytes"
import "io/ioutil"
import "path/filepath"
import "encoding/base64"

import "github.com/romana/rlog"
import log "github.com/sirupsen/logrus"
@@ -69,6 +68,20 @@ func init() {
checksum_tree = radix.New()
}

var mainnet_checksums = load_base64(mainnet_checksums_base64)
var testnet_checksums = load_base64(testnet_checksums_base64)

func load_base64(input string) []byte {
data, err := base64.StdEncoding.DecodeString(input)
if err != nil {
rlog.Tracef(1, "Loaded checksums failed base64 decoding input length %d", len(input))
}
return data
}

// load checkpoints from the data directory
// a line should be printed on console when we are doing this
func LoadCheckPoints(logger *log.Entry) {


BIN
checkpoints/mainnet_checksums.dat View File


+ 570970
- 764516
checkpoints/mainnet_checksums.go
File diff suppressed because it is too large
View File


+ 1061
- 5295
checkpoints/testnet_checksums.go
File diff suppressed because it is too large
View File


+ 4
- 3
cmd/dero-wallet-cli/prompt.go View File

@@ -20,6 +20,7 @@ import "os"
import "io"
import "fmt"
import "bytes"
import "time"
import "io/ioutil"
import "path/filepath"
import "strings"
@@ -898,14 +899,14 @@ func show_transfers(l *readline.Instance, wallet *walletapi.Wallet, limit uint64
case 0:

if len(transfers[i].PaymentID) == 0 {
io.WriteString(l.Stderr(), fmt.Sprintf(color_green+"Height %d TopoHeight %d transaction %s received %s DERO"+color_white+"\n", transfers[i].Height, transfers[i].TopoHeight, transfers[i].TXID, globals.FormatMoney12(transfers[i].Amount)))
io.WriteString(l.Stderr(), fmt.Sprintf(color_green+"%s Height %d TopoHeight %d transaction %s received %s DERO"+color_white+"\n",transfers[i].Time.Format(time.RFC822), transfers[i].Height, transfers[i].TopoHeight, transfers[i].TXID, globals.FormatMoney12(transfers[i].Amount)))
} else {
payment_id := fmt.Sprintf("%x", transfers[i].PaymentID)
io.WriteString(l.Stderr(), fmt.Sprintf(color_green+"Height %d TopoHeight %d transaction %s received %s DERO"+color_white+" PAYMENT ID:%s\n", transfers[i].Height, transfers[i].TopoHeight, transfers[i].TXID, globals.FormatMoney12(transfers[i].Amount), payment_id))
io.WriteString(l.Stderr(), fmt.Sprintf(color_green+"%s Height %d TopoHeight %d transaction %s received %s DERO"+color_white+" PAYMENT ID:%s\n",transfers[i].Time.Format(time.RFC822), transfers[i].Height, transfers[i].TopoHeight, transfers[i].TXID, globals.FormatMoney12(transfers[i].Amount), payment_id))
}

case 1:
io.WriteString(l.Stderr(), fmt.Sprintf(color_magenta+"Height %d TopoHeight %d transaction %s spent %s DERO"+color_white+"\n", transfers[i].Height, transfers[i].TopoHeight, transfers[i].TXID, globals.FormatMoney12(transfers[i].Amount)))
io.WriteString(l.Stderr(), fmt.Sprintf(color_magenta+"%s Height %d TopoHeight %d transaction %s spent %s DERO"+color_white+"\n",transfers[i].Time.Format(time.RFC822), transfers[i].Height, transfers[i].TopoHeight, transfers[i].TXID, globals.FormatMoney12(transfers[i].Amount)))
case 2:
fallthrough
default:


+ 1
- 1
cmd/derod/main.go View File

@@ -136,7 +136,7 @@ func main() {
globals.Logger.Infof("Daemon in %s mode", globals.Config.Name)
globals.Logger.Infof("Daemon data directory %s", globals.GetDataDirectory())

// go check_update_loop ()
go check_update_loop ()

params := map[string]interface{}{}



+ 1
- 1
config/version.go View File

@@ -20,4 +20,4 @@ import "github.com/blang/semver"

// right now it has to be manually changed
// do we need to include git commitsha??
var Version = semver.MustParse("2.0.1-3.alpha.atlantis+04072018")
var Version = semver.MustParse("2.1.0-0.alpha.atlantis+19092018")

+ 23
- 0
walletapi/wallet.go View File

@@ -20,6 +20,7 @@ import "fmt"
import "net"
import "sort"
import "sync"
import "time"
import "bytes"
import "strings"
import "crypto/rand"
@@ -689,6 +690,7 @@ type Entry struct {
PaymentID []byte
Status byte
Unlock_Time uint64
Time time.Time
}

// finds all inputs which have been received/spent etc
@@ -699,6 +701,8 @@ type Entry struct {
// if payment_id is true, only entries with payment ids are returned
func (w *Wallet) Show_Transfers(available bool, in bool, out bool, pool bool, failed bool, payment_id bool, min_height, max_height uint64) (entries []Entry) {

dero_first_block_time := time.Unix(1512432000,0) //Tuesday, December 5, 2017 12:00:00 AM
if max_height == 0 {
max_height = 5000000000
}
@@ -723,6 +727,12 @@ func (w *Wallet) Show_Transfers(available bool, in bool, out bool, pool bool, fa
entry.Amount = tx.WAmount
entry.PaymentID = tx.WPaymentID
entry.Status = 0
entry.Time = time.Unix(int64(tx.TXdata.Block_Time), 0)

if entry.Height < 95600 { // make up time for pre-atlantis blocks
duration,_ := time.ParseDuration(fmt.Sprintf("%ds",int64(180*entry.Height)))
entry.Time = dero_first_block_time.Add(duration)
}

if payment_id {

@@ -760,6 +770,13 @@ func (w *Wallet) Show_Transfers(available bool, in bool, out bool, pool bool, fa
entry.Amount = tx.WAmount
entry.PaymentID = tx.WPaymentID
entry.Status = 0
entry.Time = time.Unix(int64(tx.TXdata.Block_Time), 0)

if entry.Height < 95600 { // make up time for pre-atlantis blocks
duration,_ := time.ParseDuration(fmt.Sprintf("%ds",int64(180*entry.Height)))
entry.Time = dero_first_block_time.Add(duration)
}

if in {
if tx.TXdata.Height >= min_height && tx.TXdata.Height <= max_height { // height filter
if payment_id {
@@ -793,6 +810,12 @@ func (w *Wallet) Show_Transfers(available bool, in bool, out bool, pool bool, fa
entry.TXID = tx.TXdata.TXID
entry.TopoHeight = tx.TXdata.TopoHeight
entry.PaymentID = entry.PaymentID[:0] // payment id needs to be zero or tracked from some where else
entry.Time = time.Unix(int64(tx.TXdata.Block_Time), 0)

if entry.Height < 95600 { // make up time for pre-atlantis blocks
duration,_ := time.ParseDuration(fmt.Sprintf("%ds",int64(180*entry.Height)))
entry.Time = dero_first_block_time.Add(duration)
}

entry.Status = 1
entries = append(entries, entry) // spend entry


Loading…
Cancel
Save