Skip to content

Commit

Permalink
Merge pull request #732 from ava-labs/avago-1.11.11
Browse files Browse the repository at this point in the history
Avago 1.11.11 compat for c-chain
  • Loading branch information
felipemadero authored Sep 10, 2024
2 parents a67443b + 34b19d1 commit 90c2a0e
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 147 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ go 1.21.12
toolchain go1.22.3

require (
github.com/ava-labs/avalanchego v1.11.11-0.20240814014627-2eef64141457
github.com/ava-labs/coreth v0.13.8-fixed-genesis-upgrade.0.20240813194342-7635a96aa180
github.com/ava-labs/avalanchego v1.11.11
github.com/ava-labs/coreth v0.13.8-fixed-genesis-upgrade.0.20240815193440-a96bc921e732
github.com/ethereum/go-ethereum v1.13.8
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0
github.com/onsi/ginkgo/v2 v2.13.1
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/ava-labs/avalanchego v1.11.11-0.20240814014627-2eef64141457 h1:yT27Bn/2+SnJR1YPIscqznSlvpnR3TEGfbS7wdB1Gmg=
github.com/ava-labs/avalanchego v1.11.11-0.20240814014627-2eef64141457/go.mod h1:UkyrRDXK2E15Lq2abyae2Pt+JsWvgsg1pe0/AtoMyAM=
github.com/ava-labs/coreth v0.13.8-fixed-genesis-upgrade.0.20240813194342-7635a96aa180 h1:6aIHp7wbyGVYdhHVQUbG7BEcbCMEQ5SYopPPJyipyvk=
github.com/ava-labs/coreth v0.13.8-fixed-genesis-upgrade.0.20240813194342-7635a96aa180/go.mod h1:/wNBVq7J7wlC2Kbov7kk6LV5xZvau7VF9zwTVOeyAjY=
github.com/ava-labs/avalanchego v1.11.11 h1:MIQq8xRavRj4ZXHA4G+aMiymig7SOScGOG1SApmMvBc=
github.com/ava-labs/avalanchego v1.11.11/go.mod h1:yFx3V31Jy9NFa8GZlgGnwiVf8KGjeF2+Uc99l9Scd/8=
github.com/ava-labs/coreth v0.13.8-fixed-genesis-upgrade.0.20240815193440-a96bc921e732 h1:wlhGJbmb7s3bU2QWtxKjscGjfHknQiq+cVhhUjONsB8=
github.com/ava-labs/coreth v0.13.8-fixed-genesis-upgrade.0.20240815193440-a96bc921e732/go.mod h1:RkQLaQ961Xe/sUb3ycn4Qi18vPPuEetTqDf2eDcquAs=
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
Expand Down
11 changes: 6 additions & 5 deletions local/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
"github.com/ava-labs/avalanchego/wallet/chain/p"
pbuilder "github.com/ava-labs/avalanchego/wallet/chain/p/builder"
psigner "github.com/ava-labs/avalanchego/wallet/chain/p/signer"
pwallet "github.com/ava-labs/avalanchego/wallet/chain/p/wallet"
"github.com/ava-labs/avalanchego/wallet/subnet/primary"
"github.com/ava-labs/avalanchego/wallet/subnet/primary/common"
"go.uber.org/zap"
Expand Down Expand Up @@ -826,8 +827,8 @@ func (ln *localNetwork) restartNodes(
type wallet struct {
addr ids.ShortID
pCTX *pbuilder.Context
pWallet p.Wallet
pBackend p.Backend
pWallet pwallet.Wallet
pBackend pwallet.Backend
pBuilder pbuilder.Builder
pSigner psigner.Signer
xCTX *xbuilder.Context
Expand Down Expand Up @@ -879,10 +880,10 @@ func newWallet(
var w wallet
w.addr = privateKey.PublicKey().Address()
w.pCTX = pCTX
w.pBackend = p.NewBackend(pCTX, pUTXOs, subnetOwners)
w.pBackend = pwallet.NewBackend(pCTX, pUTXOs, subnetOwners)
w.pBuilder = pbuilder.New(kc.Addresses(), pCTX, w.pBackend)
w.pSigner = psigner.New(kc, w.pBackend)
w.pWallet = p.NewWallet(w.pBuilder, w.pSigner, pClient, w.pBackend)
w.pWallet = pwallet.New(p.NewClient(pClient, w.pBackend), w.pBuilder, w.pSigner)

xBackend := x.NewBackend(xCTX, xUTXOs)
xBuilder := xbuilder.New(kc.Addresses(), xCTX, xBackend)
Expand All @@ -895,7 +896,7 @@ func newWallet(

func (w *wallet) reload(uri string) {
pClient := platformvm.NewClient(uri)
w.pWallet = p.NewWallet(w.pBuilder, w.pSigner, pClient, w.pBackend)
w.pWallet = pwallet.New(p.NewClient(pClient, w.pBackend), w.pBuilder, w.pSigner)
}

// add all nodes as validators of the primary network, in case they are not
Expand Down
4 changes: 2 additions & 2 deletions local/default/flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"health-check-frequency":"2s",
"api-admin-enabled":true,
"index-enabled":true,
"log-display-level":"ERROR",
"log-level": "ERROR"
"log-display-level":"INFO",
"log-level": "INFO"
}
1 change: 1 addition & 0 deletions local/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func verifyProtocol(
[]uint32{},
knownPeersFilter,
knownPeersSalt,
false,
)
if err != nil {
errCh <- err
Expand Down
6 changes: 3 additions & 3 deletions scripts/tests.e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ fi
ANR_PATH=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)

# this avago and subnet-evm versions must have compatibility at rpc protocol level
DEFAULT_VERSION_1=v1.11.5
DEFAULT_SUBNET_EVM_VERSION=v0.6.4
DEFAULT_VERSION_1=v1.11.11
DEFAULT_SUBNET_EVM_VERSION=v0.6.9

# used standalone, without interaction with subnet-evm, no compatibility needed
DEFAULT_VERSION_2=v1.11.4
DEFAULT_VERSION_2=v1.11.11

if [ $# == 0 ]; then
VERSION_1=$DEFAULT_VERSION_1
Expand Down
131 changes: 2 additions & 129 deletions tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ var (
newNode2NodeID = ""
pausedNodeURI = ""
pausedNodeName = "node1"
createdSubnetID = ""
elasticAssetID = ""
newSubnetID = ""
customNodeConfigs = map[string]string{
"node1": `{"api-admin-enabled":true}`,
Expand All @@ -73,36 +71,12 @@ var (
numNodes = uint32(5)
subnetParticipants = []string{"node1", "node2", "node3"}
newParticipantNode = "new_participant_node"
delegateeNode = "permissionlessNode"
subnetParticipants2 = []string{"node1", "node2", newParticipantNode}
existingNodes = []string{"node1", "node2", "node3", "node4", "node5"}
disjointNewSubnetParticipants = [][]string{
{"n0", "n1", "n2", "n3", "n4"},
{"n5", "n6", "n7", "n8", "n9"},
}
testElasticSubnetConfig = rpcpb.ElasticSubnetSpec{
SubnetId: "",
AssetName: "BLIZZARD",
AssetSymbol: "BRRR",
InitialSupply: 240000000,
MaxSupply: 720000000,
MinConsumptionRate: 100000,
MaxConsumptionRate: 120000,
MinValidatorStake: 2000,
MaxValidatorStake: 3000000,
MinStakeDuration: 14 * 24,
MaxStakeDuration: 365 * 24,
MinDelegationFee: 20000,
MinDelegatorStake: 25,
MaxValidatorWeightFactor: 5,
UptimeRequirement: 0.8 * 1_000_000,
}

testValidatorConfig = rpcpb.PermissionlessStakerSpec{
StakedTokenAmount: 2000,
StartTime: time.Now().Add(1 * time.Hour).UTC().Format(server.TimeParseLayout),
StakeDuration: 336,
}
)

func init() {
Expand Down Expand Up @@ -927,107 +901,6 @@ var _ = ginkgo.Describe("[Start/Remove/Restart/Add/Stop]", func() {
})
})

ginkgo.It("transform subnet to elastic subnets", func() {
var elasticSubnetID string
ginkgo.By("add 1 subnet", func() {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
resp, err := cli.CreateSubnets(ctx, []*rpcpb.SubnetSpec{{}})
cancel()
gomega.Ω(err).Should(gomega.BeNil())
gomega.Ω(len(resp.SubnetIds)).Should(gomega.Equal(1))
gomega.Ω(len(resp.ClusterInfo.Subnets)).Should(gomega.Equal(5))
createdSubnetID = resp.SubnetIds[0]
})
ginkgo.By("check expected non elastic status", func() {
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
status, err := cli.Status(ctx)
cancel()
gomega.Ω(err).Should(gomega.BeNil())
subnetInfo := status.ClusterInfo.Subnets[createdSubnetID]
gomega.Ω(subnetInfo.IsElastic).Should(gomega.Equal(false))
gomega.Ω(subnetInfo.ElasticSubnetId).Should(gomega.Equal(ids.Empty.String()))
})
ginkgo.By("transform 1 subnet to elastic subnet", func() {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
defer cancel()
testElasticSubnetConfig.SubnetId = createdSubnetID
response, err := cli.TransformElasticSubnets(ctx, []*rpcpb.ElasticSubnetSpec{&testElasticSubnetConfig})
gomega.Ω(err).Should(gomega.BeNil())
gomega.Ω(len(response.TxIds)).Should(gomega.Equal(1))
gomega.Ω(len(response.AssetIds)).Should(gomega.Equal(1))
elasticAssetID = response.AssetIds[0]
})
ginkgo.By("check expected elastic status", func() {
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
status, err := cli.Status(ctx)
cancel()
gomega.Ω(err).Should(gomega.BeNil())
subnetInfo := status.ClusterInfo.Subnets[createdSubnetID]
gomega.Ω(subnetInfo.IsElastic).Should(gomega.Equal(true))
gomega.Ω(subnetInfo.ElasticSubnetId).ShouldNot(gomega.Equal(ids.Empty.String()))
elasticSubnetID = subnetInfo.ElasticSubnetId
})
ginkgo.By("transforming a subnet with same subnetID to elastic subnet will fail", func() {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
defer cancel()
testElasticSubnetConfig.SubnetId = createdSubnetID
_, err := cli.TransformElasticSubnets(ctx, []*rpcpb.ElasticSubnetSpec{&testElasticSubnetConfig})
gomega.Ω(err).Should(gomega.HaveOccurred())
})
ginkgo.By("save snapshot with elastic info", func() {
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
_, err := cli.SaveSnapshot(ctx, "elastic_snapshot", false)
cancel()
gomega.Ω(err).Should(gomega.BeNil())
})
ginkgo.By("load snapshot with elastic info", func() {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
_, err := cli.LoadSnapshot(ctx, "elastic_snapshot", false)
cancel()
gomega.Ω(err).Should(gomega.BeNil())
})
ginkgo.By("check expected elastic status", func() {
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
status, err := cli.Status(ctx)
cancel()
gomega.Ω(err).Should(gomega.BeNil())
subnetInfo := status.ClusterInfo.Subnets[createdSubnetID]
gomega.Ω(subnetInfo.IsElastic).Should(gomega.Equal(true))
gomega.Ω(subnetInfo.ElasticSubnetId).Should(gomega.Equal(elasticSubnetID))
})
ginkgo.By("remove snapshot with elastic info", func() {
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
_, err := cli.RemoveSnapshot(ctx, "elastic_snapshot")
cancel()
gomega.Ω(err).Should(gomega.BeNil())
})
})

ginkgo.It("add permissionless validator to elastic subnets", func() {
ginkgo.By("adding a permissionless validator to elastic subnet", func() {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
defer cancel()
testValidatorConfig.SubnetId = createdSubnetID
testValidatorConfig.AssetId = elasticAssetID
testValidatorConfig.NodeName = delegateeNode
_, err := cli.AddPermissionlessValidator(ctx, []*rpcpb.PermissionlessStakerSpec{&testValidatorConfig})
gomega.Ω(err).Should(gomega.BeNil())
})
})

ginkgo.It("add permissionless delegator to elastic subnets", func() {
ginkgo.By("adding a permissionless delegator to permissionless validator", func() {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
defer cancel()
testValidatorConfig.SubnetId = createdSubnetID
testValidatorConfig.AssetId = elasticAssetID
testValidatorConfig.NodeName = delegateeNode
testValidatorConfig.StakedTokenAmount = 35
_, err := cli.AddPermissionlessDelegator(ctx, []*rpcpb.PermissionlessStakerSpec{&testValidatorConfig})
gomega.Ω(err).Should(gomega.BeNil())
})
})

ginkgo.It("snapshots + blockchain creation", func() {
var originalUris []string
var originalSubnets []string
Expand All @@ -1037,15 +910,15 @@ var _ = ginkgo.Describe("[Start/Remove/Restart/Add/Stop]", func() {
originalUris, err = cli.URIs(ctx)
cancel()
gomega.Ω(err).Should(gomega.BeNil())
gomega.Ω(len(originalUris)).Should(gomega.Equal(8))
gomega.Ω(len(originalUris)).Should(gomega.Equal(7))
})
ginkgo.By("get original subnets", func() {
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
status, err := cli.Status(ctx)
cancel()
gomega.Ω(err).Should(gomega.BeNil())
numSubnets := len(status.ClusterInfo.Subnets)
gomega.Ω(numSubnets).Should(gomega.Equal(5))
gomega.Ω(numSubnets).Should(gomega.Equal(4))
originalSubnets = maps.Keys(status.ClusterInfo.Subnets)
})
ginkgo.By("check there are no snapshots", func() {
Expand Down
7 changes: 5 additions & 2 deletions utils/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"time"

"github.com/ava-labs/avalanchego/upgrade"
"github.com/ava-labs/avalanchego/utils/crypto/bls"
"github.com/ava-labs/avalanchego/utils/formatting"
"github.com/ava-labs/avalanchego/vms/platformvm/signer"
Expand All @@ -26,9 +27,11 @@ const (

func generateCchainGenesis() ([]byte, error) {
cChainGenesisMap := map[string]interface{}{}
cChainGenesisMap["config"] = coreth_params.AvalancheLocalChainConfig
chainConfig := *coreth_params.TestChainConfig
chainConfig.ChainID = coreth_params.AvalancheLocalChainID
cChainGenesisMap["config"] = chainConfig
cChainGenesisMap["timestamp"] = upgrade.InitiallyActiveTime.Unix()
cChainGenesisMap["nonce"] = hexa0Str
cChainGenesisMap["timestamp"] = hexa0Str
cChainGenesisMap["extraData"] = "0x00"
cChainGenesisMap["gasLimit"] = "0x5f5e100"
cChainGenesisMap["difficulty"] = hexa0Str
Expand Down

0 comments on commit 90c2a0e

Please sign in to comment.