Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated runs-on #570

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from
24 changes: 20 additions & 4 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,21 @@ concurrency:
cancel-in-progress: true
jobs:
build-image:
runs-on: neon-evm-1
runs-on: ["self-hosted", "k8s-prod"]
outputs:
evm_tag: ${{ steps.tags.outputs.evm_tag }}
evm_sha_tag: ${{ steps.tags.outputs.evm_sha_tag }}
evm_pr_version_branch: ${{ steps.tags.outputs.evm_pr_version_branch }}
is_evm_release: ${{ steps.tags.outputs.is_evm_release }}
neon_test_tag: ${{ steps.tags.outputs.neon_test_tag }}
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: actions/setup-python@v5
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: pip install -r ./.github/workflows/requirements.txt
- name: Specify image tags
run: |
python3 ./.github/workflows/deploy.py specify_image_tags \
Expand All @@ -60,13 +64,17 @@ jobs:
--evm_sha_tag=${{ steps.tags.outputs.evm_sha_tag }} \
--evm_tag=${{ steps.tags.outputs.evm_tag }}
run-evm-tests:
runs-on: test-runner
runs-on: ["self-hosted", "k8s-prod"]
needs:
- build-image
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: actions/setup-python@v5
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: pip install -r ./.github/workflows/requirements.txt
- name: Run tests
run: |
python3 ./.github/workflows/deploy.py run_tests \
Expand All @@ -78,13 +86,17 @@ jobs:
if: "failure()"
uses: "andymckay/[email protected]"
trigger-proxy-tests:
runs-on: trigger-runner
runs-on: ["self-hosted", "k8s-prod"]
needs:
- build-image
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: actions/setup-python@v5
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: pip install -r ./.github/workflows/requirements.txt
- name: Trigger proxy build
run: |
python3 ./.github/workflows/deploy.py trigger_proxy_action \
Expand All @@ -100,15 +112,19 @@ jobs:
if: "failure()"
uses: "andymckay/[email protected]"
finalize-image:
runs-on: neon-evm-1
runs-on: ["self-hosted", "k8s-prod"]
needs:
- build-image
- trigger-proxy-tests
- run-evm-tests
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: actions/setup-python@v5
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: pip install -r ./.github/workflows/requirements.txt
- name: Finalize image
run: |
python3 ./.github/workflows/deploy.py finalize_image \
Expand Down
1 change: 1 addition & 0 deletions evm_loader/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions evm_loader/lib-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use abi_stable::{

#[repr(C)]
#[derive(StableAbi)]
#[sabi(kind(Prefix(prefix_ref = NeonEVMLib_Ref)))]
#[sabi(kind(Prefix(prefix_ref = NeonEVMLibRef)))]
#[sabi(missing_field(panic))]
pub struct NeonEVMLib {
pub hash: extern "C" fn() -> RString,
Expand All @@ -28,8 +28,8 @@ pub struct NeonEVMLib {
}

#[allow(clippy::use_self)]
impl RootModule for NeonEVMLib_Ref {
abi_stable::declare_root_module_statics! {NeonEVMLib_Ref}
impl RootModule for NeonEVMLibRef {
abi_stable::declare_root_module_statics! {NeonEVMLibRef}

const BASE_NAME: &'static str = "neon-lib-interface";
const NAME: &'static str = "neon-lib-interface";
Expand All @@ -46,14 +46,14 @@ pub enum NeonEVMLibLoadError {

pub fn load_libraries<P>(
directory: P,
) -> Result<HashMap<String, NeonEVMLib_Ref>, NeonEVMLibLoadError>
) -> Result<HashMap<String, NeonEVMLibRef>, NeonEVMLibLoadError>
where
P: AsRef<Path>,
{
let paths = std::fs::read_dir(directory)?;
let mut result = HashMap::new();
for path in paths {
let lib = NeonEVMLib_Ref::load_from_file(&path?.path())?;
let lib = NeonEVMLibRef::load_from_file(&path?.path())?;
let hash = lib.hash()();

result.insert(hash.into_string(), lib);
Expand Down
1 change: 1 addition & 0 deletions evm_loader/lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ clap = "2.34.0"
lazy_static = "1.5.0"
elsa = "1.10.0"
arrayref = "0.3.8"
futures = "0.3.30"

[dev-dependencies]
hex-literal = "0.4.1"
Expand Down
5 changes: 0 additions & 5 deletions evm_loader/lib/src/account_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -918,11 +918,6 @@ impl<'a, T: Rpc> EmulatorAccountStorage<'_, T> {
let new_lamports = new_acc.lamports;
let new_size = new_acc.get_length();

if new_acc.is_busy() && new_lamports < self.rent.minimum_balance(new_acc.get_length()) {
info!("Account {pubkey} is not rent exempt");
return Err(ProgramError::AccountNotRentExempt.into());
}

let old_lamports = lamports_after_upgrade.unwrap_or(original_lamports);
old_lamports_sum += old_lamports;
new_lamports_sum += new_lamports;
Expand Down
61 changes: 60 additions & 1 deletion evm_loader/lib/src/account_storage_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::rpc;
use crate::tracing::AccountOverride;
use evm_loader::types::vector::VectorVecExt;
use hex_literal::hex;
use solana_account_decoder::UiDataSliceConfig;
use std::collections::HashMap;
use std::str::FromStr;

Expand All @@ -19,6 +20,8 @@ mod mock_rpc_client {
use solana_sdk::pubkey::Pubkey;
use std::collections::HashMap;

use solana_account_decoder::UiDataSliceConfig;

pub struct MockRpcClient {
accounts: HashMap<Pubkey, Account>,
}
Expand All @@ -33,7 +36,31 @@ mod mock_rpc_client {

#[async_trait(?Send)]
impl Rpc for MockRpcClient {
async fn get_account(&self, key: &Pubkey) -> ClientResult<Option<Account>> {
async fn get_account_slice(
&self,
key: &Pubkey,
slice: Option<UiDataSliceConfig>,
) -> ClientResult<Option<Account>> {
if let Some(data_slice) = slice {
if let Some(orig_acc) = self.accounts.get(key) {
let cut_to =
usize::min(data_slice.offset + data_slice.length, orig_acc.data.len());
let sliced_data = if data_slice.offset < orig_acc.data.len() {
orig_acc.data[data_slice.offset..cut_to].to_vec()
} else {
vec![]
};

return Ok(Some(Account {
lamports: orig_acc.lamports,
data: sliced_data,
owner: orig_acc.owner,
executable: orig_acc.executable,
rent_epoch: orig_acc.rent_epoch,
}));
}
}

let result = self.accounts.get(key).cloned();
Ok(result)
}
Expand Down Expand Up @@ -1790,3 +1817,35 @@ async fn test_storage_new_from_other_and_override() {
expected_balance
);
}

#[tokio::test]
async fn test_storage_get_account_slice() {
let slice_from = 2;
let slice_size = 20;
let test_key = Pubkey::new_unique();
let acc = Account::new(10, 1 * 1024 * 1024, &solana_sdk::sysvar::rent::id());

let account_tuple = (test_key, acc);
let accounts_for_rpc = vec![
(solana_sdk::sysvar::rent::id(), account_tuple.1.clone()),
account_tuple.clone(),
];
let rpc_client = mock_rpc_client::MockRpcClient::new(&accounts_for_rpc);
let acc_no_slice = rpc_client
.get_account(&test_key)
.await
.expect("Failed to get account slice");

let slice_cfg = UiDataSliceConfig {
offset: slice_from,
length: slice_size,
};
let sliced_acc = rpc_client
.get_account_slice(&test_key, Some(slice_cfg))
.await
.expect("Failed to get account slice");
assert!(acc_no_slice.is_some());
assert!(sliced_acc.is_some());
assert!(acc_no_slice.unwrap().data.len() > 2000);
assert_eq!(sliced_acc.unwrap().data.len(), slice_size);
}
10 changes: 5 additions & 5 deletions evm_loader/lib/src/build_info_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use build_info::chrono::{DateTime, Utc};
use build_info::semver::Version;
use build_info::VersionControl::Git;
use build_info::{BuildInfo, OptimizationLevel};
use serde::Serialize;
use serde::{Deserialize, Serialize};
use std::fmt::{Display, Formatter};

#[derive(Debug, Clone, Serialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SlimBuildInfo {
timestamp: DateTime<Utc>,
profile: String,
Expand All @@ -15,18 +15,18 @@ pub struct SlimBuildInfo {
version_control: GitInfo,
}

#[derive(Debug, Clone, Serialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
struct CrateInfo {
name: String,
version: Version,
}

#[derive(Debug, Clone, Serialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
struct CompilerInfo {
version: Version,
}

#[derive(Debug, Clone, Serialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
struct GitInfo {
commit_id: String,
dirty: bool,
Expand Down
1 change: 0 additions & 1 deletion evm_loader/lib/src/commands/get_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ impl BuildConfigSimulator for CallDbClient {
async fn build_config_simulator(&self, program_id: Pubkey) -> NeonResult<ConfigSimulator> {
let mut simulator = SolanaSimulator::new_without_sync(self).await?;
simulator.sync_accounts(self, &[program_id]).await?;

Ok(ConfigSimulator::ProgramTestContext {
program_id,
simulator,
Expand Down
6 changes: 3 additions & 3 deletions evm_loader/lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ use abi::_MODULE_WM_;
use abi_stable::export_root_module;
pub use config::Config;
pub use errors::NeonError;
use neon_lib_interface::NeonEVMLib_Ref;
use neon_lib_interface::NeonEVMLibRef;

pub type NeonResult<T> = Result<T, NeonError>;

const MODULE: NeonEVMLib_Ref = NeonEVMLib_Ref(_MODULE_WM_.static_as_prefix());
const MODULE: NeonEVMLibRef = NeonEVMLibRef(_MODULE_WM_.static_as_prefix());

#[export_root_module]
#[must_use]
pub const fn get_root_module() -> NeonEVMLib_Ref {
pub const fn get_root_module() -> NeonEVMLibRef {
MODULE
}

Expand Down
20 changes: 14 additions & 6 deletions evm_loader/lib/src/rpc/db_call_client.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::{e, Rpc};
use super::{e, Rpc, SliceConfig};
use crate::types::{TracerDb, TracerDbTrait};
use crate::NeonError;
use crate::NeonError::RocksDb;
Expand Down Expand Up @@ -42,18 +42,26 @@ impl CallDbClient {
})
}

async fn get_account_at(&self, key: &Pubkey) -> ClientResult<Option<Account>> {
async fn get_account_at(
&self,
key: &Pubkey,
slice: Option<SliceConfig>,
) -> ClientResult<Option<Account>> {
self.tracer_db
.get_account_at(key, self.slot, self.tx_index_in_block)
.get_account_at(key, self.slot, self.tx_index_in_block, slice)
.await
.map_err(|e| e!("load account error", key, e))
}
}

#[async_trait(?Send)]
impl Rpc for CallDbClient {
async fn get_account(&self, key: &Pubkey) -> ClientResult<Option<Account>> {
self.get_account_at(key).await
async fn get_account_slice(
&self,
key: &Pubkey,
slice: Option<SliceConfig>,
) -> ClientResult<Option<Account>> {
self.get_account_at(key, slice).await
}

async fn get_multiple_accounts(
Expand All @@ -62,7 +70,7 @@ impl Rpc for CallDbClient {
) -> ClientResult<Vec<Option<Account>>> {
let mut result = Vec::new();
for key in pubkeys {
result.push(self.get_account_at(key).await?);
result.push(self.get_account_at(key, None).await?);
}
debug!("get_multiple_accounts: pubkeys={pubkeys:?} result={result:?}");
Ok(result)
Expand Down
34 changes: 24 additions & 10 deletions evm_loader/lib/src/rpc/emulator_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,35 @@ use solana_sdk::{

use crate::account_storage::{fake_operator, EmulatorAccountStorage};

use super::Rpc;
use super::{Rpc, SliceConfig};

#[async_trait(?Send)]
impl<'rpc, T: Rpc> Rpc for EmulatorAccountStorage<'rpc, T> {
async fn get_account(&self, key: &Pubkey) -> ClientResult<Option<Account>> {
if *key == self.operator() {
return Ok(Some(fake_operator()));
}

if let Some(account_data) = self.accounts_get(key) {
return Ok(Some(Account::from(&*account_data)));
async fn get_account_slice(
&self,
key: &Pubkey,
slice: Option<SliceConfig>,
) -> ClientResult<Option<Account>> {
let answer_account = if *key == self.operator() {
Some(fake_operator())
} else if let Some(account_data) = self.accounts_get(key) {
Some(Account::from(&*account_data))
} else {
self._get_account_from_rpc(*key).await?.cloned()
};

if let Some(data_slice) = slice {
// if only slice is necessary - cut data
if let Some(mut account) = answer_account {
if data_slice.offset != 0 {
account.data.drain(0..data_slice.offset);
}
account.data.truncate(data_slice.length);
return Ok(Some(account));
}
}

let account = self._get_account_from_rpc(*key).await?.cloned();
Ok(account)
Ok(answer_account)
}

async fn get_multiple_accounts(
Expand Down
Loading
Loading