Skip to content
This repository has been archived by the owner on Apr 3, 2022. It is now read-only.

Commit

Permalink
Hardfork 3 Ready 2.1.0-0.alpha.atlantis+19092018
Browse files Browse the repository at this point in the history
  • Loading branch information
Captain Dero committed Sep 19, 2018
1 parent 6435d22 commit 05081d3
Show file tree
Hide file tree
Showing 11 changed files with 572,103 additions and 769,829 deletions.
6 changes: 5 additions & 1 deletion blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down
5 changes: 3 additions & 2 deletions blockchain/hardfork_core.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion blockchain/outputs_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down
31 changes: 22 additions & 9 deletions checkpoints/checkpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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) {
Expand Down
Binary file modified checkpoints/mainnet_checksums.dat
Binary file not shown.
Loading

0 comments on commit 05081d3

Please sign in to comment.