Repository: ObolNetwork/charon

Issue:
New default partial deposits in compounding mode
# 🎯 Problem to be solved

Apply default partial deposits `[1,8,32,256]` when `--compounding` flag is enabled. Otherwise, the default values remain `[1,32]`. 

# 🛠️ Proposed solution
- [x] Change default partial deposit values

# 🧪 Tests
- [x] Tested by new automated unit/integration/smoke tests
- [ ] Manually tested on core team/canary/test clusters
- [ ] Manually tested on local compose simnet


Discussion:

Solution patch:
diff --git a/cmd/createcluster.go b/cmd/createcluster.go
index c65548af..842b86cf 100644
--- a/cmd/createcluster.go
+++ b/cmd/createcluster.go
@@ -227,7 +227,7 @@ func runCreateCluster(ctx context.Context, w io.Writer, conf clusterConfig) erro
 	}
 
 	if len(depositAmounts) == 0 {
-		depositAmounts = deposit.DefaultDepositAmounts()
+		depositAmounts = deposit.DefaultDepositAmounts(conf.Compounding)
 	}
 
 	if len(secrets) == 0 {
diff --git a/dkg/dkg.go b/dkg/dkg.go
index 0ac82cca..6d9ebc08 100644
--- a/dkg/dkg.go
+++ b/dkg/dkg.go
@@ -253,7 +253,7 @@ func Run(ctx context.Context, conf Config) (err error) {
 	depositAmounts := def.DepositAmounts
 	if len(depositAmounts) == 0 {
 		if cluster.SupportPartialDeposits(def.Version) {
-			depositAmounts = deposit.DefaultDepositAmounts()
+			depositAmounts = deposit.DefaultDepositAmounts(def.Compounding)
 		} else {
 			depositAmounts = []eth2p0.Gwei{deposit.DefaultDepositAmount}
 		}
diff --git a/eth2util/deposit/deposit.go b/eth2util/deposit/deposit.go
index 57178567..8153aa94 100644
--- a/eth2util/deposit/deposit.go
+++ b/eth2util/deposit/deposit.go
@@ -291,8 +291,14 @@ func DedupAmounts(amounts []eth2p0.Gwei) []eth2p0.Gwei {
 	return result
 }
 
-// DefaultDepositAmounts returns the default deposit amounts: 1ETH and 32ETH.
-func DefaultDepositAmounts() []eth2p0.Gwei {
+// DefaultDepositAmounts returns the default deposit amounts:
+// --compounding=false: [1,32] ETH,
+// --compounding=true: [1,8,32,256] ETH.
+func DefaultDepositAmounts(compounding bool) []eth2p0.Gwei {
+	if compounding {
+		return []eth2p0.Gwei{MinDepositAmount, 8 * OneEthInGwei, 32 * OneEthInGwei, 256 * OneEthInGwei}
+	}
+
 	return []eth2p0.Gwei{MinDepositAmount, DefaultDepositAmount}
 }
 



Test patch:
diff --git a/cmd/createcluster_internal_test.go b/cmd/createcluster_internal_test.go
index d3aad308..ebde67b7 100644
--- a/cmd/createcluster_internal_test.go
+++ b/cmd/createcluster_internal_test.go
@@ -372,7 +372,7 @@ func testCreateCluster(t *testing.T, conf clusterConfig, def cluster.Definition,
 		vals := make(map[string]struct{})
 		amounts := deposit.DedupAmounts(deposit.EthsToGweis(conf.DepositAmounts))
 		if len(amounts) == 0 {
-			amounts = deposit.DefaultDepositAmounts()
+			amounts = deposit.DefaultDepositAmounts(conf.Compounding)
 		}
 		for _, val := range lock.Validators {
 			vals[val.PublicKeyHex()] = struct{}{}
diff --git a/dkg/dkg_test.go b/dkg/dkg_test.go
index cc519e22..d1a26882 100644
--- a/dkg/dkg_test.go
+++ b/dkg/dkg_test.go
@@ -418,7 +418,7 @@ func verifyDistValidators(t *testing.T, lock cluster.Lock, def cluster.Definitio
 			if !cluster.SupportPartialDeposits(def.Version) {
 				depositAmounts = []eth2p0.Gwei{deposit.DefaultDepositAmount}
 			} else {
-				depositAmounts = deposit.DefaultDepositAmounts()
+				depositAmounts = deposit.DefaultDepositAmounts(def.Compounding)
 			}
 		}
 		require.Len(t, val.PartialDepositData, len(depositAmounts))
diff --git a/eth2util/deposit/deposit_test.go b/eth2util/deposit/deposit_test.go
index cee12e5a..225e10e6 100644
--- a/eth2util/deposit/deposit_test.go
+++ b/eth2util/deposit/deposit_test.go
@@ -155,12 +155,21 @@ func TestVerifyDepositAmounts(t *testing.T) {
 }
 
 func TestDefaultDepositAmounts(t *testing.T) {
-	amounts := deposit.DefaultDepositAmounts()
+	amounts := deposit.DefaultDepositAmounts(false)
 
 	require.Equal(t, []eth2p0.Gwei{
 		deposit.MinDepositAmount,
 		deposit.DefaultDepositAmount,
 	}, amounts)
+
+	amounts = deposit.DefaultDepositAmounts(true)
+
+	require.Equal(t, []eth2p0.Gwei{
+		deposit.MinDepositAmount,
+		8 * deposit.OneEthInGwei,
+		32 * deposit.OneEthInGwei,
+		256 * deposit.OneEthInGwei,
+	}, amounts)
 }
 
 func TestEthsToGweis(t *testing.T) {