This commit is contained in:
c4ei 2023-08-23 13:41:40 +09:00
parent bd1420220a
commit 8608748ac1
17 changed files with 134 additions and 60 deletions

2
.gitignore vendored
View File

@ -60,3 +60,5 @@ coverage.txt
testdbs/
coverage.tmp
start.txt

View File

@ -18,7 +18,7 @@ func TestVersion(t *testing.T) {
pver := uint32(4)
// Create version message data.
tcpAddrMe := &net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: 16111}
tcpAddrMe := &net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: 21001}
me := NewNetAddress(tcpAddrMe)
generatedID, err := id.GenerateID()
if err != nil {

View File

@ -12,7 +12,7 @@ import (
// TestNetAddress tests the NetAddress API.
func TestNetAddress(t *testing.T) {
ip := net.ParseIP("127.0.0.1")
port := 16111
port := 21001
// Test NewNetAddress.
na := NewNetAddress(&net.TCPAddr{IP: ip, Port: port})

BIN
bin/genkeypair Executable file

Binary file not shown.

BIN
bin/kaspactl Executable file

Binary file not shown.

BIN
bin/kaspaminer Executable file

Binary file not shown.

BIN
bin/kaspawallet Executable file

Binary file not shown.

View File

@ -29,6 +29,7 @@ $ go install .
- Kaspactl should now be installed in `$(go env GOPATH)/bin`. If you did not already add the bin directory to your
system path during Go installation, you are encouraged to do so now.
- 이제 Kaspad(및 유틸리티)가 $(go env GOPATH)/bin에 설치됩니다. Go 설치 중에 시스템 경로에 bin 디렉터리를 아직 추가하지 않았다면 지금 추가하는 것이 좋습니다.
## Usage

View File

@ -102,7 +102,7 @@ func TestPOW(t *testing.T) {
}
random := rand.New(rand.NewSource(0))
// Difficulty is too high on mainnet to actually mine.
if consensusConfig.Name != "kaspa-mainnet" {
if consensusConfig.Name != "c4ex-mainnet" {
mining.SolveBlock(validBlock, random)
err = tc.ValidateAndInsertBlock(validBlock, true)
if err != nil {

View File

@ -1,8 +1,9 @@
package dagconfig
import (
"github.com/kaspanet/kaspad/domain/consensus/utils/constants"
"time"
"github.com/kaspanet/kaspad/domain/consensus/utils/constants"
)
// The documentation refers to the following constants which aren't explicated in the code:
@ -20,32 +21,63 @@ import (
// https://research.kas.pa/t/a-proposal-for-finality-in-ghostdag/66/17
// https://research.kas.pa/t/some-of-the-intuition-behind-the-design-of-the-invalidation-rules-for-pruning/95
//
// 문서에서는 코드에 설명되지 않은 다음 상수를 참조합니다.
// d - 블록 왕복 시간의 상한
// 델타 - 네트워크 너비가 기본값을 초과하는 예상 시간 비율GHOSTDAGK
//
// defaultGHOSTDAGK 및 델타 및 defaultTargetTimePerBlock에 대한 종속성에 대한 자세한 내용은
// PHANTOM 논문을 참고하세요: https://eprint.iacr.org/2018/104.pdf
//
// DAA 상수에 대한 자세한 내용은 defaultDifficultyAdjustmentWindowSize, defaultTimestampDeviationTolerance,
// 그리고 defaultGHOSTDAGK 및 defaultTargetTimePerBlock과의 관계는 다음을 참조하세요.
// https://research.kas.pa/t/handling-timestamp-manipulations/97
//
// defaultMergeSetSizeLimit, defaultFinalityDuration 및 정리와의 관계에 대한 자세한 내용은 다음을 참조하세요.
// https://research.kas.pa/t/a-proposal-for-finality-in-ghostdag/66/17
// https://research.kas.pa/t/some-of-the-intuition-behind-the-design-of-the-invalidation-rules-for-pruning/95
const (
defaultMaxCoinbasePayloadLength = 204
// defaultMaxBlockMass is a bound on the mass of a block, larger values increase the bound d
// on the round trip time of a block, which affects the other parameters as described below
// defaultMaxBlockMass는 블록 질량의 경계이며, 값이 클수록 경계 d가 증가합니다.
// 블록의 왕복 시간에 따라 아래 설명된 대로 다른 매개변수에 영향을 미칩니다.
defaultMaxBlockMass = 500_000
// defaultMassPerTxByte, defaultMassPerScriptPubKeyByte and defaultMassPerSigOp define the number of grams per
// transaction byte, script pub key byte and sig op respectively.
// These values are used when calculating a transactions mass.
// defaultMassPerTxByte, defaultMassPerScriptPubKeyByte 및 defaultMassPerSigOp는 당 그램 수를 정의합니다.
// 각각 트랜잭션 바이트, 스크립트 pub 키 바이트 및 sig op.
// 거래량을 계산할 때 사용되는 값입니다.
defaultMassPerTxByte = 1
defaultMassPerScriptPubKeyByte = 10
defaultMassPerSigOp = 1000
// defaultMaxBlockParents is the number of blocks any block can point to.
// Should be about d/defaultTargetTimePerBlock where d is a bound on the round trip time of a block.
// defaultMaxBlockParents는 모든 블록이 가리킬 수 있는 블록 수입니다.
// d/defaultTargetTimePerBlock 정도여야 합니다. 여기서 d는 블록의 왕복 시간에 대한 경계입니다.
defaultMaxBlockParents = 10
// defaultGHOSTDAGK is a bound on the number of blue blocks in the anticone of a blue block. Approximates the maximal
// width of the network.
// Formula (1) in section 4.2 of the PHANTOM paper shows how to calculate defaultGHOSTDAGK. The delta term represents a bound
// on the expected fraction of the network life in which the width was higher than defaultGHOSTDAGK. The current value of K
// was calculated for d = 5 seconds and delta = 0.05.
// defaultGHOSTDAGK는 파란색 블록의 안티콘에 있는 파란색 블록 수에 대한 경계입니다. 최대 근사치
// 네트워크의 너비.
// PHANTOM 논문 섹션 4.2의 공식 (1)은 기본GHOSTDAGK를 계산하는 방법을 보여줍니다. 델타 항은 경계를 나타냅니다.
// 너비가 defaultGHOSTDAGK보다 높은 네트워크 수명의 예상 비율. K의 현재 값
// d = 5초, 델타 = 0.05로 계산되었습니다.
defaultGHOSTDAGK = 18
// defaultMergeSetSizeLimit is a bound on the size of the past of a block and the size of the past
// of its selected parent. Any block which violates this bound is invalid.
// Should be at least an order of magnitude smaller than defaultFinalityDuration/defaultTargetTimePerBlock.
// (Higher values make pruning attacks easier by a constant, lower values make merging after a split or a spike
// in block take longer)
// defaultMergeSetSizeLimit은 블록의 과거 크기와 과거 크기의 경계입니다.
// 선택한 부모의 이 경계를 위반하는 모든 블록은 유효하지 않습니다.
// defaultFinalityDuration/defaultTargetTimePerBlock보다 최소한 한 자릿수는 작아야 합니다.
// (값이 높을수록 상수에 의한 가지치기 공격이 더 쉬워지고, 값이 낮을수록 분할 또는 스파이크 후에 병합됩니다.
// 블록에서는 시간이 더 오래 걸립니다)
defaultMergeSetSizeLimit = defaultGHOSTDAGK * 10
defaultSubsidyGenesisReward = 1 * constants.SompiPerKaspa
defaultPreDeflationaryPhaseBaseSubsidy = 500 * constants.SompiPerKaspa
@ -54,12 +86,20 @@ const (
// defaultDifficultyAdjustmentWindowSize is the number of blocks in a block's past used to calculate its difficulty
// target.
// The DAA should take the median of 2640 blocks, so in order to do that we need 2641 window size.
// defaultDifficultyAdjustmentWindowSize는 난이도를 계산하는 데 사용된 블록의 과거 블록 수입니다.
// 표적.
// DAA는 2640 블록의 중앙값을 취해야 하므로 이를 위해서는 2641 창 크기가 필요합니다.
defaultDifficultyAdjustmentWindowSize = 2641
// defaultTimestampDeviationTolerance is the allowed deviance of an inconming block's timestamp, measured in block delays.
// A new block can't hold a timestamp lower than the median timestamp of the (defaultTimestampDeviationTolerance*2-1) blocks
// with highest accumulated blue work in its past, such blocks are considered invalid.
// A new block can't hold a timestamp higher than the local system time + defaultTimestampDeviationTolerance/defaultTargetTimePerBlock,
// such blocks are not marked as invalid but are rejected.
// defaultTimestampDeviationTolerance는 블록 지연으로 측정된 문제가 있는 블록의 타임스탬프에 허용되는 편차입니다.
// 새 블록은 (defaultTimestampDeviationTolerance*2-1) 블록의 중간 타임스탬프보다 낮은 타임스탬프를 보유할 수 없습니다.
// 과거에 가장 많이 누적된 파란색 작업이 있는 경우 이러한 블록은 유효하지 않은 것으로 간주됩니다.
// 새 블록은 로컬 시스템 시간 + defaultTimestampDeviationTolerance/defaultTargetTimePerBlock보다 높은 타임스탬프를 보유할 수 없습니다.
// 이러한 블록은 유효하지 않은 것으로 표시되지는 않지만 거부됩니다.
defaultTimestampDeviationTolerance = 132
// defaultFinalityDuration is an approximate lower bound of how old the finality block is. The finality block is chosen to
// be the newest block in the selected chain whose blue score difference from the selected tip is at least
@ -67,10 +107,19 @@ const (
// The pruning block is selected similarly, with the following duration:
// pruning block duration =
// 2*defaultFinalityDuration/defaultTargetTimePerBlock + 4*defaultMergeSetSizeLimit*defaultGHOSTDAGK + 2*defaultGHOSTDAGK + 2
// defaultFinalityDuration은 최종성 블록이 얼마나 오래되었는지에 대한 대략적인 하한입니다. 최종 블록은 다음과 같이 선택됩니다.
// 선택된 팁과의 파란색 점수 차이가 최소한인 선택된 체인의 최신 블록이 됩니다.
// defaultFinalityDuration/defaultTargetTimePerBlock.
// 가지치기 블록은 다음과 같은 기간으로 유사하게 선택됩니다.
// 가지치기 블록 기간 =
// 2*defaultFinalityDuration/defaultTargetTimePerBlock + 4*defaultMergeSetSizeLimit*defaultGHOSTDAGK + 2*defaultGHOSTDAGK + 2
defaultFinalityDuration = 24 * time.Hour
// defaultTargetTimePerBlock represents how much time should pass on average between two consecutive block creations.
// Should be parametrized such that the average width of the DAG is about defaultMaxBlockParents and such that most of the
// time the width of the DAG is at most defaultGHOSTDAGK.
// defaultTargetTimePerBlock은 두 개의 연속 블록 생성 사이에 평균적으로 경과해야 하는 시간을 나타냅니다.
// DAG의 평균 너비가 defaultMaxBlockParents 정도가 되도록 매개변수화해야 하며 대부분의 경우
// DAG의 너비가 최대 기본값GHOSTDAGK인 시간입니다.
defaultTargetTimePerBlock = 1 * time.Second
defaultPruningProofM = 1000
@ -81,6 +130,12 @@ const (
// Half a year in seconds = 365.25 / 2 * 24 * 60 * 60 = 15778800
// The network was down for three days shortly after launch
// Three days in seconds = 3 * 24 * 60 * 60 = 259200
// defaultDeflationaryPhaseDaaScore는 디플레이션 이전 기간 이후의 DAA 점수입니다.
// 디플레이션 기간으로 전환합니다. 이 숫자는 다음과 같이 계산됩니다.
// 1년을 365.25일로 정의합니다.
// 반년(초) = 365.25 / 2 * 24 * 60 * 60 = 15778800
// 출시 직후 3일 ​​동안 네트워크가 다운되었습니다.
// 3일(초) = 3 * 24 * 60 * 60 = 259200
defaultDeflationaryPhaseDaaScore = 15778800 - 259200
defaultMergeDepth = 3600

View File

@ -5,12 +5,13 @@
package dagconfig
import (
"math/big"
"github.com/kaspanet/go-muhash"
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
"github.com/kaspanet/kaspad/domain/consensus/utils/blockheader"
"github.com/kaspanet/kaspad/domain/consensus/utils/subnetworks"
"github.com/kaspanet/kaspad/domain/consensus/utils/transactionhelper"
"math/big"
)
var genesisTxOuts = []*externalapi.DomainTransactionOutput{}
@ -145,7 +146,7 @@ var simnetGenesisTxPayload = []byte{
0x00, 0x00, // Script version
0x01, // Varint
0x00, // OP-FALSE
0x6b, 0x61, 0x73, 0x70, 0x61, 0x2d, 0x73, 0x69, 0x6d, 0x6e, 0x65, 0x74, // kaspa-simnet
0x6b, 0x61, 0x73, 0x70, 0x61, 0x2d, 0x73, 0x69, 0x6d, 0x6e, 0x65, 0x74, // c4ex-simnet
}
// simnetGenesisCoinbaseTx is the coinbase transaction for the simnet genesis block.

View File

@ -209,29 +209,30 @@ func (p *Params) PruningDepth() uint64 {
// MainnetParams defines the network parameters for the main Kaspa network.
var MainnetParams = Params{
K: defaultGHOSTDAGK,
Name: "kaspa-mainnet",
Name: "c4ex-mainnet",
Net: appmessage.Mainnet,
RPCPort: "16110",
DefaultPort: "16111",
RPCPort: "21000", // 16110 --> 21000
DefaultPort: "21001", // 16111 --> 21001
DNSSeeds: []string{
// This DNS seeder is run by Wolfie
"mainnet-dnsseed.kas.pa",
"dnsseed.c4ex.net",
// "mainnet-dnsseed.kas.pa",
// This DNS seeder is run by Denis Mashkevich
"mainnet-dnsseed-1.kaspanet.org",
// This DNS seeder is run by Denis Mashkevich
"mainnet-dnsseed-2.kaspanet.org",
// This DNS seeder is run by Constantine Bytensky
"dnsseed.cbytensky.org",
// This DNS seeder is run by Georges Künzli
"seeder1.kaspad.net",
// This DNS seeder is run by Georges Künzli
"seeder2.kaspad.net",
// This DNS seeder is run by Georges Künzli
"seeder3.kaspad.net",
// This DNS seeder is run by Georges Künzli
"seeder4.kaspad.net",
// This DNS seeder is run by Tim
"kaspadns.kaspacalc.net",
// "mainnet-dnsseed-1.kaspanet.org",
// // This DNS seeder is run by Denis Mashkevich
// "mainnet-dnsseed-2.kaspanet.org",
// // This DNS seeder is run by Constantine Bytensky
// "dnsseed.cbytensky.org",
// // This DNS seeder is run by Georges Künzli
// "seeder1.kaspad.net",
// // This DNS seeder is run by Georges Künzli
// "seeder2.kaspad.net",
// // This DNS seeder is run by Georges Künzli
// "seeder3.kaspad.net",
// // This DNS seeder is run by Georges Künzli
// "seeder4.kaspad.net",
// // This DNS seeder is run by Tim
// "kaspadns.kaspacalc.net",
},
// DAG parameters
@ -293,14 +294,15 @@ var MainnetParams = Params{
// TestnetParams defines the network parameters for the test Kaspa network.
var TestnetParams = Params{
K: defaultGHOSTDAGK,
Name: "kaspa-testnet-10",
Name: "c4ex-testnet", // kaspa-testnet-10
Net: appmessage.Testnet,
RPCPort: "16210",
DefaultPort: "16211",
RPCPort: "22000", // 16210 --> 22000
DefaultPort: "22001", // 16211 --> 22001
DNSSeeds: []string{
"testnet-10-dnsseed.kas.pa",
"test-dnsseed.c4ex.net",
// "testnet-10-dnsseed.kas.pa",
// This DNS seeder is run by Tiram
"seeder1-testnet.kaspad.net",
// "seeder1-testnet.kaspad.net",
},
// DAG parameters
@ -365,10 +367,10 @@ var TestnetParams = Params{
// just turn into another public testnet.
var SimnetParams = Params{
K: defaultGHOSTDAGK,
Name: "kaspa-simnet",
Name: "c4ex-simnet",
Net: appmessage.Simnet,
RPCPort: "16510",
DefaultPort: "16511",
RPCPort: "22510", // 16510 --> 22510
DefaultPort: "22511", // 16511 --> 22511
DNSSeeds: []string{}, // NOTE: There must NOT be any seeds.
// DAG parameters
@ -425,10 +427,10 @@ var SimnetParams = Params{
// DevnetParams defines the network parameters for the development Kaspa network.
var DevnetParams = Params{
K: defaultGHOSTDAGK,
Name: "kaspa-devnet",
Name: "c4ex-devnet",
Net: appmessage.Devnet,
RPCPort: "16610",
DefaultPort: "16611",
RPCPort: "22610", // 16610 --> 22610
DefaultPort: "22611", // 16611 --> 22611
DNSSeeds: []string{}, // NOTE: There must NOT be any seeds.
// DAG parameters

View File

@ -84,14 +84,14 @@ type Flags struct {
AddPeers []string `short:"a" long:"addpeer" description:"Add a peer to connect with at startup"`
ConnectPeers []string `long:"connect" description:"Connect only to the specified peers at startup"`
DisableListen bool `long:"nolisten" description:"Disable listening for incoming connections -- NOTE: Listening is automatically disabled if the --connect or --proxy options are used without also specifying listen interfaces via --listen"`
Listeners []string `long:"listen" description:"Add an interface/port to listen for connections (default all interfaces port: 16111, testnet: 16211)"`
Listeners []string `long:"listen" description:"Add an interface/port to listen for connections (default all interfaces port: 21001, testnet: 16211)"`
TargetOutboundPeers int `long:"outpeers" description:"Target number of outbound peers"`
MaxInboundPeers int `long:"maxinpeers" description:"Max number of inbound peers"`
EnableBanning bool `long:"enablebanning" description:"Enable banning of misbehaving peers"`
BanDuration time.Duration `long:"banduration" description:"How long to ban misbehaving peers. Valid time units are {s, m, h}. Minimum 1 second"`
BanThreshold uint32 `long:"banthreshold" description:"Maximum allowed ban score before disconnecting and banning misbehaving peers."`
Whitelists []string `long:"whitelist" description:"Add an IP network or IP that will not be banned. (eg. 192.168.1.0/24 or ::1)"`
RPCListeners []string `long:"rpclisten" description:"Add an interface/port to listen for RPC connections (default port: 16110, testnet: 16210)"`
RPCListeners []string `long:"rpclisten" description:"Add an interface/port to listen for RPC connections (default port: 21000, testnet: 22000)"`
RPCCert string `long:"rpccert" description:"File containing the certificate file"`
RPCKey string `long:"rpckey" description:"File containing the certificate key"`
RPCMaxClients int `long:"rpcmaxclients" description:"Max number of RPC clients for standard connections"`

View File

@ -68,9 +68,9 @@
; You may specify each IP address with or without a port. The default port will
; be added automatically if one is not specified here.
; addpeer=192.168.1.1
; addpeer=10.0.0.2:16111
; addpeer=10.0.0.2:21001
; addpeer=fe80::1
; addpeer=[fe80::2]:16111
; addpeer=[fe80::2]:21001
; Add persistent peers that you ONLY want to connect to as desired. One peer
; per line. You may specify each IP address with or without a port. The
@ -78,9 +78,9 @@
; NOTE: Specifying this option has other side effects as described above in
; the 'addpeer' versus 'connect' summary section.
; connect=192.168.1.1
; connect=10.0.0.2:16111
; connect=10.0.0.2:21001
; connect=fe80::1
; connect=[fe80::2]:16111
; connect=[fe80::2]:21001
; Maximum number of inbound and outbound peers.
; maxinpeers=125
@ -117,12 +117,12 @@
; listen=0.0.0.0
; All ipv6 interfaces on default port:
; listen=::
; All interfaces on port 16111:
; listen=:16111
; All ipv4 interfaces on port 16111:
; listen=0.0.0.0:16111
; All ipv6 interfaces on port 16111:
; listen=[::]:16111
; All interfaces on port 21001:
; listen=:21001
; All ipv4 interfaces on port 21001:
; listen=0.0.0.0:21001
; All ipv6 interfaces on port 21001:
; listen=[::]:21001
; Only ipv4 localhost on port 8333:
; listen=127.0.0.1:8333
; Only ipv6 localhost on port 8333:
@ -162,16 +162,16 @@
; rpclisten=0.0.0.0
; All ipv6 interfaces on default port:
; rpclisten=::
; All interfaces on port 16110:
; rpclisten=:16110
; All ipv4 interfaces on port 16110:
; rpclisten=0.0.0.0:16110
; All ipv6 interfaces on port 16110:
; rpclisten=[::]:16110
; Only ipv4 localhost on port 16110:
; rpclisten=127.0.0.1:16110
; Only ipv6 localhost on port 16110:
; rpclisten=[::1]:16110
; All interfaces on port 21000:
; rpclisten=:21000
; All ipv4 interfaces on port 21000:
; rpclisten=0.0.0.0:21000
; All ipv6 interfaces on port 21000:
; rpclisten=[::]:21000
; Only ipv4 localhost on port 21000:
; rpclisten=127.0.0.1:21000
; Only ipv6 localhost on port 21000:
; rpclisten=[::1]:21000
; Only ipv4 localhost on non-standard port 8337:
; rpclisten=127.0.0.1:8337
; All interfaces on non-standard port 8337:

View File

@ -40,7 +40,7 @@ func TestIPTypes(t *testing.T) {
rfc4193, rfc4380, rfc4843, rfc4862, rfc5737, rfc6052, rfc6145, rfc6598,
local, valid, routable bool) ipTest {
nip := net.ParseIP(ip)
na := *appmessage.NewNetAddressIPPort(nip, 16111)
na := *appmessage.NewNetAddressIPPort(nip, 21001)
test := ipTest{na, rfc1918, rfc2544, rfc3849, rfc3927, rfc3964, rfc4193, rfc4380,
rfc4843, rfc4862, rfc5737, rfc6052, rfc6145, rfc6598, local, valid, routable}
return test

View File

@ -6,7 +6,7 @@ KASPAD_PID=$!
sleep 1
orphans --simnet -alocalhost:16511 -n20 --profile=7000
orphans --simnet -alocalhost:22511 -n20 --profile=7000
TEST_EXIT_CODE=$?
kill $KASPAD_PID

13
start_chg.txt Normal file
View File

@ -0,0 +1,13 @@
kaspa-mainnet --> c4ex-mainnet
/home/dev/coin/kaspad/domain/dagconfig/params.go
var MainnetParams = Params{
K: defaultGHOSTDAGK,
Name: "c4ex-mainnet",
Net: appmessage.Mainnet,
RPCPort: "21000", // 16110 --> 21000
DefaultPort: "21001", // 16111 --> 21001
DNSSeeds: []string{
// This DNS seeder is run by Wolfie
"dnsseed.c4ex.net",
},