Skip to content

Commit

Permalink
DERO-HE STARGATE Testnet Release31
Browse files Browse the repository at this point in the history
  • Loading branch information
CaptainDero committed Nov 28, 2021
1 parent b98d31e commit 484639b
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 34 deletions.
2 changes: 1 addition & 1 deletion block/miniblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type MiniBlock struct {
Final bool // bit 5
PastCount uint8 // previous count // bits 6,7

Timestamp uint16 // can represent time from first block
Timestamp uint16 // represents rolling time
Height uint64 // 5 bytes serialized in 5 bytes,

Past [2]uint32 // 8 bytes used to build DAG of miniblocks and prevent number of attacks
Expand Down
10 changes: 5 additions & 5 deletions blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ func (chain *Blockchain) Add_Complete_Block(cbl *block.Complete_Block) (err erro
}

// we will directly use graviton to mov in to history
logger.V(3).Info("Full order data", "full_order", full_order, "base_topo_index", base_topo_index)
logger.V(1).Info("Full order data", "full_order", full_order, "base_topo_index", base_topo_index)

if base_topo_index < 0 {
logger.Error(nil, "negative base topo, not possible, probably disk corruption or core issue")
Expand Down Expand Up @@ -880,7 +880,7 @@ func (chain *Blockchain) Add_Complete_Block(cbl *block.Complete_Block) (err erro
panic(err)
}

logger.V(3).Info("reading block snapshot", "blid", full_order[i-1], "i", i, "record_version", record_version)
logger.V(1).Info("reading block snapshot", "blid", full_order[i-1], "i", i, "record_version", record_version)

ss, err = chain.Store.Balance_store.LoadSnapshot(record_version)
if err != nil {
Expand Down Expand Up @@ -987,12 +987,12 @@ func (chain *Blockchain) Add_Complete_Block(cbl *block.Complete_Block) (err erro
chain.StoreBlock(bl_current, commit_version)
topos_written = true
chain.Store.Topo_store.Write(current_topo_block, full_order[i], commit_version, chain.Load_Block_Height(full_order[i]))
if logger.V(3).Enabled() {
if logger.V(1).Enabled() {
merkle_root, err := chain.Load_Merkle_Hash(commit_version)
if err != nil {
panic(err)
}
logger.V(3).Info("storing topo", "i", i, "blid", full_order[i].String(), "topoheight", current_topo_block, "commit_version", commit_version, "committed_merkle", merkle_root)
logger.V(1).Info("storing topo", "i", i, "blid", full_order[i].String(), "topoheight", current_topo_block, "commit_version", commit_version, "committed_merkle", merkle_root)
}

}
Expand Down Expand Up @@ -1024,7 +1024,7 @@ func (chain *Blockchain) Add_Complete_Block(cbl *block.Complete_Block) (err erro

for i := range tips {
tip_height := int64(chain.Load_Height_for_BL_ID(tips[i]))
if (chain_height - tip_height) < 2 {
if (chain_height - tip_height) == 0 {

new_tips[tips[i]] = tips[i]
} else { // this should be a rare event, unless network has very high latency
Expand Down
8 changes: 2 additions & 6 deletions blockchain/miner_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,12 +352,8 @@ func ConvertBlockToMiniblock(bl block.Block, miniblock_miner_address rpc.Address
mbl.Height = bl.Height

timestamp := uint64(globals.Time().UTC().UnixMilli())
diff := timestamp - bl.Timestamp
mbl.Timestamp = 0xffff
if diff > 0xffff {
mbl.Timestamp = 0xffff
}

mbl.Timestamp = uint16(timestamp) // this will help us better understand network conditions

mbl.PastCount = byte(len(bl.Tips))
for i := range bl.Tips {
mbl.Past[i] = binary.BigEndian.Uint32(bl.Tips[i][:])
Expand Down
5 changes: 3 additions & 2 deletions blockchain/sc.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,9 @@ func (chain *Blockchain) execute_sc_function(w_sc_tree *Tree_Wrapper, data_tree
return
}
signer, err := extract_signer(&tx)
if err != nil {
return
if err != nil { // allow anonymous SC transactions with condition that SC will not call Signer
// this allows anonymous voting and numerous other applications
// otherwise SC receives signer as all zeroes
}

// setup block hash, height, topoheight correctly
Expand Down
1 change: 1 addition & 0 deletions blockchain/transaction_execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ func (chain *Blockchain) process_transaction_sc(cache map[crypto.Hash]*graviton.
func extract_signer(tx *transaction.Transaction) (signer [33]byte, err error) {
for t := range tx.Payloads {
if uint64(len(tx.Payloads[t].Statement.Publickeylist_compressed)) != tx.Payloads[t].Statement.RingSize {
panic("tx is not expanded")
return signer, fmt.Errorf("tx is not expanded")
}
if tx.Payloads[t].SCID.IsZero() && tx.Payloads[t].Statement.RingSize == 2 {
Expand Down
48 changes: 47 additions & 1 deletion cmd/derod/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,44 @@ func readline_loop(l *readline.Instance, chain *blockchain.Blockchain, logger lo

case command == "print_tree": // prints entire block chain tree
//WriteBlockChainTree(chain, "/tmp/graph.dot")
case command == "install_block":
var hash crypto.Hash

if len(line_parts) == 2 && len(line_parts[1]) == 64 {
bl_raw, err := hex.DecodeString(strings.ToLower(line_parts[1]))
if err != nil {
fmt.Printf("err while decoding blid err %s\n", err)
continue
}
copy(hash[:32], []byte(bl_raw))
} else {
fmt.Printf("install_block needs a single block id as argument\n")
continue
}

var bl block.Block
var cbl *block.Complete_Block

if block_data, err := os.ReadFile(fmt.Sprintf("/tmp/blocks/%s", hash)); err == nil {

if err = bl.Deserialize(block_data); err != nil { // we should deserialize the block here
logger.Error(err, "fError deserialiing block, block id %x len(data) %d data %x", hash[:], len(block_data), block_data, err)
continue
}

cbl = &block.Complete_Block{Bl: &bl}
} else {
fmt.Printf("err reading block %s\n", err)
continue
}

// bl, err := chain.Load_BL_FROM_ID(hash)
// if err != nil {
// fmt.Printf("Err %s\n", err)
// }

err, _ = chain.Add_Complete_Block(cbl)
fmt.Printf("err adding block %s\n", err)

case command == "print_block":

Expand Down Expand Up @@ -661,7 +699,7 @@ func readline_loop(l *readline.Instance, chain *blockchain.Blockchain, logger lo
if supply > (1000000 * 1000000000000) {
supply -= (1000000 * 1000000000000) // remove premine
}
fmt.Printf("Network %s Height %d NW Hashrate %0.03f MH/sec TH %s Peers %d inc, %d out MEMPOOL size %d REGPOOL %d Total Supply %s DERO \n", globals.Config.Name, chain.Get_Height(), float64(chain.Get_Network_HashRate())/1000000.0, chain.Get_Top_ID(), inc, out, mempool_tx_count, regpool_tx_count, globals.FormatMoney(supply))
fmt.Printf("Network %s Height %d NW Hashrate %0.03f MH/sec Peers %d inc, %d out MEMPOOL size %d REGPOOL %d Total Supply %s DERO \n", globals.Config.Name, chain.Get_Height(), float64(chain.Get_Network_HashRate())/1000000.0, inc, out, mempool_tx_count, regpool_tx_count, globals.FormatMoney(supply))
if chain.LocatePruneTopo() >= 1 {
fmt.Printf("Chain is pruned till %d\n", chain.LocatePruneTopo())
} else {
Expand All @@ -670,6 +708,14 @@ func readline_loop(l *readline.Instance, chain *blockchain.Blockchain, logger lo
fmt.Printf("Integrator address %s\n", chain.IntegratorAddress().String())
fmt.Printf("UTC time %s (as per system clock) \n", time.Now().UTC())
fmt.Printf("UTC time %s (offset %s) (as per daemon) should be close to 0\n", globals.Time().UTC(), time.Now().Sub(globals.Time()))
fmt.Printf("Local time %s (as per system clock) \n", time.Now())
fmt.Printf("Local time %s (offset %s) (as per daemon) should be close to 0\n", globals.Time(), time.Now().Sub(globals.Time()))
tips := chain.Get_TIPS()
fmt.Printf("Tips ")
for _, tip := range tips {
fmt.Printf(" %s(%d)", tip, chain.Load_Height_for_BL_ID(tip))
}
fmt.Printf("\n")

// print hardfork status on second line
hf_state, _, _, threshold, version, votes, window := chain.Get_HF_info()
Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ var Mainnet = CHAIN_CONFIG{Name: "mainnet",
}

var Testnet = CHAIN_CONFIG{Name: "testnet", // testnet will always have last 3 bytes 0
Network_ID: uuid.FromBytesOrNil([]byte{0x59, 0xd7, 0xf7, 0xe9, 0xdd, 0x48, 0xd5, 0xfd, 0x13, 0x0a, 0xf6, 0xe0, 0x72, 0x00, 0x00, 0x00}),
Network_ID: uuid.FromBytesOrNil([]byte{0x59, 0xd7, 0xf7, 0xe9, 0xdd, 0x48, 0xd5, 0xfd, 0x13, 0x0a, 0xf6, 0xe0, 0x73, 0x00, 0x00, 0x00}),
P2P_Default_Port: 40401,
RPC_Default_Port: 40402,
Wallet_RPC_Default_Port: 40403,
Expand Down
2 changes: 1 addition & 1 deletion config/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ import "github.com/blang/semver/v4"

// right now it has to be manually changed
// do we need to include git commitsha??
var Version = semver.MustParse("3.4.91-1.DEROHE.STARGATE+25112021")
var Version = semver.MustParse("3.4.92-1.DEROHE.STARGATE+25112021")
34 changes: 17 additions & 17 deletions p2p/connection_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,34 +56,35 @@ const MAX_CLOCK_DATA_SET = 16

// This structure is used to do book keeping for the connection and keeps other DATA related to peer
// golang restricts 64 bit uint64/int atomic on a 64 bit boundary
// therefore all atomics are on the top
// therefore all atomics are on the top, As suggested by Slixe
type Connection struct {
Height int64 // last height sent by peer ( first member alignments issues)
StableHeight int64 // last stable height
TopoHeight int64 // topo height, current topo height, this is the only thing we require for syncing
Pruned int64 // till where chain has been pruned on this node
LastObjectRequestTime int64 // when was the last item placed in object list
Latency int64 // time.Duration // latency to this node when sending timed sync
BytesIn uint64 // total bytes in
BytesOut uint64 // total bytes out
Top_Version uint64 // current hard fork version supported by peer
Peer_ID uint64 // Remote peer id
Port uint32 // port advertised by other end as its server,if it's 0 server cannot accept connections
State uint32 // state of the connection

Client *rpc2.Client
Conn net.Conn // actual object to talk
ConnTls net.Conn // tls layered conn

Height int64 // last height sent by peer ( first member alignments issues)
StableHeight int64 // last stable height
TopoHeight int64 // topo height, current topo height, this is the only thing we require for syncing
StateHash crypto.Hash // statehash at the top
Pruned int64 // till where chain has been pruned on this node
StateHash crypto.Hash // statehash at the top

Created time.Time // when was object created
LastObjectRequestTime int64 // when was the last item placed in object list
BytesIn uint64 // total bytes in
BytesOut uint64 // total bytes out
Latency int64 // time.Duration // latency to this node when sending timed sync
Created time.Time // when was object created

Incoming bool // is connection incoming or outgoing
Addr net.Addr // endpoint on the other end
Port uint32 // port advertised by other end as its server,if it's 0 server cannot accept connections
Peer_ID uint64 // Remote peer id
SyncNode bool // whether the peer has been added to command line as sync node
Top_Version uint64 // current hard fork version supported by peer
ProtocolVersion string
Tag string // tag for the other end
DaemonVersion string
State uint32 // state of the connection
Top_ID crypto.Hash // top block id of the connection

logger logr.Logger // connection specific logger
Expand All @@ -100,8 +101,7 @@ type Connection struct {
clock_offsets [MAX_CLOCK_DATA_SET]time.Duration
delays [MAX_CLOCK_DATA_SET]time.Duration
clock_offset int64 // duration updated on every miniblock

onceexit sync.Once
onceexit sync.Once

Mutex sync.Mutex // used only by connection go routine
}
Expand Down

0 comments on commit 484639b

Please sign in to comment.