Browse Source

:arrow_up: Upgrading Anchor, Solana and Rust (#172)

Danilo Guanabara 5 months ago
parent
commit
e93b4fd039

+ 3 - 3
.github/workflows/publish-bolt-crates.yml

@@ -49,7 +49,7 @@ jobs:
       - name: install rust
       - name: install rust
         uses: dtolnay/rust-toolchain@stable
         uses: dtolnay/rust-toolchain@stable
         with:
         with:
-          toolchain: 1.81.0
+          toolchain: stable
 
 
       - name: Cache rust
       - name: Cache rust
         uses: Swatinem/rust-cache@v2
         uses: Swatinem/rust-cache@v2
@@ -72,7 +72,7 @@ jobs:
       - name: Run fmt
       - name: Run fmt
         run: cargo fmt -- --check --verbose
         run: cargo fmt -- --check --verbose
       - name: Run clippy
       - name: Run clippy
-        run: cargo clippy -- --deny=warnings
+        run: cargo clippy -- --deny=warnings --allow=unexpected_cfgs
 
 
   test-and-publish:
   test-and-publish:
     needs: [clippy-lint]
     needs: [clippy-lint]
@@ -82,7 +82,7 @@ jobs:
       - name: install rust
       - name: install rust
         uses: dtolnay/rust-toolchain@stable
         uses: dtolnay/rust-toolchain@stable
         with:
         with:
-          toolchain: 1.81.0
+          toolchain: stable
 
 
       - name: Cache rust
       - name: Cache rust
         uses: Swatinem/rust-cache@v2
         uses: Swatinem/rust-cache@v2

+ 2 - 2
.github/workflows/publish-bolt-sdk.yml

@@ -49,7 +49,7 @@ jobs:
       - name: install rust
       - name: install rust
         uses: dtolnay/rust-toolchain@stable
         uses: dtolnay/rust-toolchain@stable
         with:
         with:
-          toolchain: 1.81.0
+          toolchain: stable
 
 
       - name: Cache rust
       - name: Cache rust
         uses: Swatinem/rust-cache@v2
         uses: Swatinem/rust-cache@v2
@@ -92,7 +92,7 @@ jobs:
       - name: install rust
       - name: install rust
         uses: dtolnay/rust-toolchain@stable
         uses: dtolnay/rust-toolchain@stable
         with:
         with:
-          toolchain: 1.81.0
+          toolchain: stable
 
 
       - name: Cache rust
       - name: Cache rust
         uses: Swatinem/rust-cache@v2
         uses: Swatinem/rust-cache@v2

+ 8 - 8
.github/workflows/publish-packages.yml

@@ -23,43 +23,43 @@ jobs:
           - {
           - {
             NAME: linux-x64-glibc,
             NAME: linux-x64-glibc,
             OS: ubuntu-latest,
             OS: ubuntu-latest,
-            TOOLCHAIN: 1.81.0,
+            TOOLCHAIN: stable,
             TARGET: x86_64-unknown-linux-gnu,
             TARGET: x86_64-unknown-linux-gnu,
           }
           }
           - {
           - {
             NAME: linux-x86-glibc,
             NAME: linux-x86-glibc,
             OS: ubuntu-latest,
             OS: ubuntu-latest,
-            TOOLCHAIN: 1.81.0,
+            TOOLCHAIN: stable,
             TARGET: i686-unknown-linux-gnu,
             TARGET: i686-unknown-linux-gnu,
           }
           }
           - {
           - {
             NAME: linux-arm64-glibc,
             NAME: linux-arm64-glibc,
             OS: ubuntu-latest,
             OS: ubuntu-latest,
-            TOOLCHAIN: 1.81.0,
+            TOOLCHAIN: stable,
             TARGET: aarch64-unknown-linux-gnu,
             TARGET: aarch64-unknown-linux-gnu,
           }
           }
           - {
           - {
             NAME: win32-x64-msvc,
             NAME: win32-x64-msvc,
             OS: windows-latest,
             OS: windows-latest,
-            TOOLCHAIN: 1.81.0,
+            TOOLCHAIN: stable,
             TARGET: x86_64-pc-windows-msvc,
             TARGET: x86_64-pc-windows-msvc,
           }
           }
           - {
           - {
             NAME: win32-x86-msvc,
             NAME: win32-x86-msvc,
             OS: windows-latest,
             OS: windows-latest,
-            TOOLCHAIN: 1.81.0,
+            TOOLCHAIN: stable,
             TARGET: i686-pc-windows-msvc,
             TARGET: i686-pc-windows-msvc,
           }
           }
           - {
           - {
             NAME: darwin-x64,
             NAME: darwin-x64,
             OS: macos-latest,
             OS: macos-latest,
-            TOOLCHAIN: 1.81.0,
+            TOOLCHAIN: stable,
             TARGET: x86_64-apple-darwin,
             TARGET: x86_64-apple-darwin,
           }
           }
           - {
           - {
             NAME: darwin-arm64,
             NAME: darwin-arm64,
             OS: macos-latest,
             OS: macos-latest,
-            TOOLCHAIN: 1.81.0,
+            TOOLCHAIN: stable,
             TARGET: aarch64-apple-darwin,
             TARGET: aarch64-apple-darwin,
           }
           }
     steps:
     steps:
@@ -85,7 +85,7 @@ jobs:
           fi
           fi
 
 
       - name: Install Rust toolchain
       - name: Install Rust toolchain
-        uses: actions-rs/toFolchain@v1
+        uses: actions-rs/toolchain@v1
         with:
         with:
           toolchain: ${{ matrix.build.TOOLCHAIN }}
           toolchain: ${{ matrix.build.TOOLCHAIN }}
           target: ${{ matrix.build.TARGET }}
           target: ${{ matrix.build.TARGET }}

+ 2 - 2
.github/workflows/run-lint.yml

@@ -35,7 +35,7 @@ jobs:
       - name: Install Rust
       - name: Install Rust
         uses: dtolnay/rust-toolchain@stable
         uses: dtolnay/rust-toolchain@stable
         with:
         with:
-          toolchain: 1.81.0
+          toolchain: stable
 
 
       - name: Cache Rust
       - name: Cache Rust
         uses: Swatinem/rust-cache@v2
         uses: Swatinem/rust-cache@v2
@@ -64,7 +64,7 @@ jobs:
         run: |
         run: |
           if [ "${{ matrix.task }}" == "clippy" ]; then
           if [ "${{ matrix.task }}" == "clippy" ]; then
             cargo fmt -- --check --verbose
             cargo fmt -- --check --verbose
-            cargo clippy -- --deny=warnings
+            cargo clippy -- --deny=warnings --allow=unexpected_cfgs
           else
           else
             yarn lint
             yarn lint
           fi
           fi

+ 3 - 3
.github/workflows/run-tests.yml

@@ -3,7 +3,7 @@ on:
   push:
   push:
     branches:
     branches:
       - main
       - main
-  pull_request_target:
+  pull_request:
     branches:
     branches:
       - main
       - main
 
 
@@ -35,7 +35,7 @@ jobs:
       - name: Install Rust
       - name: Install Rust
         uses: dtolnay/rust-toolchain@stable
         uses: dtolnay/rust-toolchain@stable
         with:
         with:
-          toolchain: 1.81.0
+          toolchain: stable
 
 
       - name: Cache Rust
       - name: Cache Rust
         uses: Swatinem/rust-cache@v2
         uses: Swatinem/rust-cache@v2
@@ -56,7 +56,7 @@ jobs:
       - name: Install Rust
       - name: Install Rust
         uses: dtolnay/rust-toolchain@stable
         uses: dtolnay/rust-toolchain@stable
         with:
         with:
-          toolchain: 1.81.0
+          toolchain: stable
 
 
       - name: Cache Rust
       - name: Cache Rust
         uses: Swatinem/rust-cache@v2
         uses: Swatinem/rust-cache@v2

File diff suppressed because it is too large
+ 129 - 292
Cargo.lock


+ 13 - 13
Cargo.toml

@@ -36,28 +36,28 @@ bolt-system = { path = "crates/programs/bolt-system", features = ["cpi"], versio
 bolt-component = { path = "crates/programs/bolt-component", features = ["cpi"], version = "=0.2.2"}
 bolt-component = { path = "crates/programs/bolt-component", features = ["cpi"], version = "=0.2.2"}
 
 
 ## External crates
 ## External crates
-session-keys       = { version = "=2.0.6", features = ["no-entrypoint"] }
-anchor-lang        = { version = "=0.30.1", features = ["init-if-needed"] }
-anchor-cli         = { version = "=0.30.1" }
-anchor-client      = { version = "=0.30.1", features = ["async"] }
-anchor-syn         = { version = "=0.30.1" }
-anchor-lang-idl = { version = "=0.1.1" }
-solana-program  = { version = "=1.18.26" }
-solana-client   = { version = "=1.18.26" }
-mpl-token-metadata = { version = "=4.1.2" }
-solana-security-txt = "1.1.1"
+session-keys       = { version = ">=2.0.7", features = ["no-entrypoint"] }
+anchor-lang        = { version = ">=0.31.1", features = ["init-if-needed"] }
+anchor-cli         = { version = ">=0.31.1" }
+anchor-client      = { version = ">=0.31.1", features = ["async"] }
+anchor-syn         = { version = ">=0.31.1" }
+anchor-lang-idl = { version = ">=0.1.2" }
+solana-program  = { version = ">=2.0.25" }
+solana-client   = { version = ">=2.0.25" }
+mpl-token-metadata = { version = ">=5.1.0" }
+solana-security-txt = ">=1.1.1"
 tuple-conv = "1.0.1"
 tuple-conv = "1.0.1"
 syn = { version = "1.0.60", features = ["full"] }
 syn = { version = "1.0.60", features = ["full"] }
-ligen-ir = { version = "=0.1.18" }
+ligen-ir = "=0.1.18"
 quote = "1.0"
 quote = "1.0"
-proc-macro2 = "1.0"
+proc-macro2 = "=1.0.95"
 serde = { version = "1.0", features = ["derive"] }
 serde = { version = "1.0", features = ["derive"] }
 serde_json = "1.0"
 serde_json = "1.0"
 anyhow = "1.0.32"
 anyhow = "1.0.32"
 heck = "0.5.0"
 heck = "0.5.0"
 clap = { version = "4.2.4", features = ["derive"] }
 clap = { version = "4.2.4", features = ["derive"] }
 ahash = "=0.8.11"
 ahash = "=0.8.11"
-ephemeral-rollups-sdk = "=0.2.1"
+ephemeral-rollups-sdk = "0.2.5"
 bincode = "=1.3.3"
 bincode = "=1.3.3"
 which = "7.0.2"
 which = "7.0.2"
 tokio = { version = "1", features = ["full"] }
 tokio = { version = "1", features = ["full"] }

+ 18 - 18
clients/csharp/Solana.Unity.Bolt.Test/AccelerationTest.cs

@@ -21,9 +21,10 @@ namespace AccelerationTest {
             await Profiler.Run("DelegateComponent", async () => {
             await Profiler.Run("DelegateComponent", async () => {
                 await DelegateComponent(framework);
                 await DelegateComponent(framework);
             });
             });
-            await Profiler.Run("ApplySimpleMovementSystemOnAccelerator 10", async () => {
-                await ApplySimpleMovementSystemOnAccelerator(framework);
-            });
+            // TODO: Re-enable this test when ephemeral-validator is properly installed on the CI.
+            // await Profiler.Run("ApplySimpleMovementSystemOnAccelerator 10", async () => {
+            //     await ApplySimpleMovementSystemOnAccelerator(framework);
+            // });
         }
         }
 
 
         public static async Task AddAccelerationEntity(Framework framework) {
         public static async Task AddAccelerationEntity(Framework framework) {
@@ -43,20 +44,19 @@ namespace AccelerationTest {
             await framework.SendAndConfirmInstruction(delegateComponent.Instruction);
             await framework.SendAndConfirmInstruction(delegateComponent.Instruction);
         }
         }
 
 
-        // TODO: Re-enable this test when ephemeral-validator is properly installed on the CI.
-        // public static async Task ApplySimpleMovementSystemOnAccelerator(Framework framework) {
-        //     for (int i = 0; i < 10; i++) {
-        //         var apply = new ApplyAccounts() {
-        //             Authority = framework.Wallet.Account.PublicKey,
-        //             BoltSystem = framework.SystemSimpleMovement,
-        //             World = framework.WorldPda,
-        //         };
-        //         var instruction = WorldProgram.Apply(apply, Bolt.World.SerializeArgs(new { direction = "Up" }));
-        //         instruction.Keys.Add(AccountMeta.ReadOnly(framework.ExampleComponentPosition, false));
-        //         instruction.Keys.Add(AccountMeta.Writable(framework.AccelerationComponentPositionPda, false));
-        //         await framework.SendAndConfirmInstruction(framework.AcceleratorClient, instruction);
-        //         await Task.Delay(50);
-        //     }
-        // }
+        public static async Task ApplySimpleMovementSystemOnAccelerator(Framework framework) {
+            for (int i = 0; i < 10; i++) {
+                var apply = new ApplyAccounts() {
+                    Authority = framework.Wallet.Account.PublicKey,
+                    BoltSystem = framework.SystemSimpleMovement,
+                    World = framework.WorldPda,
+                };
+                var instruction = WorldProgram.Apply(apply, Bolt.World.SerializeArgs(new { direction = "Up" }));
+                instruction.Keys.Add(AccountMeta.ReadOnly(framework.ExampleComponentPosition, false));
+                instruction.Keys.Add(AccountMeta.Writable(framework.AccelerationComponentPositionPda, false));
+                await framework.SendAndConfirmInstruction(framework.AcceleratorClient, instruction);
+                await Task.Delay(50);
+            }
+        }
    }
    }
 }
 }

+ 6 - 6
crates/bolt-cli/src/instructions.rs

@@ -48,7 +48,7 @@ pub async fn create_registry(cfg_override: &ConfigOverride) -> Result<()> {
             system_program: system_program::ID,
             system_program: system_program::ID,
         })
         })
         .args(instruction::InitializeRegistry {})
         .args(instruction::InitializeRegistry {})
-        .signer(&payer)
+        .signer(payer)
         .send()
         .send()
         .await?;
         .await?;
 
 
@@ -81,7 +81,7 @@ pub async fn create_world(cfg_override: &ConfigOverride) -> Result<()> {
             system_program: system_program::ID,
             system_program: system_program::ID,
         })
         })
         .args(instruction::InitializeNewWorld {})
         .args(instruction::InitializeNewWorld {})
-        .signer(&payer)
+        .signer(payer)
         .send()
         .send()
         .await?;
         .await?;
 
 
@@ -115,7 +115,7 @@ pub async fn authorize(
             world: world_pubkey,
             world: world_pubkey,
         })
         })
         .args(instruction::AddAuthority { world_id })
         .args(instruction::AddAuthority { world_id })
-        .signer(&payer)
+        .signer(payer)
         .send()
         .send()
         .await?;
         .await?;
 
 
@@ -150,7 +150,7 @@ pub async fn deauthorize(
             world: world_pubkey,
             world: world_pubkey,
         })
         })
         .args(instruction::RemoveAuthority { world_id })
         .args(instruction::RemoveAuthority { world_id })
-        .signer(&payer)
+        .signer(payer)
         .send_with_spinner_and_config(RpcSendTransactionConfig {
         .send_with_spinner_and_config(RpcSendTransactionConfig {
             skip_preflight: true,
             skip_preflight: true,
             ..RpcSendTransactionConfig::default()
             ..RpcSendTransactionConfig::default()
@@ -185,7 +185,7 @@ pub async fn approve_system(
             system_program: system_program::ID,
             system_program: system_program::ID,
         })
         })
         .args(instruction::ApproveSystem {})
         .args(instruction::ApproveSystem {})
-        .signer(&payer)
+        .signer(payer)
         .send()
         .send()
         .await?;
         .await?;
 
 
@@ -217,7 +217,7 @@ pub async fn remove_system(
             system_program: system_program::ID,
             system_program: system_program::ID,
         })
         })
         .args(instruction::RemoveSystem {})
         .args(instruction::RemoveSystem {})
-        .signer(&payer)
+        .signer(payer)
         .send()
         .send()
         .await?;
         .await?;
 
 

+ 1 - 0
crates/bolt-cli/src/lib.rs

@@ -128,6 +128,7 @@ pub async fn entry(opts: Opts) -> Result<()> {
                 template,
                 template,
                 test_template,
                 test_template,
                 force,
                 force,
+                ..
             } => init(
             } => init(
                 &opts.cfg_override,
                 &opts.cfg_override,
                 name,
                 name,

+ 1 - 2
crates/bolt-cli/src/templates/component/mod.rs

@@ -21,13 +21,12 @@ pub fn create_component_template_simple(name: &str, program_path: &Path) -> File
 }
 }
 
 
 /// Automatic generation of crates from the components idl
 /// Automatic generation of crates from the components idl
-
 pub fn component_type(idl: &Idl, component_id: &str) -> Result<String> {
 pub fn component_type(idl: &Idl, component_id: &str) -> Result<String> {
     let component_account = idl
     let component_account = idl
         .accounts
         .accounts
         .iter()
         .iter()
         .filter(|a| a.name.to_lowercase() != "Entity")
         .filter(|a| a.name.to_lowercase() != "Entity")
-        .last();
+        .next_back();
     let component_account =
     let component_account =
         component_account.ok_or_else(|| anyhow::anyhow!("Component account not found in IDL"))?;
         component_account.ok_or_else(|| anyhow::anyhow!("Component account not found in IDL"))?;
 
 

+ 1 - 1
crates/bolt-lang/attribute/component-deserialize/src/lib.rs

@@ -70,7 +70,7 @@ pub fn component_deserialize(_attr: TokenStream, item: TokenStream) -> TokenStre
 
 
         #[automatically_derived]
         #[automatically_derived]
         impl anchor_lang::Discriminator for #name {
         impl anchor_lang::Discriminator for #name {
-            const DISCRIMINATOR: [u8; 8] = [0; 8];
+            const DISCRIMINATOR: &'static [u8] = &[1, 1, 1, 1, 1, 1, 1, 1];
         }
         }
 
 
         #owner_definition
         #owner_definition

+ 1 - 1
crates/programs/world/src/lib.rs

@@ -507,7 +507,7 @@ pub struct AddEntity<'info> {
     pub payer: Signer<'info>,
     pub payer: Signer<'info>,
     #[account(init, payer = payer, space = World::size(), seeds = [Entity::seed(), &world.id.to_be_bytes(),
     #[account(init, payer = payer, space = World::size(), seeds = [Entity::seed(), &world.id.to_be_bytes(),
     &match extra_seed {
     &match extra_seed {
-        Some(ref seed) => [0; 8],
+        Some(ref _seed) => [0; 8],
         None => world.entities.to_be_bytes()
         None => world.entities.to_be_bytes()
     },
     },
     match extra_seed {
     match extra_seed {

+ 1 - 1
examples/system-simple-movement/Cargo.toml

@@ -26,4 +26,4 @@ custom-panic = []
 [dependencies]
 [dependencies]
 serde.workspace = true
 serde.workspace = true
 bolt-lang.workspace = true
 bolt-lang.workspace = true
-bolt-types = { version = "0.2.1", path = "../../crates/types" }
+bolt-types = { version = "0.2.2", path = "../../crates/types" }

+ 1 - 1
rust-toolchain.toml

@@ -1,3 +1,3 @@
 [toolchain]
 [toolchain]
-channel = "1.81.0"
+channel = "1.86.0"
 components = ["rustfmt"]
 components = ["rustfmt"]

+ 1 - 1
scripts/lint.sh

@@ -6,7 +6,7 @@ echo "### Checking formatting..."
 cargo fmt -- --verbose
 cargo fmt -- --verbose
 
 
 echo "### Checking clippy..."
 echo "### Checking clippy..."
-cargo clippy --fix -- --deny=warnings
+cargo clippy --fix -- --deny=warnings --allow=unexpected_cfgs
 
 
 echo "### Checking yarn lint..."
 echo "### Checking yarn lint..."
 yarn lint --write
 yarn lint --write

Some files were not shown because too many files changed in this diff