Skip to content

Commit

Permalink
[feature] remove third-party Move module (smart contract) publishing …
Browse files Browse the repository at this point in the history
…ability for mainnet (#170)

Co-authored-by: 0o-de-lally <1364012+0o-de-lally@users.noreply.github.com>
  • Loading branch information
0xzoz and 0o-de-lally committed Feb 22, 2024
1 parent 576e263 commit 0388e07
Show file tree
Hide file tree
Showing 14 changed files with 255 additions and 211 deletions.
35 changes: 34 additions & 1 deletion framework/libra-framework/sources/code.move
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module diem_framework::code {
use diem_std::copyable_any::Any;
use std::option::Option;
use std::string;
use ol_framework::testnet;

// ----------------------------------------------------------------------
// Code Publishing
Expand Down Expand Up @@ -88,6 +89,10 @@ module diem_framework::code {
/// Creating a package with incompatible upgrade policy is disabled.
const EINCOMPATIBLE_POLICY_DISABLED: u64 = 0x8;

//////// 0L ////////
/// Third party contracts can be published on testnet and layer 2. Libra, not blockchain.
const ENOT_A_COMPUTE_PLATFORM: u64 = 0x9;

/// Whether unconditional code upgrade with no compatibility check is allowed. This
/// publication mode should only be used for modules which aren't shared with user others.
/// The developer is responsible for not breaking memory layout of any resources he already
Expand Down Expand Up @@ -127,7 +132,35 @@ module diem_framework::code {

/// Publishes a package at the given signer's address. The caller must provide package metadata describing the
/// package.
public fun publish_package(owner: &signer, pack: PackageMetadata, code: vector<vector<u8>>) acquires PackageRegistry {
public fun publish_package(owner: &signer, pack: PackageMetadata, code:
vector<vector<u8>>) acquires PackageRegistry {
// Contract publishing is done by system resource addresses (0x1, 0x2,
// etc.)
// To defend the throughput and reliability of the chain, the layer 1
// optimizes for the intended use of the chain (programming Libra)
// versus generalized compute (which does not use Libra).
// Despite there being no user deployment of modules, any user can craft
// Move "transaction scripts" for custom workflows which use framework
// smart contracts. Note that such transaction scripts can also be
// executed in multisig and ownerless "resource accounts"
// for community execution.
// Third party modules are possible on L2 networks, and testnet.
// If you need a specific functionality or program on the Layer 1,
// submit a pull request for module "Ascension" (for more info see: https://www.youtube.com/watch?v=jDwqPCAw_7k).

// If it is not a reserved address this must not be chain ID 1 (mainnet)
assert!(system_addresses::is_framework_reserved_address(signer::address_of(owner)) ||
testnet::is_testnet(),
ENOT_A_COMPUTE_PLATFORM
// Rise up this mornin',
// Smiled with the risin' sun,
// Three little birds
// Pitch by my doorstep
// Singin' sweet songs
// Of melodies pure and true,
// Sayin', ("This is my message to you-ou-ou:")
);

// Disallow incompatible upgrade mode. Governance can decide later if
// this should be reconsidered.
assert!(
Expand Down
Binary file modified framework/releases/head.mrb
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
55160121cdabafe018da27c4531e6e25141f939d57110e9c662b6acfbcaed589
b267dcd733538e5cd89e6aa6c0b42c45d96d5452ad4f7dc1dc2fa3f298f1b53a
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Upgrade proposal for package `MoveStdlib`

// Framework commit hash: 85f102a0002684626b730c4168de28b54aca8236
// Framework commit hash: 0aca1662b767111e252f971abf31b4691f16eb9a
// Builder commit hash: db1137ba1f8e7301e325021f71f740063daaf76e

// Next step script hash: 3b3b30322a1bebff817c859db1c065eb10e9048793655d8b1bd9e8c8cd090455
// Next step script hash: b169af1a1a4e0c345708e96223d16e8f2332e666ab101a63f467ea90f966a08b

// source digest: CD5C8655F0340314CC68657DF89A58E257A0A88218E2B07A278A20B843E7A09E
script {
Expand All @@ -17,7 +17,7 @@ script {
let framework_signer = diem_governance::resolve_multi_step_proposal(
proposal_id,
@0000000000000000000000000000000000000000000000000000000000000001,
vector[59u8,59u8,48u8,50u8,42u8,27u8,235u8,255u8,129u8,124u8,133u8,157u8,177u8,192u8,101u8,235u8,16u8,233u8,4u8,135u8,147u8,101u8,93u8,139u8,27u8,217u8,232u8,200u8,205u8,9u8,4u8,85u8,],
vector[177u8,105u8,175u8,26u8,26u8,78u8,12u8,52u8,87u8,8u8,233u8,98u8,35u8,209u8,110u8,143u8,35u8,50u8,230u8,102u8,171u8,16u8,26u8,99u8,244u8,103u8,234u8,144u8,249u8,102u8,160u8,139u8,],
);
let code = vector::empty();
let code_chunk0 =
Expand Down Expand Up @@ -644,6 +644,6 @@ script {
112u8,116u8,105u8,111u8,110u8,0u8,0u8,0u8,6u8,115u8,116u8,114u8,105u8,110u8,103u8,0u8,0u8,0u8,0u8,0u8,
];
code::publish_package_txn(&framework_signer, metadata_chunk1, code);
version::upgrade_set_git(&framework_signer, x"85f102a0002684626b730c4168de28b54aca8236")
version::upgrade_set_git(&framework_signer, x"0aca1662b767111e252f971abf31b4691f16eb9a")
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3b3b30322a1bebff817c859db1c065eb10e9048793655d8b1bd9e8c8cd090455
b169af1a1a4e0c345708e96223d16e8f2332e666ab101a63f467ea90f966a08b
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Upgrade proposal for package `VendorStdlib`

// Framework commit hash: 85f102a0002684626b730c4168de28b54aca8236
// Framework commit hash: 0aca1662b767111e252f971abf31b4691f16eb9a
// Builder commit hash: db1137ba1f8e7301e325021f71f740063daaf76e

// Next step script hash: ae2e3c071a3cbc949dd441d79268e2ea575ea9eae879f1e3494456417854fc3c
// Next step script hash: d65c8d49d68fe6c5be25786e4d4688f29f3f00a62a541b7942e078599b1b654a

// source digest: 5E12DDD8987B153D75378183FB77218A1FAB6038899EB9121ECD4BE94EC1D598
script {
Expand All @@ -17,7 +17,7 @@ script {
let framework_signer = diem_governance::resolve_multi_step_proposal(
proposal_id,
@0000000000000000000000000000000000000000000000000000000000000001,
vector[174u8,46u8,60u8,7u8,26u8,60u8,188u8,148u8,157u8,212u8,65u8,215u8,146u8,104u8,226u8,234u8,87u8,94u8,169u8,234u8,232u8,121u8,241u8,227u8,73u8,68u8,86u8,65u8,120u8,84u8,252u8,60u8,],
vector[214u8,92u8,141u8,73u8,214u8,143u8,230u8,197u8,190u8,37u8,120u8,110u8,77u8,70u8,136u8,242u8,159u8,63u8,0u8,166u8,42u8,84u8,27u8,121u8,66u8,224u8,120u8,89u8,155u8,27u8,101u8,74u8,],
);
let code = vector::empty();
let code_chunk0 =
Expand Down Expand Up @@ -2551,6 +2551,6 @@ script {
0u8,0u8,1u8,10u8,77u8,111u8,118u8,101u8,83u8,116u8,100u8,108u8,105u8,98u8,0u8,
];
code::publish_package_txn(&framework_signer, metadata_chunk1, code);
version::upgrade_set_git(&framework_signer, x"85f102a0002684626b730c4168de28b54aca8236")
version::upgrade_set_git(&framework_signer, x"0aca1662b767111e252f971abf31b4691f16eb9a")
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ae2e3c071a3cbc949dd441d79268e2ea575ea9eae879f1e3494456417854fc3c
d65c8d49d68fe6c5be25786e4d4688f29f3f00a62a541b7942e078599b1b654a
Loading

0 comments on commit 0388e07

Please sign in to comment.