Skip to content

Commit

Permalink
Upgrade script to use usecs after timestamp upgrading timestamp logic (
Browse files Browse the repository at this point in the history
…#1075)

Co-authored-by: Andy Golay <andygolay@gmail.com>
Co-authored-by: musitdev <philippe.delrieu@free.fr>
Co-authored-by: Mikhail Zabaluev <mikhail.zabaluev@movementlabs.xyz>
Co-authored-by: Richard Melkonian <35300528+0xmovses@users.noreply.github.com>
Co-authored-by: Icarus131 <anirudhprasad131@protonmail.com>
Co-authored-by: primata <primata@movementlabs.xyz>
Co-authored-by: Icarus131 <anirudhprasad131@gmail.com>
Co-authored-by: Richard Melkonian <r.v.melkonian@gmail.com>
Co-authored-by: Radu Popa <radupopa21be@gmail.com>
  • Loading branch information
10 people authored Mar 4, 2025
1 parent d05782b commit 9cedb2a
Show file tree
Hide file tree
Showing 15 changed files with 115 additions and 10 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/checks-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,34 @@ jobs:
nix develop --command bash -c "just movement-full-node native build.setup.eth-holesky.celestia-local.test -t=false"
nix develop --command bash -c "just movement-full-node native build.setup.eth-holesky.celestia-local.test -t=false"
# Elsa to Biarritz RC1
movement-elsa-to-biarritz-rc1-bring-up:
if: github.event.label.name == 'cicd:movement-elsa-to-biarritz-rc1' || github.ref == 'refs/heads/main'

strategy:
matrix:
include:
- os: ubuntu-22.04
arch: x86_64
runs-on: buildjet-16vcpu-ubuntu-2204

runs-on: ${{ matrix.runs-on }}

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true

- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main

- name: Run Movement Full Node Gas DoS Test
env:
CELESTIA_LOG_LEVEL: FATAL # adjust the log level while debugging
run: |
nix develop --command bash -c "just movement-full-node native build.setup.eth-local.celestia-local.gas-dos -t=false"
movement-celestia-da-light-node:
if: false # this is effectively tested by the above
strategy:
Expand Down
1 change: 1 addition & 0 deletions protocol-units/bridge/contracts/minter/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
8 changes: 8 additions & 0 deletions protocol-units/bridge/contracts/minter/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "Minter"
version = "0.0.0"

[dependencies.AptosFramework]
git = "https://github.com/movementlabsxyz/aptos-core.git"
rev = "movement"
subdir = "aptos-move/framework/aptos-framework"
14 changes: 14 additions & 0 deletions protocol-units/bridge/contracts/minter/sources/minter.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
script {
use aptos_framework::aptos_governance;
use aptos_framework::transaction_fee;

fun main(core_resources: &signer) {

let core_signer = aptos_governance::get_signer_testnet_only(core_resources, @0x1);

let framework_signer = &core_signer;

transaction_fee::burn_from(framework_signer, @0xdead, 4);

}
}
24 changes: 24 additions & 0 deletions protocol-units/da/movement/protocol/util/src/blob/ir/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,28 @@ pub mod block {
Ok(Self::now(blob))
}
}

impl<C> TryFrom<block::Id> for InnerSignedBlobV1Data<C>
where
C: Curve + Verify<C> + Digester<C>,
{
type Error = anyhow::Error;

fn try_from(id: block::Id) -> Result<Self, Self::Error> {
let blob = id.as_bytes().to_vec();
Ok(Self::now(blob))
}
}

impl<C> TryFrom<Vec<block::Id>> for InnerSignedBlobV1Data<C>
where
C: Curve + Verify<C> + Digester<C>,
{
type Error = anyhow::Error;

fn try_from(ids: Vec<block::Id>) -> Result<Self, Self::Error> {
let blob = bcs::to_bytes(&ids)?;
Ok(Self::now(blob))
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub mod dot_movement;

use aptos_framework_biarritz_rc1_release::cached::gas_upgrade::BiarritzRc1;
use aptos_framework_biarritz_rc1_release::cached::full::feature_upgrade::BiarritzRc1;
use maptos_framework_release_util::{Release, ReleaseSigner};
use std::future::Future;

Expand All @@ -21,7 +21,7 @@ impl ElsaToBiarritzRc1 {
// upgrade to Biarritz RC1 with the gas upgrade
let biarritz_rc1 = BiarritzRc1::new();
biarritz_rc1
.release(signer, 2_000_000, 100, 60, client)
.release(signer, 2_000_000, 100, 60_000, client)
.await
.map_err(|e| ElsaToBiarritzRc1Error::MigrationFailed(e.into()))?;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use maptos_framework_release_util::commit_hash_with_script;
commit_hash_with_script!(
BiarritzRc1, // Struct name
"https://github.com/movementlabsxyz/aptos-core.git", // Repository URL
"d86339c130c3a9afd9413db95412b7586b78c905", // Commit hash
"aa45303216be96ea30d361ab7eb2e95fb08c2dcb", // Commit hash
6, // Bytecode version
"biarritz-rc1.mrb", // MRB file name
"CACHE_BIARRITZ_RC1_FRAMEWORK_RELEASE" // Cache environment variable for Elsa
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use maptos_framework_release_util::mrb_release;
mrb_release!(
BiarritzRc1,
BIARRTIZ_RC1,
"d86339c130c3a9afd9413db95412b7586b78c905-biarritz-rc1.mrb"
"aa45303216be96ea30d361ab7eb2e95fb08c2dcb-biarritz-rc1.mrb"
);

generate_gas_upgrade_module!(gas_upgrade, BiarritzRc1, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use maptos_framework_release_util::commit_hash_with_script;
commit_hash_with_script!(
BiarritzRc1, // Struct name
"https://github.com/movementlabsxyz/aptos-core.git", // Repository URL
"d86339c130c3a9afd9413db95412b7586b78c905", // Commit hash
"aa45303216be96ea30d361ab7eb2e95fb08c2dcb", // Commit hash
6, // Bytecode version
"biarritz-rc1.mrb", // MRB file name
"CACHE_BIARRITZ_RC1_FRAMEWORK_RELEASE" // Cache environment variable for Elsa
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ where
let now_u64 = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.map_err(|e| ReleaseBundleError::Build(e.into()))?
.as_secs();
.as_micros() as u64;
let expiration_timestamp_secs = now_u64 + expiration_timestamp_sec_offset;
self.set_feature_flags(
signer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ where
let now_u64 = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.map_err(|e| ReleaseBundleError::Build(e.into()))?
.as_secs();
.as_micros() as u64;
let expiration_timestamp_secs = now_u64 + expiration_timestamp_sec_offset;
self.set_release_script(
signer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ where
let now_u64 = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.map_err(|e| ReleaseBundleError::Build(e.into()))?
.as_secs();
.as_micros() as u64;
let expiration_timestamp_secs = now_u64 + expiration_timestamp_sec_offset;

info!("Upgrading gas parameters");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ pub trait Release {
let now_u64 = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.map_err(|e| ReleaseBundleError::Build(e.into()))?
.as_secs();
.as_micros() as u64;
let expiration_timestamp = now_u64 + expiration_timestamp_sec_offset as u64;
let _completed_votes = self
.vote(signer, max_gas_amount, gas_unit_price, expiration_timestamp, client)
Expand Down Expand Up @@ -412,7 +412,7 @@ fn build_release_bundles_raw_transactions(
let now_u64 = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.map_err(|e| ReleaseBundleError::Build(e.into()))?
.as_secs();
.as_micros() as u64;
let expiration_timestamp = now_u64 + (expiration_timestamp_sec_offset * i) as u64;

let raw_transaction = RawTransaction::new(
Expand Down
8 changes: 8 additions & 0 deletions protocol-units/settlement/mcr/contracts/minter/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "Minter"
version = "0.0.0"

[dependencies.AptosFramework]
git = "https://github.com/movementlabsxyz/aptos-core.git"
rev = "movement"
subdir = "aptos-move/framework/aptos-framework"
22 changes: 22 additions & 0 deletions protocol-units/settlement/mcr/contracts/minter/sources/minter.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
script {
use std::signer;
use aptos_framework::aptos_account;
use aptos_framework::aptos_coin;
use aptos_framework::coin;

// Tune this parameter based upon the actual gas costs
const GAS_BUFFER: u64 = 100000;
const U64_MAX: u64 = 18446744073709551615;

fun main(minter: &signer, dst_addr: address, amount: u64) {
let minter_addr = signer::address_of(minter);

// Do not mint if it would exceed U64_MAX
let balance = coin::balance<aptos_coin::AptosCoin>(minter_addr);
if (balance < U64_MAX - amount - GAS_BUFFER) {
aptos_coin::mint(minter, minter_addr, amount + GAS_BUFFER);
};

aptos_account::transfer(minter, dst_addr, amount);
}
}

0 comments on commit 9cedb2a

Please sign in to comment.