Skip to content

Commit

Permalink
execution-core: removed contract deployment contract id
Browse files Browse the repository at this point in the history
  • Loading branch information
miloszm committed Jul 9, 2024
1 parent 19be190 commit 92bdb8c
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 28 deletions.
23 changes: 0 additions & 23 deletions execution-core/src/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ pub enum CallOrDeploy {
#[derive(Debug, Clone, PartialEq, Eq, Archive, Serialize, Deserialize)]
#[archive_attr(derive(CheckBytes))]
pub struct ContractDeploy {
/// The optional ID of the contract to be deployed.
pub contract_id: Option<ContractId>,
/// Bytecode of the contract to be deployed.
pub bytecode: Bytecode,
/// Owner of the contract to be deployed.
Expand Down Expand Up @@ -139,14 +137,6 @@ impl ContractDeploy {
pub fn to_var_bytes(&self) -> Vec<u8> {
let mut bytes = Vec::new();

match self.contract_id {
Some(contract_id) => {
bytes.push(1);
bytes.extend(contract_id);
}
None => bytes.push(0),
}

bytes.extend(&self.bytecode.to_var_bytes());

bytes.extend((self.owner.len() as u64).to_bytes());
Expand All @@ -170,18 +160,6 @@ impl ContractDeploy {
/// Errors when the bytes are not canonical.
pub fn from_slice(buf: &[u8]) -> Result<Self, BytesError> {
let mut buf = buf;
let (offset, contract_id) = match u8::from_reader(&mut buf)? {
0 => (0, None),
1 => {
let mut contract = [0u8; 32];
contract.copy_from_slice(&buf[..32]);
(32, Some(contract))
}
_ => {
return Err(BytesError::InvalidData);
}
};
let mut buf = &buf[offset..];

let (bytecode, bytecode_len) = Bytecode::from_buf(buf)?;
buf = &buf[bytecode_len..];
Expand All @@ -206,7 +184,6 @@ impl ContractDeploy {
};

Ok(Self {
contract_id,
bytecode,
owner,
constructor_args,
Expand Down
3 changes: 0 additions & 3 deletions execution-core/src/transfer/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,6 @@ impl Payload {
bytes.extend(call.fn_name.as_bytes());
bytes.extend(&call.fn_args);
} else if let Some(deploy) = self.contract_deploy() {
if let Some(contract_id) = &deploy.contract_id {
bytes.extend(contract_id);
}
bytes.extend(&deploy.bytecode.to_hash_input_bytes());
bytes.extend(&deploy.owner);
if let Some(constructor_args) = &deploy.constructor_args {
Expand Down
2 changes: 0 additions & 2 deletions execution-core/tests/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,13 @@ fn transaction_serialization_deploy() -> Result<(), Error> {
let (tx_skeleton, fee, _) = build_skeleton_fee_deposit();

// build the contract-deploy
let contract = [42; 32];
let bytecode = Bytecode {
hash: [1u8; 32],
bytes: vec![1, 2, 3, 4, 5],
};
let owner = [1; 32];
let constructor_args = vec![5];
let deploy = ContractDeploy {
contract_id: Some(contract),
bytecode,
owner: owner.to_vec(),
constructor_args: Some(constructor_args),
Expand Down

0 comments on commit 92bdb8c

Please sign in to comment.