Skip to content

Commit

Permalink
Merge branch 'update-20240912120205'
Browse files Browse the repository at this point in the history
  • Loading branch information
profMagija committed Sep 12, 2024
2 parents 48f0d1c + 15f2046 commit 34ee875
Show file tree
Hide file tree
Showing 162 changed files with 2,049 additions and 653 deletions.
37 changes: 32 additions & 5 deletions .github/workflows/submodule-pin-check.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,48 @@
name: Submodule Pin Check
name: Merge Checks

on:
pull_request:
pull_request_target:
branches: [ master ]
types: [synchronize, opened, reopened]

permissions:
statuses: write

jobs:
submodule-pin-check:
name: Submodule Pin Check
name: Check Submodule Pin
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
submodules: true

- name: Check all submodules are ancestors of origin/HEAD or configured branch
run: ${{ github.workspace }}/.github/workflows/submodule-pin-check.sh
run: |
status_state="pending"
if ${{ github.workspace }}/.github/workflows/submodule-pin-check.sh; then
status_state="success"
else
resp="$(curl -sSL --fail-with-body \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/$GITHUB_REPOSITORY/commits/${{ github.event.pull_request.head.sha }}/statuses")"
if ! jq -e '.[] | select(.context == "Submodule Pin Check")' > /dev/null <<< "$resp"; then
# Submodule pin check is failling and no status exists
# Keep it without a status to keep the green checkmark appearing
# Otherwise, the commit and PR's CI will appear to be indefinitely pending
# Merging will still be blocked until the required status appears
exit 0
fi
fi
curl -sSL --fail-with-body \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{ github.event.pull_request.head.sha }}" \
-d '{"context":"Submodule Pin Check","state":"'"$status_state"'"}'
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ ifneq ($(origin GOLANG_LDFLAGS),undefined)
GOLANG_PARAMS = -ldflags="-extldflags '-ldl' $(GOLANG_LDFLAGS)"
endif

UNAME_S := $(shell uname -s)

# In Mac OSX, there are a lot of warnings emitted if these environment variables aren't set.
ifeq ($(UNAME_S), Darwin)
export MACOSX_DEPLOYMENT_TARGET := $(shell sw_vers -productVersion)
export CGO_LDFLAGS := -Wl,-no_warn_duplicate_libraries
endif

precompile_names = AddressTable Aggregator BLS Debug FunctionTable GasInfo Info osTest Owner RetryableTx Statistics Sys
precompiles = $(patsubst %,./solgen/generated/%.go, $(precompile_names))

Expand Down
4 changes: 3 additions & 1 deletion arbcompress/compress_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ func compressedBufferSizeFor(length int) int {
return length + (length>>10)*8 + 64 // actual limit is: length + (length >> 14) * 4 + 6
}

func CompressLevel(input []byte, level int) ([]byte, error) {
func CompressLevel(input []byte, level uint64) ([]byte, error) {
// level is trusted and shouldn't be anything crazy
// #nosec G115
return Compress(input, uint32(level), EmptyDictionary)
}
19 changes: 14 additions & 5 deletions arbitrator/arbutil/src/evm/req.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use crate::{
storage::{StorageCache, StorageWord},
user::UserOutcomeKind,
},
format::Utf8OrHex,
pricing::EVM_API_INK,
Bytes20, Bytes32,
};
Expand Down Expand Up @@ -140,8 +139,13 @@ impl<D: DataReader, H: RequestHandler<D>> EvmApi<D> for EvmApiRequestor<D, H> {
}

let (res, _, cost) = self.request(EvmApiMethod::SetTrieSlots, data);
if res[0] != EvmApiStatus::Success.into() {
bail!("{}", String::from_utf8_or_hex(res));
let status = res
.first()
.copied()
.map(EvmApiStatus::from)
.unwrap_or(EvmApiStatus::Failure);
if status != EvmApiStatus::Success {
bail!("{:?}", status);
}
Ok(cost)
}
Expand All @@ -156,8 +160,13 @@ impl<D: DataReader, H: RequestHandler<D>> EvmApi<D> for EvmApiRequestor<D, H> {
data.extend(key);
data.extend(value);
let (res, ..) = self.request(EvmApiMethod::SetTransientBytes32, data);
if res[0] != EvmApiStatus::Success.into() {
bail!("{}", String::from_utf8_or_hex(res));
let status = res
.first()
.copied()
.map(EvmApiStatus::from)
.unwrap_or(EvmApiStatus::Failure);
if status != EvmApiStatus::Success {
bail!("{:?}", status);
}
Ok(())
}
Expand Down
34 changes: 19 additions & 15 deletions arbitrator/jit/src/wavmio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ use crate::{
};
use arbutil::{Color, PreimageType};
use caller_env::{GuestPtr, MemAccess};
use sha2::Sha256;
use sha3::{Digest, Keccak256};
use std::{
io,
io::{BufReader, BufWriter, ErrorKind},
Expand Down Expand Up @@ -170,19 +168,25 @@ pub fn resolve_preimage_impl(
error!("Missing requested preimage for hash {hash_hex} in {name}")
};

// Check if preimage rehashes to the provided hash. Exclude blob preimages
let calculated_hash: [u8; 32] = match preimage_type {
PreimageType::Keccak256 => Keccak256::digest(preimage).into(),
PreimageType::Sha2_256 => Sha256::digest(preimage).into(),
PreimageType::EthVersionedHash => *hash,
};
if calculated_hash != *hash {
error!(
"Calculated hash {} of preimage {} does not match provided hash {}",
hex::encode(calculated_hash),
hex::encode(preimage),
hex::encode(*hash)
);
#[cfg(debug_assertions)]
{
use sha2::Sha256;
use sha3::{Digest, Keccak256};

// Check if preimage rehashes to the provided hash. Exclude blob preimages
let calculated_hash: [u8; 32] = match preimage_type {
PreimageType::Keccak256 => Keccak256::digest(preimage).into(),
PreimageType::Sha2_256 => Sha256::digest(preimage).into(),
PreimageType::EthVersionedHash => *hash,
};
if calculated_hash != *hash {
error!(
"Calculated hash {} of preimage {} does not match provided hash {}",
hex::encode(calculated_hash),
hex::encode(preimage),
hex::encode(*hash)
);
}
}

if offset % 32 != 0 {
Expand Down
89 changes: 69 additions & 20 deletions arbitrator/stylus/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use arbutil::{
};
use caller_env::GuestPtr;
use eyre::Result;
use prover::value::Value;
use std::{
fmt::Display,
mem::{self, MaybeUninit},
Expand Down Expand Up @@ -441,26 +440,76 @@ pub(crate) fn pay_for_memory_grow<D: DataReader, E: EvmApi<D>>(
hostio!(env, pay_for_memory_grow(pages))
}

pub(crate) fn console_log_text<D: DataReader, E: EvmApi<D>>(
mut env: WasmEnvMut<D, E>,
ptr: GuestPtr,
len: u32,
) -> MaybeEscape {
hostio!(env, console_log_text(ptr, len))
}
pub(crate) mod console {
use super::*;

pub(crate) fn console_log<D: DataReader, E: EvmApi<D>, T: Into<Value>>(
mut env: WasmEnvMut<D, E>,
value: T,
) -> MaybeEscape {
hostio!(env, console_log(value))
}
pub(crate) fn log_txt<D: DataReader, E: EvmApi<D>>(
mut env: WasmEnvMut<D, E>,
ptr: GuestPtr,
len: u32,
) -> MaybeEscape {
hostio!(env, console_log_text(ptr, len))
}

pub(crate) fn console_tee<D: DataReader, E: EvmApi<D>, T: Into<Value> + Copy>(
mut env: WasmEnvMut<D, E>,
value: T,
) -> Result<T, Escape> {
hostio!(env, console_tee(value))
pub(crate) fn log_i32<D: DataReader, E: EvmApi<D>>(
mut env: WasmEnvMut<D, E>,
value: u32,
) -> MaybeEscape {
hostio!(env, console_log(value))
}

pub(crate) fn tee_i32<D: DataReader, E: EvmApi<D>>(
mut env: WasmEnvMut<D, E>,
value: u32,
) -> Result<u32, Escape> {
hostio!(env, console_tee(value))
}

pub(crate) fn log_i64<D: DataReader, E: EvmApi<D>>(
mut env: WasmEnvMut<D, E>,
value: u64,
) -> MaybeEscape {
hostio!(env, console_log(value))
}

pub(crate) fn tee_i64<D: DataReader, E: EvmApi<D>>(
mut env: WasmEnvMut<D, E>,
value: u64,
) -> Result<u64, Escape> {
hostio!(env, console_tee(value))
}

pub(crate) fn log_f32<D: DataReader, E: EvmApi<D>>(
mut env: WasmEnvMut<D, E>,
value: f32,
) -> MaybeEscape {
hostio!(env, console_log(value))
}

pub(crate) fn tee_f32<D: DataReader, E: EvmApi<D>>(
mut env: WasmEnvMut<D, E>,
value: f32,
) -> Result<f32, Escape> {
hostio!(env, console_tee(value))
}

pub(crate) fn log_f64<D: DataReader, E: EvmApi<D>>(
mut env: WasmEnvMut<D, E>,
value: f64,
) -> MaybeEscape {
hostio!(env, console_log(value))
}

pub(crate) fn tee_f64<D: DataReader, E: EvmApi<D>>(
mut env: WasmEnvMut<D, E>,
value: f64,
) -> Result<f64, Escape> {
hostio!(env, console_tee(value))
}
}

pub(crate) fn null_host<D: DataReader, E: EvmApi<D>>(_: WasmEnvMut<D, E>) {}
pub(crate) mod debug {
use super::*;

pub(crate) fn null_host<D: DataReader, E: EvmApi<D>>(_: WasmEnvMut<D, E>) {}
}
Loading

0 comments on commit 34ee875

Please sign in to comment.