Bladeren bron

BPF SDK hotfix and devnet startup improvement (#196)

* Tiltfile: Make the guardian k8s_resource depend on solana-devnet

This makes guardian network convergence faster as the guardian pods
don't have to suffer from increasing redeploy back-off delays. This
should impact performance neglibibly as solana-devnet is still the
heaviest build we perform (at the time of this writing saturating a
32-thread Ryzen 9 CPU on my build machine.)

* hotfix bpf-sdk: bump bpf-sdk; use cargo-build-bpf
Stanisław Drozd 4 jaren geleden
bovenliggende
commit
6de425a990
6 gewijzigde bestanden met toevoegingen van 24 en 18 verwijderingen
  1. 1 1
      Tiltfile
  2. 5 3
      solana/Dockerfile
  3. 3 2
      solana/bridge/Cargo.toml
  4. 1 0
      solana/bridge/src/entrypoint.rs
  5. 1 1
      solana/cli/src/main.rs
  6. 13 11
      solana/do.sh

+ 1 - 1
Tiltfile

@@ -83,7 +83,7 @@ def build_bridge_yaml():
 
 
 k8s_yaml_with_ns(build_bridge_yaml())
 k8s_yaml_with_ns(build_bridge_yaml())
 
 
-k8s_resource("guardian", resource_deps=["proto-gen"], port_forwards=[
+k8s_resource("guardian", resource_deps=["proto-gen", "solana-devnet"], port_forwards=[
     port_forward(6060, name="Debug/Status Server [:6060]"),
     port_forward(6060, name="Debug/Status Server [:6060]"),
 ])
 ])
 
 

+ 5 - 3
solana/Dockerfile

@@ -6,11 +6,13 @@ RUN rustup component add rustfmt
 
 
 WORKDIR /usr/src/bridge
 WORKDIR /usr/src/bridge
 
 
+RUN sh -c "$(curl -sSfL https://release.solana.com/v1.5.5/install)"
+
+ENV PATH="/root/.local/share/solana/install/active_release/bin:$PATH"
+
 COPY bpf-sdk-install.sh .
 COPY bpf-sdk-install.sh .
 COPY do.sh .
 COPY do.sh .
 
 
-RUN ./do.sh update
-
 COPY bridge bridge
 COPY bridge bridge
 COPY agent agent
 COPY agent agent
 COPY cli cli
 COPY cli cli
@@ -24,4 +26,4 @@ RUN --mount=type=cache,target=/usr/local,from=rust,source=/usr/local \
     --mount=type=cache,target=bin,from=rust,source=bin \
     --mount=type=cache,target=bin,from=rust,source=bin \
     ./do.sh build bridge && \
     ./do.sh build bridge && \
     mkdir -p /opt/solana/deps && \
     mkdir -p /opt/solana/deps && \
-    cp target/bpfel-unknown-unknown/release/spl_bridge_debug.so /opt/solana/deps/spl_bridge.so
+    cp target/deploy/spl_bridge_debug.so /opt/solana/deps/spl_bridge.so

+ 3 - 2
solana/bridge/Cargo.toml

@@ -10,15 +10,16 @@ license = "Apache-2.0"
 edition = "2018"
 edition = "2018"
 
 
 [features]
 [features]
+default = ["program"]
 no-entrypoint = []
 no-entrypoint = []
-program = ["spl-token/no-entrypoint"]
+program = []
 
 
 [dependencies]
 [dependencies]
 num-derive = "0.2"
 num-derive = "0.2"
 num-traits = "0.2"
 num-traits = "0.2"
 remove_dir_all = "=0.5.0"
 remove_dir_all = "=0.5.0"
 solana-program = "=1.5.5"
 solana-program = "=1.5.5"
-spl-token = { version = "=3.0.1" }
+spl-token = { version = "=3.0.1", features = ["no-entrypoint"] }
 thiserror = "1.0"
 thiserror = "1.0"
 byteorder = "1.3.4"
 byteorder = "1.3.4"
 zerocopy = "0.3.0"
 zerocopy = "0.3.0"

+ 1 - 0
solana/bridge/src/entrypoint.rs

@@ -15,6 +15,7 @@ fn process_instruction<'a>(
     accounts: &'a [AccountInfo<'a>],
     accounts: &'a [AccountInfo<'a>],
     instruction_data: &[u8],
     instruction_data: &[u8],
 ) -> ProgramResult {
 ) -> ProgramResult {
+    msg!("In bridge entrypoint");
     if let Err(error) = Bridge::process(program_id, accounts, instruction_data) {
     if let Err(error) = Bridge::process(program_id, accounts, instruction_data) {
         // catch the error so we can print it
         // catch the error so we can print it
         error.print::<Error>();
         error.print::<Error>();

+ 1 - 1
solana/cli/src/main.rs

@@ -56,7 +56,7 @@ fn command_deploy_bridge(
     bridge: &Pubkey,
     bridge: &Pubkey,
     initial_guardian: Vec<[u8; 20]>,
     initial_guardian: Vec<[u8; 20]>,
 ) -> CommmandResult {
 ) -> CommmandResult {
-    println!("Deploying bridge program");
+    println!("Deploying bridge program {}", bridge);
 
 
     let minimum_balance_for_rent_exemption = config
     let minimum_balance_for_rent_exemption = config
         .rpc_client
         .rpc_client

+ 13 - 11
solana/do.sh

@@ -24,21 +24,22 @@ Supported projects:
 EOF
 EOF
 }
 }
 
 
-sdkParentDir=bin
-sdkDir="$sdkParentDir"/bpf-sdk
-profile=bpfel-unknown-unknown/release
+sdkDir=$HOME/.local/share/solana/install/active_release/bin/sdk/bpf
+profile=deploy
 
 
 perform_action() {
 perform_action() {
     set -e
     set -e
+    set -x
     projectDir="$PWD"/$2
     projectDir="$PWD"/$2
     targetDir=target
     targetDir=target
     case "$1" in
     case "$1" in
     build)
     build)
-        if [[ -f "$projectDir"/Xargo.toml ]]; then
-          "$sdkDir"/rust/build.sh "$projectDir"
-
+	if [[ -f "$projectDir"/Xargo.toml ]]; then
+	  # "$sdkDir"/rust/build.sh "$projectDir"
           so_path="$targetDir/$profile"
           so_path="$targetDir/$profile"
+	  cargo build-bpf --manifest-path "$projectDir/Cargo.toml"
 	  files=`find $so_path -maxdepth 1 -type f \! -name "*_debug.so" -name  "*.so"`
 	  files=`find $so_path -maxdepth 1 -type f \! -name "*_debug.so" -name  "*.so"`
+	  echo "pwd: $PWD"
 	  for file in $files
 	  for file in $files
 	  do
 	  do
 	    cp $file ${file/.so/_debug.so} # Copy with rename
 	    cp $file ${file/.so/_debug.so} # Copy with rename
@@ -134,10 +135,10 @@ perform_action() {
             cargo test --features=program ${@:3}
             cargo test --features=program ${@:3}
         )
         )
         ;;
         ;;
-    update)
-        mkdir -p $sdkParentDir
-        ./bpf-sdk-install.sh $sdkParentDir
-        ;;
+    # update)
+    #     mkdir -p $sdkParentDir
+    #     ./bpf-sdk-install.sh $sdkParentDir
+    #     ;;
     *)
     *)
         echo "Error: Unknown command"
         echo "Error: Unknown command"
         usage
         usage
@@ -156,7 +157,8 @@ else
         exit
         exit
     fi
     fi
     if [[ ! -d "$sdkDir" ]]; then
     if [[ ! -d "$sdkDir" ]]; then
-        ./do.sh update
+	true
+        # ./do.sh update
     fi
     fi
 fi
 fi