Skip to content

Commit

Permalink
N-10 Move TODOs to issue tracker
Browse files Browse the repository at this point in the history
Some have been added to internal docs & some have been linked in the
code if the issue is outside of this project.
  • Loading branch information
rory-ocl committed Aug 21, 2024
1 parent 2330ac7 commit 73dbc1c
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 24 deletions.
2 changes: 0 additions & 2 deletions mini-alloc/tests/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,4 @@ fn edge_cases() {
assert!(offset < size_bytes());
}
}

// TODO: test allocating all 4GB
}
3 changes: 1 addition & 2 deletions stylus-proc/src/methods/public.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub fn public(_attr: TokenStream, input: TokenStream) -> TokenStream {
continue;
};

// see if user chose a purity or selector (TODO: use drain_filter when stable)
// see if user chose a purity or selector
let mut purity = None;
let mut override_id = None;
let mut override_name = None;
Expand Down Expand Up @@ -301,7 +301,6 @@ pub fn public(_attr: TokenStream, input: TokenStream) -> TokenStream {
#(#borrow_clauses,)*
#where_clauses
{
// TODO: this should be configurable
type Storage = Self;

#[inline(always)]
Expand Down
8 changes: 3 additions & 5 deletions stylus-proc/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub fn storage(_attr: TokenStream, input: TokenStream) -> TokenStream {
error!(&field, "Type not supported for EVM state storage");
};

// implement borrows (TODO: use drain_filter when stable)
// implement borrows
let attrs = mem::take(&mut field.attrs);
for attr in attrs {
if !attr.path.is_ident("borrow") {
Expand Down Expand Up @@ -57,7 +57,6 @@ pub fn storage(_attr: TokenStream, input: TokenStream) -> TokenStream {
let path = &ty.path.segments.last().unwrap().ident;
let not_supported = format!("Type `{path}` not supported for EVM state storage");

// TODO: use short-hand substition from the `storage-macro-shorthand` branch
match path.to_string().as_str() {
x @ ("u8" | "u16" | "u32" | "u64" | "u128" | "i8" | "i16" | "i32" | "i64" | "i128"
| "U8" | "U16" | "U32" | "U64" | "U128" | "I8" | "I16" | "I32" | "I64"
Expand All @@ -68,8 +67,8 @@ pub fn storage(_attr: TokenStream, input: TokenStream) -> TokenStream {
x.to_uppercase()
);
}
"usize" => error!(&field, "{not_supported}."), // TODO: add usize
"isize" => error!(&field, "{not_supported}."), // TODO: add isize
"usize" => error!(&field, "{not_supported}."),
"isize" => error!(&field, "{not_supported}."),
"bool" => error!(&field, "{not_supported}. Instead try `StorageBool`."),
"f32" | "f64" => error!(&field, "{not_supported}. Consider fixed-point arithmetic."),
_ => {}
Expand Down Expand Up @@ -116,7 +115,6 @@ pub fn storage(_attr: TokenStream, input: TokenStream) -> TokenStream {
});
}

// TODO: add mechanism for struct assignment
let expanded = quote! {
#input

Expand Down
2 changes: 1 addition & 1 deletion stylus-proc/src/storage/proc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ impl TryFrom<Path> for PrimitiveKey {

let ty = match name.as_str() {
"address" => "Address",
"bool" => "U8", // TODO: ask alloy to add a Bool type
"bool" => "U8",
"int" => "I256",
"uint" => "U256",
"bytes" => return Ok(Self(syn::parse_str("Vec<u8>")?)),
Expand Down
1 change: 1 addition & 0 deletions stylus-sdk/src/abi/const_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ impl ConstString {
let digits = number.checked_ilog10();
let digits = match digits {
// TODO: simplify when `const_precise_live_drops` is stabilized
// https://github.com/rust-lang/rust/issues/73255
Some(digits) => digits as usize + 1,
None => 1,
};
Expand Down
2 changes: 0 additions & 2 deletions stylus-sdk/src/abi/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ where
const ABI: ConstString = append_dec!("uint", BITS);
}

// test_type!(uint160, "uint160", Uint<160, 3>); TODO: audit alloy
test_type!(uint256, "uint256", Uint<256, 4>);

impl<const BITS: usize, const LIMBS: usize> AbiType for Signed<BITS, LIMBS>
Expand All @@ -73,7 +72,6 @@ where
const ABI: ConstString = append_dec!("int", BITS);
}

// test_type!(int160, "int160", Signed<160, 3>); TODO: audit alloy
test_type!(int256, "int256", Signed<256, 4>);

macro_rules! impl_int {
Expand Down
2 changes: 1 addition & 1 deletion stylus-sdk/src/call/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl RawCall {
/// Note: values are clipped to the amount of ink remaining.
/// See [`Ink and Gas`] for more information on Stylus's compute-pricing model.
///
/// [`Ink and Gas`]: https://developer.arbitrum.io/TODO
/// [`Ink and Gas`]: https://docs.arbitrum.io/stylus/concepts/stylus-gas
pub fn ink(mut self, ink: u64) -> Self {
self.gas = Some(tx::ink_to_gas(ink));
self
Expand Down
2 changes: 1 addition & 1 deletion stylus-sdk/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub fn pay_for_memory_grow(pages: u16) {
wrap_hostio!(
/// Gets the amount of gas remaining. See [`Ink and Gas`] for more information on Stylus's compute pricing.
///
/// [`Ink and Gas`]: https://developer.arbitrum.io/TODO
/// [`Ink and Gas`]: https://docs.arbitrum.io/stylus/concepts/stylus-gas
gas_left evm_gas_left u64
);

Expand Down
8 changes: 4 additions & 4 deletions stylus-sdk/src/hostio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ vm_hooks! {
/// `read_return_data` hostio. The semantics are equivalent to that of the EVM's [`CREATE`]
/// opcode, which notably includes the exact address returned.
///
/// [`Deploying Stylus Programs`]: https://developer.arbitrum.io/TODO
/// [`Deploying Stylus Programs`]: https://docs.arbitrum.io/stylus/stylus-quickstart
/// [`CREATE`]: https://www.evm.codes/#f0
pub fn create1(
code: *const u8,
Expand All @@ -223,7 +223,7 @@ vm_hooks! {
/// via the `read_return_data` hostio. The semantics are equivalent to that of the EVM's
/// `[CREATE2`] opcode, which notably includes the exact address returned.
///
/// [`Deploying Stylus Programs`]: https://developer.arbitrum.io/TODO
/// [`Deploying Stylus Programs`]: https://docs.arbitrum.io/stylus/stylus-quickstart
/// [`CREATE2`]: https://www.evm.codes/#f5
pub fn create2(
code: *const u8,
Expand Down Expand Up @@ -279,7 +279,7 @@ vm_hooks! {
/// [`Ink and Gas`] for more information on Stylus's compute pricing.
///
/// [`GAS`]: https://www.evm.codes/#5a
/// [`Ink and Gas`]: https://developer.arbitrum.io/TODO
/// [`Ink and Gas`]: https://docs.arbitrum.io/stylus/concepts/stylus-gas
pub fn evm_ink_left() -> u64;

/// The `entrypoint!` macro handles importing this hostio, which is required if the
Expand Down Expand Up @@ -375,7 +375,7 @@ vm_hooks! {
/// Gets the price of ink in evm gas basis points. See [`Ink and Gas`] for more information on
/// Stylus's compute-pricing model.
///
/// [`Ink and Gas`]: https://developer.arbitrum.io/TODO
/// [`Ink and Gas`]: https://docs.arbitrum.io/stylus/concepts/stylus-gas
pub fn tx_ink_price() -> u32;

/// Gets the top-level sender of the transaction. The semantics are equivalent to that of the
Expand Down
3 changes: 0 additions & 3 deletions stylus-sdk/src/storage/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ impl StorageBytes {
let len = self.len();
let mut bytes = Vec::with_capacity(len);

// TODO: efficient extraction
for i in 0..len {
let byte = unsafe { self.get_unchecked(i) };
bytes.push(byte);
Expand Down Expand Up @@ -243,7 +242,6 @@ impl Erase for StorageBytes {
}
}

// TODO: efficient bulk insertion
impl Extend<u8> for StorageBytes {
fn extend<T: IntoIterator<Item = u8>>(&mut self, iter: T) {
for elem in iter {
Expand All @@ -252,7 +250,6 @@ impl Extend<u8> for StorageBytes {
}
}

// TODO: efficient bulk insertion
impl<'a> Extend<&'a u8> for StorageBytes {
fn extend<T: IntoIterator<Item = &'a u8>>(&mut self, iter: T) {
for elem in iter {
Expand Down
2 changes: 2 additions & 0 deletions stylus-sdk/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ alias_bytes! {
///
/// Note: in the future `L` won't be needed.
// TODO: drop L after SupportedInt provides LIMBS (waiting for clarity reasons)
// https://github.com/rust-lang/rust/issues/76560
#[derive(Debug)]
pub struct StorageUint<const B: usize, const L: usize> {
slot: U256,
Expand Down Expand Up @@ -214,6 +215,7 @@ impl<const B: usize, const L: usize> From<StorageUint<B, L>> for Uint<B, L> {
///
/// Note: in the future `L` won't be needed.
// TODO: drop L after SupportedInt provides LIMBS (waiting for clarity reasons)
// https://github.com/rust-lang/rust/issues/76560
#[derive(Debug)]
pub struct StorageSigned<const B: usize, const L: usize> {
slot: U256,
Expand Down
6 changes: 3 additions & 3 deletions stylus-sdk/src/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ wrap_hostio! {
/// Gets the price of ink in evm gas basis points. See [`Ink and Gas`] for more information on
/// Stylus's compute-pricing model.
///
/// [`Ink and Gas`]: https://developer.arbitrum.io/TODO
/// [`Ink and Gas`]: https://docs.arbitrum.io/stylus/concepts/stylus-gas
ink_price INK_PRICE tx_ink_price u32
}

/// Converts evm gas to ink. See [`Ink and Gas`] for more information on
/// Stylus's compute-pricing model.
///
/// [`Ink and Gas`]: https://developer.arbitrum.io/TODO
/// [`Ink and Gas`]: https://docs.arbitrum.io/stylus/concepts/stylus-gas
pub fn gas_to_ink(gas: u64) -> u64 {
gas.saturating_mul(ink_price().into())
}

/// Converts ink to evm gas. See [`Ink and Gas`] for more information on
/// Stylus's compute-pricing model.
///
/// [`Ink and Gas`]: https://developer.arbitrum.io/TODO
/// [`Ink and Gas`]: https://docs.arbitrum.io/stylus/concepts/stylus-gas
pub fn ink_to_gas(ink: u64) -> u64 {
ink / ink_price() as u64
}
Expand Down

0 comments on commit 73dbc1c

Please sign in to comment.