Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

Add Spark Support #1

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions cl/clparams/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const (
SepoliaNetwork NetworkType = 11155111
GnosisNetwork NetworkType = 100
ChiadoNetwork NetworkType = 10200
SparkNetwork NetworkType = 123
)

const (
Expand Down Expand Up @@ -263,6 +264,26 @@ var NetworkConfigs map[NetworkType]NetworkConfig = map[NetworkType]NetworkConfig
ContractDeploymentBlock: 155530,
BootNodes: HoleskyBootstrapNodes,
},

SparkNetwork: {
GossipMaxSize: 1 << 20, // 1 MiB
GossipMaxSizeBellatrix: 10485760,
MaxChunkSize: 1 << 20, // 1 MiB
AttestationSubnetCount: 64,
AttestationPropagationSlotRange: 32,
MaxRequestBlocks: 1 << 10, // 1024
TtfbTimeout: ReqTimeout,
RespTimeout: RespTimeout,
MaximumGossipClockDisparity: 500 * time.Millisecond,
MessageDomainInvalidSnappy: [4]byte{00, 00, 00, 00},
MessageDomainValidSnappy: [4]byte{01, 00, 00, 00},
Eth2key: "eth2",
AttSubnetKey: "attnets",
SyncCommsSubnetKey: "syncnets",
MinimumPeersInSubnetSearch: 20,
ContractDeploymentBlock: 19475089,
BootNodes: GnosisBootstrapNodes,
},
}

// Trusted checkpoint sync endpoints: https://eth-clients.github.io/checkpoint-sync-endpoints/
Expand Down Expand Up @@ -908,6 +929,41 @@ func chiadoConfig() BeaconChainConfig {
return cfg
}

func sparkConfig() BeaconChainConfig {
cfg := MainnetBeaconConfig
cfg.MinGenesisTime = 1638968400
cfg.MinGenesisActiveValidatorCount = 4096
cfg.GenesisDelay = 6000
cfg.SecondsPerSlot = 5
cfg.Eth1FollowDistance = 1024
cfg.ConfigName = "spark"
cfg.ChurnLimitQuotient = 1 << 12
cfg.GenesisForkVersion = 0x00000064
cfg.SecondsPerETH1Block = 6
cfg.DepositChainID = uint64(SparkNetwork)
cfg.DepositNetworkID = uint64(SparkNetwork)
cfg.AltairForkEpoch = 512
cfg.AltairForkVersion = 0x01000064
cfg.BellatrixForkEpoch = 385536
cfg.BellatrixForkVersion = 0x02000064
cfg.CapellaForkEpoch = 648704
cfg.CapellaForkVersion = 0x03000064
cfg.TerminalTotalDifficulty = "8626000000000000000000058750000000000000000000"
cfg.DepositContractAddress = "0x0B98057eA310F4d31F2a452B414647007d1645d9"
cfg.BaseRewardFactor = 25
cfg.SlotsPerEpoch = 16
cfg.EpochsPerSyncCommitteePeriod = 512
cfg.DenebForkEpoch = 889856
cfg.DenebForkVersion = 0x04000064
cfg.InactivityScoreRecoveryRate = 16
cfg.InactivityScoreBias = 4
cfg.MaxWithdrawalsPerPayload = 8
cfg.MaxValidatorsPerWithdrawalsSweep = 8192
cfg.MaxPerEpochActivationChurnLimit = 2
cfg.InitializeForkSchedule()
return cfg
}

func (b *BeaconChainConfig) GetMinSlashingPenaltyQuotient(version StateVersion) uint64 {
switch version {
case Phase0Version:
Expand Down Expand Up @@ -950,6 +1006,7 @@ var BeaconConfigs map[NetworkType]BeaconChainConfig = map[NetworkType]BeaconChai
HoleskyNetwork: holeskyConfig(),
GnosisNetwork: gnosisConfig(),
ChiadoNetwork: chiadoConfig(),
SparkNetwork: sparkConfig(),
}

// Eth1DataVotesLength returns the maximum length of the votes on the Eth1 data,
Expand Down Expand Up @@ -1030,6 +1087,9 @@ func GetConfigsByNetworkName(net string) (*NetworkConfig, *BeaconChainConfig, Ne
case networkname.HoleskyChainName:
networkCfg, beaconCfg := GetConfigsByNetwork(HoleskyNetwork)
return networkCfg, beaconCfg, HoleskyNetwork, nil
case networkname.SparkChainName:
networkCfg, beaconCfg := GetConfigsByNetwork(SparkNetwork)
return networkCfg, beaconCfg, SparkNetwork, nil
default:
return nil, nil, MainnetNetwork, fmt.Errorf("chain not found")
}
Expand Down Expand Up @@ -1061,6 +1121,7 @@ func EmbeddedSupported(id uint64) bool {
id == 5 ||
id == 17000 ||
id == 11155111 ||
id == 123 ||
id == 100 // ||
//id == 10200
}
Expand Down
2 changes: 2 additions & 0 deletions common/paths/paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ func DataDirForNetwork(datadir string, network string) string {
return networkDataDirCheckingLegacy(datadir, "gnosis")
case networkname.ChiadoChainName:
return networkDataDirCheckingLegacy(datadir, "chiado")
case networkname.SparkChainName:
return networkDataDirCheckingLegacy(datadir, "spark")

default:
return datadir
Expand Down
13 changes: 13 additions & 0 deletions core/genesis_write.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,17 @@ func ChiadoGenesisBlock() *types.Genesis {
}
}

func SparkGenesisBlock() *types.Genesis {
return &types.Genesis{
Config: params.SparkChainConfig,
Timestamp: 0,
AuRaSeal: common.FromHex("0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
GasLimit: 0x989680,
Difficulty: big.NewInt(0x20000),
Alloc: readPrealloc("allocs/spark.json"),
}
}

// Pre-calculated version of:
//
// DevnetSignPrivateKey = crypto.HexToECDSA(sha256.Sum256([]byte("erigon devnet key")))
Expand Down Expand Up @@ -675,6 +686,8 @@ func GenesisBlockByChainName(chain string) *types.Genesis {
return GnosisGenesisBlock()
case networkname.ChiadoChainName:
return ChiadoGenesisBlock()
case networkname.SparkChainName:
return SparkGenesisBlock()
default:
return nil
}
Expand Down
2 changes: 2 additions & 0 deletions erigon-lib/chain/networkname/network_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const (
GnosisChainName = "gnosis"
BorE2ETestChain2ValName = "bor-e2e-test-2Val"
ChiadoChainName = "chiado"
SparkChainName = "spark"
)

var All = []string{
Expand All @@ -26,4 +27,5 @@ var All = []string{
BorDevnetChainName,
GnosisChainName,
ChiadoChainName,
SparkChainName,
}
7 changes: 7 additions & 0 deletions params/bootnodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ var ChiadoBootnodes = []string{
"enode://f7e62226a64a2ccc0ada8b032b33c4389464562f87135a3e0d5bdb814fab717d58db5d142c453b071d08b4e0ffd9c5aff4a6d4441c2041401634f10d7962f885@35.210.126.23:30303",
}

var SparkBootnodes = []string{
"enode://008870748a938f4a6599d83c1238f719b0a67e4ae2d32e7542628c43f8af4185bd54124a0a4b80ec54a95098f8ae08174c5bc7fadb0349c0b70332dff22af061@35.205.144.49:30303",
"enode://d377e5a6fb2d0b44b98e1382c9c16633bdd407843f83f21d17b09fdfa5f79175eb55113c6789fa50b7717d08cb3b24b7485951afa0fe9ca696919202e35170a6@34.34.138.246:30303",
}

const dnsPrefix = "enrtree://AKA3AM6LPBYEUDMVNU3BSVQJ5AD45Y7YPOHJLEF6W26QOE4VTUDPE@"

// KnownDNSNetwork returns the address of a public DNS-based node list for the given
Expand Down Expand Up @@ -177,6 +182,8 @@ func BootnodeURLsOfChain(chain string) []string {
return GnosisBootnodes
case networkname.ChiadoChainName:
return ChiadoBootnodes
case networkname.SparkChainName:
return SparkBootnodes
default:
return []string{}
}
Expand Down
70 changes: 70 additions & 0 deletions params/chainspecs/spark.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"ChainName": "spark",
"chainId": 123,
"consensus": "aura",
"homesteadBlock": 0,
"eip150Block": 0,
"eip155Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 442212,
"petersburgBlock": 1300000,
"istanbulBlock": 1300000,
"berlinBlock": 1300000,
"londonBlock": 14707000,
"burntContract": {
"0": "0x1559000000000000000000000000000000000000"
},
"aura": {
"stepDuration": 5,
"blockReward": 0,
"maximumUncleCountTransition": 0,
"maximumUncleCount": 0,
"validators": {
"multi": {
"0": {
"list": ["0xba7829b381f07cca0d186bdf619fdc6c7f756d0a"]
},
"1000": {
"safeContract": "0xC8c3a332f9e4CE6bfFFcf967026cB006Db2311c7"
},
"6905799": {
"list": [
"0x379e81df609e8235c9026f25a379d49a27b10d30",
"0xba7829b381f07cca0d186bdf619fdc6c7f756d0a",
"0xe4cc9b2836ba373c3ccf473cbb15ed07007963ee",
"0xbc048d3064fd912b40a9aadcf67a14fd4601db77"
]
},
"6910120": {
"safeContract": "0xC8c3a332f9e4CE6bfFFcf967026cB006Db2311c7"
},
"6925000": {
"list": [
"0x379e81df609e8235c9026f25a379d49a27b10d30",
"0xba7829b381f07cca0d186bdf619fdc6c7f756d0a",
"0xe4cc9b2836ba373c3ccf473cbb15ed07007963ee",
"0xbc048d3064fd912b40a9aadcf67a14fd4601db77"
]
},
"13608000": {
"list": [
"0xba7829b381f07cca0d186bdf619fdc6c7f756d0a",
"0xe4cc9b2836ba373c3ccf473cbb15ed07007963ee",
"0xbc048d3064fd912b40a9aadcf67a14fd4601db77"
]
},
"13639200": {
"safeContract": "0x8C682051D70301A0ca913Ce0A0e71539702E1122"
}
}
},
"blockRewardContractTransitions": {
"13639200": "0xEa2151b6095CB76ECc57A57DE166728dd9b53Ed9"
}
},
"alloc": {
"0xba7829b381f07cca0d186bdf619fdc6c7f756d0a": {
"balance": "300000000000000000000000000"
}
}
}
8 changes: 8 additions & 0 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ var (
BorDevnetGenesisHash = libcommon.HexToHash("0x5a06b25b0c6530708ea0b98a3409290e39dce6be7f558493aeb6e4b99a172a87")
GnosisGenesisHash = libcommon.HexToHash("0x4f1dd23188aab3a76b463e4af801b52b1248ef073c648cbdc4c9333d3da79756")
ChiadoGenesisHash = libcommon.HexToHash("0xada44fd8d2ecab8b08f256af07ad3e777f17fb434f8f8e678b312f576212ba9a")
SparkGenesisHash = libcommon.HexToHash("0xfd643f387cd7386d21e8d34f8762188865789196dee77c98f8210dbbc15616ae")
)

var (
Expand Down Expand Up @@ -146,6 +147,8 @@ var (

ChiadoChainConfig = readChainSpec("chainspecs/chiado.json")

SparkChainConfig = readChainSpec("chainspecs/spark.json")

CliqueSnapshot = NewSnapshotConfig(10, 1024, 16384, true, "")

TestChainConfig = &chain.Config{
Expand Down Expand Up @@ -230,6 +233,9 @@ func ChainConfigByChainName(chain string) *chain.Config {
return GnosisChainConfig
case networkname.ChiadoChainName:
return ChiadoChainConfig
case networkname.SparkChainName:
return SparkChainConfig

default:
return nil
}
Expand Down Expand Up @@ -257,6 +263,8 @@ func GenesisHashByChainName(chain string) *libcommon.Hash {
return &GnosisGenesisHash
case networkname.ChiadoChainName:
return &ChiadoGenesisHash
case networkname.SparkChainName:
return &SparkGenesisHash
default:
return nil
}
Expand Down