Skip to content

Commit

Permalink
feat: upgrade to avalanchego-v1.11.4
Browse files Browse the repository at this point in the history
  • Loading branch information
vanderheijden86 committed May 9, 2024
1 parent 9d2e2b4 commit 3142ea1
Show file tree
Hide file tree
Showing 11 changed files with 738 additions and 132 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,4 @@ yarn-error.log
# Bazel
/bazel-*

/static_files/subnet-evm
72 changes: 71 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
:small_red_triangle: Avalanche Package
======================================

This is a [Kurtosis package](https://docs.kurtosis.com/concepts-reference/packages) that spins up a non-staking Avalanche node. By default, this package works locally over Docker but can also be deployed on Kubernetes if so desired. You may optionally specify the number of nodes you wish to start locally with a simple `arg` passed in at execution time.

<!-- TOC -->
* [:small_red_triangle: Avalanche Package](#small_red_triangle-avalanche-package)
* [Run this package](#run-this-package)
* [Configuration](#configuration)
* [Custom Subnet Genesis](#custom-subnet-genesis)
* [Fixed Ports](#fixed-ports)
* [Use this package in your package](#use-this-package-in-your-package)
* [Kubernetes Configuration](#kubernetes-configuration)
* [Develop on this package](#develop-on-this-package)
* [Avalanche architecture](#avalanche-architecture)
* [Avalanche Nodes & Chains](#avalanche-nodes--chains)
* [Questions and Answers](#questions-and-answers)
<!-- TOC -->

Run this package
----------------
Open [the Kurtosis playground](https://gitpod.io/#/https://github.com/kurtosis-tech/playground-gitpod) and run:
Expand Down Expand Up @@ -141,3 +154,60 @@ Develop on this package
<!-------------------------------- LINKS ------------------------------->
[install-kurtosis]: https://docs.kurtosis.com/install
[enclaves-reference]: https://docs.kurtosis.com/concepts-reference/enclaves


## Avalanche architecture
### Avalanche Nodes & Chains
```mermaid
graph TD;
subgraph Avalanche Node
Node[Node Server] -->|RPC & WebSocket Endpoints| Routes
Node -->|Gossip Protocol| Gossip
Node -->|Consensus Messages| Consensus
subgraph X Chain
XChain[X Chain] -->|Asset Exchange| XConsensus[Consensus]
Gossip --> XChain
Consensus --> XConsensus
end
subgraph C Chain
CChain[C Chain] -->|Smart Contracts| CConsensus[Consensus]
Gossip --> CChain
Consensus --> CConsensus
end
subgraph P Chain
PChain[P Chain] -->|Validator Management| PConsensus[Consensus]
Gossip --> PChain
Consensus --> PConsensus
end
end
Routes -.->|/ext/bc/...| XChain
Routes -.->|/ext/bc/...| CChain
Routes -.->|/ext/bc/...| PChain
classDef chain fill:green,stroke:#333,stroke-width:4px;
class XChain,CChain,PChain chain;
```

The P, C, and X chains within the Avalanche platform are designed to fulfill distinct roles but are interconnected and communicate with each other:

1. **P-Chain (Platform Chain)**: The P-Chain manages the Avalanche network's validators, tracks active subnets, and enables the creation of new subnets. Communication with the X and C chains can be necessary for:
- Validator management: Validators might have stakes in multiple chains, requiring coordination between the P-Chain (which manages staking and consensus) and other chains.
- Subnet creation and management: As the P-Chain oversees subnets, creating a blockchain on a subnet (whether on the X or C chain) requires coordination to ensure proper setup and validation.

2. **X-Chain (Exchange Chain)**: The X-Chain facilitates asset creation and exchange. Interactions with the P and C chains include:
- Cross-chain asset transfers: Users might want to move assets between the X-Chain and C-Chain for different purposes, such as using X-Chain assets within smart contracts on the C-Chain.
- Staking rewards and fees: Validators and delegators earn rewards for their services, which might involve transferring assets across chains.

3. **C-Chain (Contract Chain)**: The C-Chain supports smart contracts using the Ethereum Virtual Machine (EVM). Reasons for communication with the P and X chains include:
- Smart contracts involving multiple asset types: Contracts might interact with assets from the X-Chain or require information from the P-Chain.
- Decentralized finance (DeFi) applications: DeFi platforms may use assets across the Avalanche ecosystem, necessitating seamless asset flow between chains.

Inter-chain communication in Avalanche is facilitated through cross-chain transfer protocols, enabling assets and information to move securely between the P, C, and X chains. This interconnectedness allows Avalanche to offer a comprehensive blockchain platform supporting various use cases, from simple asset transfers to complex smart contracts and decentralized applications.
10 changes: 5 additions & 5 deletions args.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
"dont_start_subnets": false,
"is_elastic": false,
"ephemeral_ports": true,
"avalanchego_image": "avaplatform/avalanchego:v1.10.1-Subnet-EVM-master",
"avalanchego_image": "avaplatform/avalanchego:v1.11.4",
"node_config": {
"network-id": "1337",
"staking-enabled": false,
"health-check-frequency": "5s"
},
"node_count": 5,
"num_validators": 5,
"node_count": 1,
"num_validators": 1,
"min_cpu": 0,
"min_memory": 0,
"vm_name": "testNet",
"chain_name": "testChain",
"custom_subnet_vm_path": "",
"custom_subnet_vm_path": "/uploaded_plugins/subnet-evm",
"custom_subnet_vm_url": "",
"subnet_genesis_json": "/static_files/genesis.json"
"subnet_genesis_json": "/static_files/genesis.json",
}
15 changes: 14 additions & 1 deletion main.star
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@ def run(plan, args):
networkId = node_config["network-id"]
if not ephemeral_ports:
plan.print("Warning - Ephemeral ports have been disabled will be publishing first node rpc on 9650 and staking on 9651, this can break due to port clash!")

# initalize the builder service with the plan containing node config and the subnet genesis json
builder_service.init(plan, node_config, subnet_genesis_json)
# generate the genesis file
genesis, vmId = builder_service.genesis(plan, networkId ,node_count, vmName)
# launch the nodes
rpc_urls, public_rpc_urls, launch_commands = node_launcher.launch(plan, genesis, image, node_count, ephemeral_ports, min_cpu, min_memory, vmId, dont_start_subnets, custom_subnet_vm_path, custom_subnet_vm_url)
# get the first private rpc url
first_private_rpc_url = rpc_urls[0]
if public_rpc_urls:
rpc_urls = public_rpc_urls
Expand All @@ -52,4 +57,12 @@ def run(plan, args):
output["elastic config"]["export id"] = exportId
output["elastic config"]["import id"] = importId
output["elastic config"]["token symbol"] = "FOO"
return output
# launch the awm relayer
p_chain_api_url = "{0}/ext/P".format(first_private_rpc_url)
info_api_url = "{0}/ext/info".format(first_private_rpc_url)
plan.print("p_chain_api_url: {0}\ninfo_api_url: {1}".format(p_chain_api_url, info_api_url))
source_blockchains = []
destination_blockchains = []
# node_launcher.launch_awm_relayer(plan, p_chain_api_url, info_api_url, source_blockchains, destination_blockchains)

return output
2 changes: 1 addition & 1 deletion src/builder.star
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
static_files = import_module("./static_files_locators.star")
utils = import_module("./utils.star")

GO_IMG = "golang:1.20.4"
GO_IMG = "golang:1.22.2"
ABS_PLUGIN_DIRPATH = "/avalanchego/build/plugins/"

BUILDER_SERVICE_NAME = "builder"
Expand Down
Loading

0 comments on commit 3142ea1

Please sign in to comment.