Skip to content

Commit

Permalink
fix urls to the specs
Browse files Browse the repository at this point in the history
  • Loading branch information
Voxelot committed Aug 8, 2023
1 parent e24f188 commit c0016d3
Show file tree
Hide file tree
Showing 20 changed files with 136 additions and 407 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ The release mostly fixes funding during the audit and integration with the bridg

- [#506](https://github.com/FuelLabs/fuel-vm/pull/506): The `mint` and `burn`
opcodes accept a new `$rB` register. It is a sub-identifier used to generate an
`AssetId` by [this rule](https://github.com/FuelLabs/fuel-specs/blob/SilentCicero-multi-token/src/identifiers/asset.md).
`AssetId` by [this rule](https://github.com/FuelLabs/fuel-specs/blob/master/src/identifiers/asset.md).
This feature allows having multi-asset per one contract. It is a huge breaking change, and
after this point, `ContractId` can't be equal to `AssetId`.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


The repository contains crates implementing the
[FuelVM specification](https://github.com/FuelLabs/fuel-specs/blob/master/src/vm/index.md)
[FuelVM specification](https://github.com/FuelLabs/fuel-specs/blob/master/src/fuel-vm/index.md)
used by [fuel-core](https://github.com/FuelLabs/fuel-core)
and [the Sway compiler](https://github.com/FuelLabs/sway/).

Expand Down
12 changes: 4 additions & 8 deletions fuel-asm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ mod unpack;
mod encoding_tests;

#[doc(no_inline)]
pub use args::{
wideint,
GMArgs,
GTFArgs,
};
pub use args::{wideint, GMArgs, GTFArgs};

/// Register ID type
pub type RegisterId = usize;
Expand Down Expand Up @@ -80,7 +76,7 @@ pub struct InvalidOpcode;

bitflags::bitflags! {
/// Possible values for the FLAG instruction.
/// See https://github.com/FuelLabs/fuel-specs/blob/master/src/vm/index.md#flags
/// See https://github.com/FuelLabs/fuel-specs/blob/master/src/fuel-vm/index.md#flags
pub struct Flags: Word {
/// If set, arithmetic errors result in setting $err instead of panicking.
/// This includes cases where result of a computation is undefined, like
Expand Down Expand Up @@ -670,8 +666,8 @@ impl Imm24 {
impl Opcode {
/// Check if the opcode is allowed for predicates.
///
/// <https://github.com/FuelLabs/fuel-specs/blob/master/specs/vm/main.md#predicate-verification>
/// <https://github.com/FuelLabs/fuel-specs/blob/master/specs/vm/opcodes.md#contract-opcodes>
/// <https://github.com/FuelLabs/fuel-specs/blob/master/src/fuel-vm/index.md#predicate-verification>
/// <https://github.com/FuelLabs/fuel-specs/blob/master/src/fuel-vm/instruction-set.md#contract-instructions>
#[allow(clippy::match_like_matches_macro)]
pub fn is_predicate_allowed(&self) -> bool {
use Opcode::*;
Expand Down
2 changes: 1 addition & 1 deletion fuel-crypto/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![docs](https://docs.rs/fuel-crypto/badge.svg)](https://docs.rs/fuel-crypto/)
[![discord](https://img.shields.io/badge/chat%20on-discord-orange?&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/xfpK4Pe)

Fuel cryptographic primitives defined by the [specification](https://github.com/FuelLabs/fuel-specs/blob/master/src/protocol/cryptographic_primitives.md).
Fuel cryptographic primitives defined by the [specification](https://github.com/FuelLabs/fuel-specs/blob/master/src/protocol/cryptographic-primitives.md).

## Compile features

Expand Down
21 changes: 4 additions & 17 deletions fuel-crypto/src/secp256k1/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ use crate::Error;

use fuel_types::Bytes64;

use core::{
fmt,
ops::Deref,
str,
};
use core::{fmt, ops::Deref, str};

#[derive(Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Expand Down Expand Up @@ -116,20 +112,11 @@ impl str::FromStr for Signature {

#[cfg(feature = "std")]
mod use_std {
use crate::{
Error,
Message,
PublicKey,
SecretKey,
Signature,
};
use crate::{Error, Message, PublicKey, SecretKey, Signature};

use lazy_static::lazy_static;
use secp256k1::{
ecdsa::{
RecoverableSignature as SecpRecoverableSignature,
RecoveryId,
},
ecdsa::{RecoverableSignature as SecpRecoverableSignature, RecoveryId},
Secp256k1,
};

Expand Down Expand Up @@ -180,7 +167,7 @@ mod use_std {
/// Sign a given message and compress the `v` to the signature
///
/// The compression scheme is described in
/// <https://github.com/FuelLabs/fuel-specs/blob/master/src/protocol/cryptographic_primitives.md>
/// <https://github.com/FuelLabs/fuel-specs/blob/master/src/protocol/cryptographic-primitives.md>
pub fn sign(secret: &SecretKey, message: &Message) -> Self {
let secret = secret.borrow();
let message = message.to_secp();
Expand Down
20 changes: 5 additions & 15 deletions fuel-crypto/src/secp256r1.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
//! secp256r1 (P-256) functions

use crate::{
Error,
Message,
};
use crate::{Error, Message};
use ecdsa::RecoveryId;
use fuel_types::Bytes64;
use p256::ecdsa::{
Signature,
VerifyingKey,
};
use p256::ecdsa::{Signature, VerifyingKey};

/// Combines recovery id with the signature bytes. See the following link for explanation.
/// https://github.com/FuelLabs/fuel-specs/blob/master/src/protocol/cryptographic_primitives.md#public-key-cryptography
/// https://github.com/FuelLabs/fuel-specs/blob/master/src/protocol/cryptographic-primitives.md#ecdsa-public-key-cryptography
/// Panics if the highest bit of byte at index 32 is set, as this indicates non-normalized
/// signature. Panics if the recovery id is in reduced-x form.
#[cfg(feature = "test-helpers")]
Expand All @@ -28,7 +22,7 @@ fn encode_signature(signature: Signature, recovery_id: RecoveryId) -> [u8; 64] {
}

/// Separates recovery id from the signature bytes. See the following link for
/// explanation. https://github.com/FuelLabs/fuel-specs/blob/master/src/protocol/cryptographic_primitives.md#public-key-cryptography
/// explanation. https://github.com/FuelLabs/fuel-specs/blob/master/src/protocol/cryptographic-primitives.md#ecdsa-public-key-cryptography
fn decode_signature(mut signature: [u8; 64]) -> Option<(Signature, RecoveryId)> {
let v = (signature[32] & 0x80) != 0;
signature[32] &= 0x7f;
Expand Down Expand Up @@ -106,11 +100,7 @@ mod tests {
use super::*;

use p256::ecdsa::SigningKey;
use rand::{
rngs::StdRng,
Rng,
SeedableRng,
};
use rand::{rngs::StdRng, Rng, SeedableRng};

#[test]
fn test_raw_recover() {
Expand Down
2 changes: 1 addition & 1 deletion fuel-merkle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
[![discord](https://img.shields.io/badge/chat%20on-discord-orange?&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/xfpK4Pe)

The crate contains implementation for the Sparse Merkle Tree, Binary Merkle Tree, and Binary Merkle Sum Tree.
[The specification](https://github.com/FuelLabs/fuel-specs/blob/master/src/protocol/cryptographic_primitives.md#merkle-trees)
[The specification](https://github.com/FuelLabs/fuel-specs/blob/master/src/protocol/cryptographic-primitives.md#merkle-trees)
contains more information on how they work inside and how they are [tested](https://github.com/FuelLabs/fuel-specs/blob/master/src/tests/index.md).
31 changes: 7 additions & 24 deletions fuel-merkle/src/sum/merkle_tree.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
use crate::{
common::{
Bytes32,
Subtree,
},
sum::{
empty_sum,
Node,
},
common::{Bytes32, Subtree},
sum::{empty_sum, Node},
};

use fuel_storage::{
Mappable,
StorageMutate,
};
use fuel_storage::{Mappable, StorageMutate};

use core::marker::PhantomData;

Expand All @@ -37,7 +28,7 @@ pub enum MerkleTreeError {
///
/// This is in contrast to the Binary Merkle Tree node, where a node has only a digest.
///
/// See the [specification](https://github.com/FuelLabs/fuel-specs/blob/master/specs/protocol/cryptographic_primitives.md#merkle-trees)
/// See the [specification](https://github.com/FuelLabs/fuel-specs/blob/master/src/protocol/cryptographic-primitives.md#merkle-trees)
/// for more details.
///
/// **Details**
Expand Down Expand Up @@ -122,7 +113,7 @@ where
if !(current.next().is_some()
&& current.node().height() == current.next_node().unwrap().height())
{
break
break;
}

// Merge the two front nodes of the list into a single node
Expand Down Expand Up @@ -161,16 +152,8 @@ where
#[cfg(test)]
mod test {
use crate::{
common::{
Bytes32,
StorageMap,
},
sum::{
leaf_sum,
node_sum,
MerkleTree,
Node,
},
common::{Bytes32, StorageMap},
sum::{leaf_sum, node_sum, MerkleTree, Node},
};
use fuel_merkle_test_helpers::TEST_DATA;
use fuel_storage::Mappable;
Expand Down
4 changes: 2 additions & 2 deletions fuel-tx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
[![docs](https://docs.rs/fuel-tx/badge.svg)](https://docs.rs/fuel-tx/)
[![discord](https://img.shields.io/badge/chat%20on-discord-orange?&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/xfpK4Pe)

This crate contains a definition of types from the [specification](https://github.com/FuelLabs/fuel-specs/tree/master/src/protocol/tx_format),
This crate contains a definition of types from the [specification](https://github.com/FuelLabs/fuel-specs/blob/master/src/tx-format/index.md),
with canonical serialization and deserialization. The `Transaction` and `Checked<Tx>` type
implements fee calculation and [validation of rules](https://github.com/FuelLabs/fuel-specs/blob/master/src/protocol/tx_validity.md) defined by the specification.
implements fee calculation and [validation of rules](https://github.com/FuelLabs/fuel-specs/blob/master/src/protocol/tx-validity.md) defined by the specification.
40 changes: 9 additions & 31 deletions fuel-tx/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,35 +1,20 @@
use crate::{
CheckError,
StorageSlot,
Transaction,
};
use crate::{CheckError, StorageSlot, Transaction};

use derivative::Derivative;
use fuel_crypto::Hasher;
use fuel_merkle::{
binary::in_memory::MerkleTree as BinaryMerkleTree,
sparse::{
in_memory::MerkleTree as SparseMerkleTree,
MerkleTreeKey,
},
};
use fuel_types::{
fmt_truncated_hex,
Bytes32,
ContractId,
Salt,
sparse::{in_memory::MerkleTree as SparseMerkleTree, MerkleTreeKey},
};
use fuel_types::{fmt_truncated_hex, Bytes32, ContractId, Salt};

use alloc::vec::Vec;
use core::{
iter,
ops::Deref,
};
use core::{iter, ops::Deref};

/// The target size of Merkle tree leaves in bytes. Contract code will will be divided
/// into chunks of this size and pushed to the Merkle tree.
///
/// See https://github.com/FuelLabs/fuel-specs/blob/master/src/protocol/id/contract.md#contract-id
/// See https://github.com/FuelLabs/fuel-specs/blob/master/src/identifiers/contract-id.md
const LEAF_SIZE: usize = 16 * 1024;
/// In the event that contract code cannot be divided evenly by the `LEAF_SIZE`, the
/// remainder must be padded to the nearest multiple of 8 bytes. Padding is achieved by
Expand Down Expand Up @@ -65,7 +50,7 @@ impl Contract {

/// Calculate the code root from a contract.
///
/// <https://github.com/FuelLabs/fuel-specs/blob/master/src/protocol/id/contract.md#contract-id>
/// <https://github.com/FuelLabs/fuel-specs/blob/master/src/identifiers/contract-id.md>
pub fn root_from_code<B>(bytes: B) -> Bytes32
where
B: AsRef<[u8]>,
Expand Down Expand Up @@ -111,7 +96,7 @@ impl Contract {

/// Calculate and return the contract id, provided a salt, code root and state root.
///
/// <https://github.com/FuelLabs/fuel-specs/blob/master/src/protocol/id/contract.md#contract-id>
/// <https://github.com/FuelLabs/fuel-specs/blob/master/src/identifiers/contract-id.md>
pub fn id(&self, salt: &Salt, root: &Bytes32, state_root: &Bytes32) -> ContractId {
let mut hasher = Hasher::default();

Expand Down Expand Up @@ -174,17 +159,10 @@ impl TryFrom<&Transaction> for Contract {
#[cfg(test)]
mod tests {
use super::*;
use fuel_types::{
bytes::WORD_SIZE,
Bytes64,
};
use fuel_types::{bytes::WORD_SIZE, Bytes64};
use itertools::Itertools;
use quickcheck_macros::quickcheck;
use rand::{
rngs::StdRng,
RngCore,
SeedableRng,
};
use rand::{rngs::StdRng, RngCore, SeedableRng};
use rstest::rstest;

// safe-guard against breaking changes to the code root calculation for valid
Expand Down
Loading

0 comments on commit c0016d3

Please sign in to comment.