Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion anchor-counter/target/deploy/public_counter-keypair.json

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion crank-counter/Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ resolution = true
skip-lint = false

[programs.devnet]
crank_counter = "E91p5Drj4deMEe1RVLWMLWUfTCwDfronioJe6NRYkbxZ"
crank_counter = "HetkBSVTbemvzJzcmnTS6Ge6LP9KVVXkbtdL6qguG2g9"

[programs.localnet]
crank_counter = "FW2QPnTK9WwYLNG29GhH7PGYdp7Jwq3pGQrUuNdUnK44"
Expand Down
2 changes: 1 addition & 1 deletion crank-counter/programs/crank-counter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use anchor_lang::solana_program::{
use ephemeral_rollups_sdk::consts::MAGIC_PROGRAM_ID;
use magicblock_magic_program_api::{args::ScheduleTaskArgs, instruction::MagicBlockInstruction};

declare_id!("E91p5Drj4deMEe1RVLWMLWUfTCwDfronioJe6NRYkbxZ");
declare_id!("HetkBSVTbemvzJzcmnTS6Ge6LP9KVVXkbtdL6qguG2g9");

pub const COUNTER_SEED: &[u8] = b"counter";

Expand Down
7 changes: 3 additions & 4 deletions dummy-token-transfer/Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,20 @@ resolution = true
skip-lint = false

[programs.devnet]
dummy_transfer = "58yUmvFtbxoV9dRmv3mbrmKCviJmQLY2MzECCa5cWR6j"
dummy_transfer = "6hakvCNCdyi8hRSmqC5TbWHjp87kgoKxyiexjCs65dmf"

[programs.localnet]
dummy_transfer = "58yUmvFtbxoV9dRmv3mbrmKCviJmQLY2MzECCa5cWR6j"

[registry]
url = "https://api.apr.dev"

[provider]
cluster = "devnet"
wallet = "~/.config/solana/id.json"

[scripts]
test = "NODE_OPTIONS='--no-deprecation' yarn run ts-mocha -p ./tsconfig.json -t 120000 tests/**/*.ts"

[hooks]

[test]
startup_wait = 5000
shutdown_wait = 2000
Expand Down
2 changes: 1 addition & 1 deletion dummy-token-transfer/programs/dummy-transfer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use ephemeral_rollups_sdk::anchor::{commit, delegate, ephemeral};
use ephemeral_rollups_sdk::cpi::DelegateConfig;
use ephemeral_rollups_sdk::ephem::MagicIntentBundleBuilder;

declare_id!("Ckyvyxw2rrFmhAKxDa7qjfTridciYHRTetS1WPGmKdpo");
declare_id!("6hakvCNCdyi8hRSmqC5TbWHjp87kgoKxyiexjCs65dmf");

#[ephemeral]
#[program]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use ephemeral_rollups_sdk::{
ephem::MagicIntentBundleBuilder,
};

declare_id!("2WJiwbdnwo7qVC3zesZjFWEPUcU2NZbBXf8arMUJ6p89");
declare_id!("8bc6ZyJAVcf4LS4xrHehetXUdp1ZX4jnEfoBdePRErfb");

pub const COUNTER_SEED: &[u8] = b"counter";

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
CounterInstruction,
IncreaseCounterPayload,
} from "./schema";
import {
Connection,
import {
Connection,
DELEGATION_PROGRAM_ID,
delegationRecordPdaFromDelegatedAccount,
delegationMetadataPdaFromDelegatedAccount,
Expand All @@ -20,18 +20,18 @@ import {
PERMISSION_PROGRAM_ID,
getAuthToken
} from "@magicblock-labs/ephemeral-rollups-kit";
import {
import {
Instruction,
getAddressEncoder,
getProgramDerivedAddress,
AccountRole,
createKeyPairFromBytes,
getAddressFromPublicKey,
address,
getProgramDerivedAddress,
AccountRole,
createKeyPairFromBytes,
getAddressFromPublicKey,
address,
createTransactionMessage,
appendTransactionMessageInstructions,
pipe,
setTransactionMessageFeePayer
appendTransactionMessageInstructions,
pipe,
setTransactionMessageFeePayer
} from '@solana/kit';
import { SYSTEM_PROGRAM_ADDRESS } from "@solana-program/system"
import * as nacl from 'tweetnacl';
Expand Down Expand Up @@ -61,7 +61,7 @@ describe("basic-test", async () => {
const teeUrl = process.env.EPHEMERAL_PROVIDER_ENDPOINT || "https://tee.magicblock.app";
const teeWsUrl = process.env.EPHEMERAL_WS_ENDPOINT || "wss://tee.magicblock.app";
const authToken = teeUrl.startsWith("https://tee") ? (await getAuthToken(teeUrl, userPubkey, (message: Uint8Array) => Promise.resolve(nacl.sign.detached(message, new Uint8Array(
(JSON.parse(process.env.PRIVATE_KEY ?? "[]") as number[])))))).token : "";
(JSON.parse(process.env.PRIVATE_KEY ?? "[]") as number[])))))).token : "";
const teeUserUrl = `${teeUrl}?token=${authToken}`;
const teeUserWsUrl = `${teeWsUrl}?token=${authToken}`;
console.log("User Explorer URL:", `https://solscan.io/?cluster=custom&customUrl=${teeUserUrl}`);
Expand All @@ -76,21 +76,17 @@ describe("basic-test", async () => {
process.env.EPHEMERAL_WS_ENDPOINT || teeUserWsUrl
)



console.log("Base Layer RPC:", connection.clusterUrlHttp, "| Websocket:", connection.clusterUrlWs);
console.log("Base Layer RPC:", connection.clusterUrlHttp, "| Websocket:", connection.clusterUrlWs);
console.log("ER RPC:", ephemeralConnection.clusterUrlHttp, "| Websocket:", ephemeralConnection.clusterUrlWs);



// Get Counter PDA
const addressEncoder = getAddressEncoder();
const [counterPda, bump] = await getProgramDerivedAddress({
programAddress: PROGRAM_ID,
seeds: [
Buffer.from("counter"),
addressEncoder.encode(userPubkey)
],
programAddress: PROGRAM_ID,
seeds: [
Buffer.from("counter"),
addressEncoder.encode(userPubkey)
],
});
// Get permission PDA
const [permissionPda] = await getProgramDerivedAddress({
Expand All @@ -107,19 +103,19 @@ describe("basic-test", async () => {
// Add local validator identity to the remaining accounts if running on localnet
const remainingAccounts = connection.clusterUrlHttp.includes("localhost") || connection.clusterUrlHttp.includes("127.0.0.1") || process.env.VALIDATOR
? [
{
address: address(process.env.VALIDATOR || "mAGicPQYBMvcYveUZA5F5UNNwyHvfYh5xkLS2Fr1mev"),
role: AccountRole.READONLY
}
{
address: address(process.env.VALIDATOR || "mAGicPQYBMvcYveUZA5F5UNNwyHvfYh5xkLS2Fr1mev"),
role: AccountRole.READONLY
}
]
: [
{
address: address("FnE6VJT5QNZdedZPnCoLsARgBwoE6DeJNjBs2H1gySXA"),
role: AccountRole.READONLY
}
{
address: address("MTEWGuqxUpYZGFJQcp8tLN7x5v9BSeoFHYWQQ3n3xzo"),
role: AccountRole.READONLY
}
];
console.log("PER Validator: ", remainingAccounts[0].address);

// Ensure test wallet has SOL
beforeAll(async () => {
await airdropSolIfNeeded(
Expand All @@ -137,8 +133,8 @@ describe("basic-test", async () => {

// Prepare transaction
const accounts = [
{ address: userPubkey, role: AccountRole.WRITABLE_SIGNER},
{ address: counterPda, role: AccountRole.WRITABLE },
{ address: userPubkey, role: AccountRole.WRITABLE_SIGNER },
{ address: counterPda, role: AccountRole.WRITABLE },
{ address: SYSTEM_PROGRAM_ADDRESS, role: AccountRole.READONLY },
{ address: PERMISSION_PROGRAM_ID, role: AccountRole.READONLY },
{ address: permissionPda, role: AccountRole.WRITABLE },
Expand All @@ -153,7 +149,7 @@ describe("basic-test", async () => {
Buffer.from(CounterInstruction.InitializeCounter, "hex"),
Buffer.from([bump]),
]);
const initializeIx : Instruction = {
const initializeIx: Instruction = {
accounts,
programAddress: PROGRAM_ID,
data: serializedInstructionData,
Expand All @@ -165,7 +161,7 @@ describe("basic-test", async () => {
);

// Send and confirm transaction
const txHash = await connection.sendAndConfirmTransaction(transactionMessage, [userKeypair], { commitment: "confirmed", skipPreflight: true })
const txHash = await connection.sendAndConfirmTransaction(transactionMessage, [userKeypair], { commitment: "confirmed", skipPreflight: true })

console.log(`${Date.now() - start}ms (Base Layer) Initialize txHash: ${txHash}`);

Expand All @@ -181,8 +177,8 @@ describe("basic-test", async () => {

// Prepare transaction
const accounts = [
{ address: userPubkey, role: AccountRole.WRITABLE_SIGNER},
{ address: counterPda, role: AccountRole.WRITABLE },
{ address: userPubkey, role: AccountRole.WRITABLE_SIGNER },
{ address: counterPda, role: AccountRole.WRITABLE },
];
const serializedInstructionData = Buffer.concat([
Buffer.from(CounterInstruction.IncreaseCounter, "hex"),
Expand All @@ -192,7 +188,7 @@ describe("basic-test", async () => {
new IncreaseCounterPayload(1)
),
]);
const increaseCounterIx : Instruction = {
const increaseCounterIx: Instruction = {
accounts,
programAddress: PROGRAM_ID,
data: serializedInstructionData,
Expand All @@ -204,7 +200,7 @@ describe("basic-test", async () => {
);

// Send and confirm transaction
const txHash = await connection.sendAndConfirmTransaction(transactionMessage, [userKeypair], { commitment: "confirmed", skipPreflight: true })
const txHash = await connection.sendAndConfirmTransaction(transactionMessage, [userKeypair], { commitment: "confirmed", skipPreflight: true })

console.log(`${Date.now() - start}ms (Base Layer) Increment txHash: ${txHash}`);
expect(txHash).toBeDefined();
Expand All @@ -219,8 +215,8 @@ describe("basic-test", async () => {

// Prepare transaction
const accounts = [
{ address: userPubkey, role: AccountRole.WRITABLE_SIGNER},
{ address: counterPda, role: AccountRole.WRITABLE },
{ address: userPubkey, role: AccountRole.WRITABLE_SIGNER },
{ address: counterPda, role: AccountRole.WRITABLE },
{ address: PROGRAM_ID, role: AccountRole.READONLY },
{
address: await delegateBufferPdaFromDelegatedAccountAndOwnerProgram(counterPda, PROGRAM_ID),
Expand All @@ -247,7 +243,7 @@ describe("basic-test", async () => {
Buffer.from(CounterInstruction.Delegate, "hex"),
Buffer.from([bump]),
]);
const delegateIx : Instruction = {
const delegateIx: Instruction = {
accounts,
programAddress: PROGRAM_ID,
data: serializedInstructionData,
Expand All @@ -259,7 +255,7 @@ describe("basic-test", async () => {
);

// Send and confirm transaction
const txHash = await connection.sendAndConfirmTransaction(transactionMessage, [userKeypair], { commitment: "confirmed", skipPreflight: true })
const txHash = await connection.sendAndConfirmTransaction(transactionMessage, [userKeypair], { commitment: "confirmed", skipPreflight: true })

console.log(`${Date.now() - start}ms (Base Layer) Delegate txHash: ${txHash}`);
expect(txHash).toBeDefined();
Expand All @@ -272,7 +268,7 @@ describe("basic-test", async () => {
async () => {
const start = Date.now();
const accounts = [
{ address: userPubkey, role: AccountRole.WRITABLE_SIGNER},
{ address: userPubkey, role: AccountRole.WRITABLE_SIGNER },
{ address: counterPda, role: AccountRole.WRITABLE },
];
const serializedInstructionData = Buffer.concat([
Expand All @@ -283,7 +279,7 @@ describe("basic-test", async () => {
new IncreaseCounterPayload(1)
),
]);
const increaseCounterIx : Instruction = {
const increaseCounterIx: Instruction = {
accounts,
programAddress: PROGRAM_ID,
data: serializedInstructionData,
Expand All @@ -295,30 +291,31 @@ describe("basic-test", async () => {
);

// Send and confirm transaction
const txHash = await ephemeralConnection.sendAndConfirmTransaction(transactionMessage, [userKeypair], { skipPreflight: true })
const txHash = await ephemeralConnection.sendAndConfirmTransaction(transactionMessage, [userKeypair], { skipPreflight: true })

console.log(`${Date.now() - start}ms (ER) Increment txHash: ${txHash}`);
expect(txHash).toBeDefined();
},
TEST_TIMEOUT
);

it(
"Commit changes from PER back to Solana",
async () => {
const start = Date.now();

// Prepare transaction
const accounts = [
{ address: userPubkey, role: AccountRole.WRITABLE_SIGNER},
{ address: counterPda, role: AccountRole.WRITABLE },
{ address: address(MAGIC_PROGRAM_ID.toString()), role: AccountRole.READONLY},
{ address: address(MAGIC_CONTEXT_ID.toString()), role: AccountRole.WRITABLE}
{ address: userPubkey, role: AccountRole.WRITABLE_SIGNER },
{ address: counterPda, role: AccountRole.WRITABLE },
{ address: address(MAGIC_PROGRAM_ID.toString()), role: AccountRole.READONLY },
{ address: address(MAGIC_CONTEXT_ID.toString()), role: AccountRole.WRITABLE }
];
const serializedInstructionData = Buffer.from(
CounterInstruction.Commit,
"hex"
);
const commitIx : Instruction = {
const commitIx: Instruction = {
accounts,
programAddress: PROGRAM_ID,
data: serializedInstructionData,
Expand All @@ -330,7 +327,7 @@ describe("basic-test", async () => {
);

// Send and confirm transaction
const txHash = await ephemeralConnection.sendAndConfirmTransaction(transactionMessage, [userKeypair], { skipPreflight: true })
const txHash = await ephemeralConnection.sendAndConfirmTransaction(transactionMessage, [userKeypair], { skipPreflight: true })


const duration = Date.now() - start;
Expand All @@ -340,12 +337,13 @@ describe("basic-test", async () => {
},
TEST_TIMEOUT
);

it(
"Increase counter on PER (2)",
async () => {
const start = Date.now();
const accounts = [
{ address: userPubkey, role: AccountRole.WRITABLE_SIGNER},
{ address: userPubkey, role: AccountRole.WRITABLE_SIGNER },
{ address: counterPda, role: AccountRole.WRITABLE },
];
const serializedInstructionData = Buffer.concat([
Expand All @@ -356,7 +354,7 @@ describe("basic-test", async () => {
new IncreaseCounterPayload(1)
),
]);
const increaseCounterIx : Instruction = {
const increaseCounterIx: Instruction = {
accounts,
programAddress: PROGRAM_ID,
data: serializedInstructionData,
Expand All @@ -368,33 +366,34 @@ describe("basic-test", async () => {
);

// Send and confirm transaction
const txHash = await ephemeralConnection.sendAndConfirmTransaction(transactionMessage, [userKeypair], { skipPreflight: true })
const txHash = await ephemeralConnection.sendAndConfirmTransaction(transactionMessage, [userKeypair], { skipPreflight: true })

console.log(`${Date.now() - start}ms (ER) Increment txHash: ${txHash}`);

expect(txHash).toBeDefined();
},
TEST_TIMEOUT
);

it(
"Undelegate counter from PER",
async () => {
const start = Date.now();

// Prepare transaction
const accounts = [
{ address: userPubkey, role: AccountRole.WRITABLE_SIGNER},
{ address: counterPda, role: AccountRole.WRITABLE },
{ address: userPubkey, role: AccountRole.WRITABLE_SIGNER },
{ address: counterPda, role: AccountRole.WRITABLE },
{ address: PERMISSION_PROGRAM_ID, role: AccountRole.READONLY },
{ address: permissionPda, role: AccountRole.WRITABLE },
{ address: address(MAGIC_PROGRAM_ID.toString()), role: AccountRole.READONLY},
{ address: address(MAGIC_CONTEXT_ID.toString()), role: AccountRole.WRITABLE}
{ address: address(MAGIC_PROGRAM_ID.toString()), role: AccountRole.READONLY },
{ address: address(MAGIC_CONTEXT_ID.toString()), role: AccountRole.WRITABLE }
];
const serializedInstructionData = Buffer.from(
CounterInstruction.CommitAndUndelegate,
"hex"
);
const undelegateIx : Instruction = {
const undelegateIx: Instruction = {
accounts,
programAddress: PROGRAM_ID,
data: serializedInstructionData,
Expand All @@ -406,7 +405,7 @@ describe("basic-test", async () => {
);

// Send and confirm transaction
const txHash = await ephemeralConnection.sendAndConfirmTransaction(transactionMessage, [userKeypair], { skipPreflight: true })
const txHash = await ephemeralConnection.sendAndConfirmTransaction(transactionMessage, [userKeypair], { skipPreflight: true })

const duration = Date.now() - start;
console.log(`${duration}ms (ER) Undelegate txHash: ${txHash}`);
Expand Down
File renamed without changes.
Loading
Loading