Skip to content

Commit

Permalink
Update StarcoinFramework for DAO Space (#3564)
Browse files Browse the repository at this point in the history
* [starcoin-frameowork] Update to latest starcoin-framework for DAOSpace

* [starcoin-frameowork] Update to latest starcoin-framework for DAOSpace

* [vm] log the location when prologue error
  • Loading branch information
jolestar authored Jul 30, 2022
1 parent 6de02c7 commit 18a055f
Show file tree
Hide file tree
Showing 90 changed files with 52 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 26 additions & 13 deletions chain/tests/test_block_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,36 @@ use starcoin_executor::{build_transfer_from_association, DEFAULT_EXPIRATION_TIME
use starcoin_types::account_address;
use starcoin_types::block::{Block, BlockHeader};
use starcoin_types::filter::Filter;
use starcoin_types::identifier::Identifier;
use starcoin_types::language_storage::TypeTag;
use starcoin_vm_types::account_config::genesis_address;
use starcoin_vm_types::event::EventKey;
use starcoin_vm_types::language_storage::StructTag;
use std::str::FromStr;
use std::sync::Arc;

#[stest::test(timeout = 120)]
fn test_chain_filter_events() {
let mut mock_chain = MockChain::new(ChainNetwork::new_test()).unwrap();
let times = 10;
mock_chain.produce_and_apply_times(times).unwrap();

let event_type_tag = TypeTag::Struct(StructTag {
address: genesis_address(),
module: Identifier::from_str("Block").unwrap(),
name: Identifier::from_str("NewBlockEvent").unwrap(),
type_params: vec![],
});

// Origin block event index is 4, after https://github.com/starcoinorg/starcoin-framework/pull/42 , Genesis account create more event_handles, so the block event index is 7.
// So we should use type_tags to filter event, do not dependent on event key.
// let evt_key = EventKey::new_from_address(&genesis_address(), 7);
{
let evt_key = EventKey::new_from_address(&genesis_address(), 4);
let event_filter = Filter {
from_block: 1,
to_block: 5,
event_keys: vec![evt_key],
event_keys: vec![],
addrs: vec![],
type_tags: vec![],
type_tags: vec![event_type_tag.clone()],
limit: None,
reverse: false,
};
Expand All @@ -40,16 +53,16 @@ fn test_chain_filter_events() {
let evt = evts.first().unwrap();
assert_eq!(evt.block_number, 1);
assert_eq!(evt.transaction_index, 0);
assert_eq!(evt.event.key(), &evt_key);
assert_eq!(evt.event.type_tag(), &event_type_tag);
}

{
let event_filter = Filter {
from_block: 1,
to_block: 10,
event_keys: vec![EventKey::new_from_address(&genesis_address(), 4)],
event_keys: vec![],
addrs: vec![],
type_tags: vec![],
type_tags: vec![event_type_tag.clone()],
limit: Some(5),
reverse: false,
};
Expand All @@ -63,9 +76,9 @@ fn test_chain_filter_events() {
let event_filter = Filter {
from_block: 1,
to_block: 10,
event_keys: vec![EventKey::new_from_address(&genesis_address(), 4)],
event_keys: vec![],
addrs: vec![],
type_tags: vec![],
type_tags: vec![event_type_tag.clone()],
limit: Some(5),
reverse: true,
};
Expand All @@ -81,9 +94,9 @@ fn test_chain_filter_events() {
let event_filter = Filter {
from_block: 0,
to_block: 10,
event_keys: vec![EventKey::new_from_address(&genesis_address(), 4)],
event_keys: vec![],
addrs: vec![],
type_tags: vec![],
type_tags: vec![event_type_tag.clone()],
limit: Some(20),
reverse: true,
};
Expand All @@ -99,9 +112,9 @@ fn test_chain_filter_events() {
let event_filter = Filter {
from_block: 0,
to_block: 20,
event_keys: vec![EventKey::new_from_address(&genesis_address(), 4)],
event_keys: vec![],
addrs: vec![],
type_tags: vec![],
type_tags: vec![event_type_tag],
limit: Some(20),
reverse: true,
};
Expand Down
21 changes: 11 additions & 10 deletions cmd/starcoin/src/dev/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,11 @@ fn create_default_account(
.account_sign_txn(transfer_raw_txn)
.unwrap();
let transfer_txn_id = transfer_txn.id();
cli_state
.client()
.submit_transaction(transfer_txn.clone())
.unwrap();
debug!("transfer_txn: {}", transfer_txn_id);
cli_state.client().submit_transaction(transfer_txn).unwrap();

sleep(Duration::from_millis(500));
let block = node_handle.generate_block().unwrap();
assert!(block.transactions().contains(&transfer_txn));
sleep(Duration::from_millis(1000));
let _block = node_handle.generate_block().unwrap();
let transfer_txn_info = cli_state
.client()
.chain_get_transaction_info(transfer_txn_id)
Expand All @@ -187,9 +184,11 @@ fn create_default_account(
transfer_amount
}

//TODO replace this with integration-test
#[stest::test(timeout = 300)]
fn test_upgrade_module() {
let node_config = NodeConfig::random_for_test();
let mut node_config = NodeConfig::random_for_test();
node_config.miner.disable_mint_empty_block = Some(true);
let config = Arc::new(node_config);
let node_handle = run_node_by_config(config.clone()).unwrap();
let rpc_service = node_handle.rpc_service().unwrap();
Expand Down Expand Up @@ -258,7 +257,7 @@ fn test_upgrade_module() {
.chain_get_transaction_info(proposal_txn_id)
.unwrap()
.unwrap();
info!("step1 txn status : {:?}", proposal_txn_info);
debug!("step1 txn status : {:?}", proposal_txn_info);
assert_eq!(proposal_txn_info.status, TransactionStatusView::Executed);

// 2. transfer
Expand Down Expand Up @@ -434,9 +433,11 @@ fn test_upgrade_module() {
node_handle.stop().unwrap();
}

//TODO replace this with integration-test
#[stest::test(timeout = 300)]
fn test_only_new_module() {
let node_config = NodeConfig::random_for_test();
let mut node_config = NodeConfig::random_for_test();
node_config.miner.disable_mint_empty_block = Some(true);
let config = Arc::new(node_config);
let node_handle = run_node_by_config(config.clone()).unwrap();
let rpc_service = node_handle.rpc_service().unwrap();
Expand Down
Binary file modified genesis/generated/halley/genesis
Binary file not shown.
8 changes: 4 additions & 4 deletions sync/src/block_connector/test_illegal_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ async fn test_verify_consensus_failed() {
}
}

#[stest::test]
#[stest::test(timeout = 120)]
async fn test_verify_new_epoch_block_uncle_should_none_failed() {
let apply_failed = test_verify_uncles_in_old_epoch(true).await;
assert!(apply_failed.is_err());
Expand Down Expand Up @@ -727,7 +727,7 @@ async fn test_verify_uncles_in_old_epoch(begin_epoch: bool) -> Result<Block> {
)
}

#[stest::test]
#[stest::test(timeout = 120)]
async fn test_verify_uncles_in_old_epoch_failed() {
let apply_failed = test_verify_uncles_in_old_epoch(false).await;
assert!(apply_failed.is_err());
Expand All @@ -736,7 +736,7 @@ async fn test_verify_uncles_in_old_epoch_failed() {
}
}

#[stest::test]
#[stest::test(timeout = 120)]
async fn test_verify_uncles_uncle_exist_failed() {
let count = 5;
let (uncle_header, mut writeable_block_chain_service, node_config, storage) =
Expand Down Expand Up @@ -860,7 +860,7 @@ async fn test_verify_uncle_and_parent_number_failed() {
}
}

#[stest::test]
#[stest::test(timeout = 120)]
async fn test_verify_uncle_which_parent_is_end_block_in_last_epoch() {
let count = G_TEST_CONFIG.consensus_config.epoch_block_count;
let (uncle_header, mut writeable_block_chain_service, node_config, storage) =
Expand Down
2 changes: 1 addition & 1 deletion sync/src/block_connector/test_write_block_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ async fn test_block_chain_forks() {
);
}

#[stest::test]
#[stest::test(timeout = 120)]
async fn test_block_chain_switch_main() {
let times = 10;
let (mut writeable_block_chain_service, node_config, _) = create_writeable_block_chain().await;
Expand Down
4 changes: 2 additions & 2 deletions sync/src/tasks/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use stream_task::{
};
use test_helper::DummyNetworkService;

#[stest::test]
#[stest::test(timeout = 120)]
pub async fn test_full_sync_new_node() -> Result<()> {
let net1 = ChainNetwork::new_builtin(BuiltinNetworkID::Test);
let mut node1 = SyncNodeMocker::new(net1, 1, 50)?;
Expand Down Expand Up @@ -210,7 +210,7 @@ pub async fn test_failed_block() -> Result<()> {
}
}

#[stest::test]
#[stest::test(timeout = 120)]
pub async fn test_full_sync_fork() -> Result<()> {
let net1 = ChainNetwork::new_builtin(BuiltinNetworkID::Test);
let mut node1 = SyncNodeMocker::new(net1, 1, 50)?;
Expand Down
2 changes: 1 addition & 1 deletion vm/stdlib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ serde = {version = "1.0.130", default-features = false}
sha2 = "0.10.2"
simplelog = "0.9.0"
starcoin-crypto = {git = "https://github.com/starcoinorg/starcoin-crypto", rev = "d871dfb4216f034ee334a575926c101574d9d6dc"}
starcoin-framework = {git = "https://github.com/starcoinorg/starcoin-framework", rev = "cf1deda180af40a8b3e26c0c7b548c4c290cd7e7"}
starcoin-framework = {git = "https://github.com/starcoinorg/starcoin-framework", rev = "0d37c891a2d660fb94b3b8c0d396b67890691a00"}
starcoin-move-compiler = {path = "../../vm/compiler"}
starcoin-vm-types = {path = "../types"}
tempfile = "3.2.0"
Expand Down
Binary file not shown.
Binary file removed vm/stdlib/compiled/latest/stdlib/11_BCS.mv
Binary file not shown.
Binary file added vm/stdlib/compiled/latest/stdlib/12_BCS.mv
Binary file not shown.
Binary file modified vm/stdlib/compiled/latest/stdlib/21_PackageTxnManager.mv
Binary file not shown.
Binary file modified vm/stdlib/compiled/latest/stdlib/22_Treasury.mv
Binary file not shown.
Binary file modified vm/stdlib/compiled/latest/stdlib/35_Account.mv
Binary file not shown.
Binary file modified vm/stdlib/compiled/latest/stdlib/36_AccountScripts.mv
Binary file not shown.
Binary file removed vm/stdlib/compiled/latest/stdlib/37_Block.mv
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added vm/stdlib/compiled/latest/stdlib/39_SnapshotUtil.mv
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added vm/stdlib/compiled/latest/stdlib/45_DAORegistry.mv
Binary file not shown.
Binary file added vm/stdlib/compiled/latest/stdlib/46_DAOAccount.mv
Binary file not shown.
Binary file added vm/stdlib/compiled/latest/stdlib/47_Ring.mv
Binary file not shown.
Binary file added vm/stdlib/compiled/latest/stdlib/48_Block.mv
Binary file not shown.
Binary file added vm/stdlib/compiled/latest/stdlib/49_DAOSpace.mv
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added vm/stdlib/compiled/latest/stdlib/52_Arith.mv
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed vm/stdlib/compiled/latest/stdlib/59_IdentifierNFT.mv
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed vm/stdlib/compiled/latest/stdlib/78_Arith.mv
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions vm/stdlib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub const STDLIB_DIR: Dir = starcoin_framework::SOURCES_DIR;
// The current stdlib that is freshly built. This will never be used in deployment so we don't need
// to pull the same trick here in order to include this in the Rust binary.
static G_FRESH_MOVELANG_STDLIB: Lazy<Vec<Vec<u8>>> = Lazy::new(|| {
build_stdlib(STARCOIN_FRAMEWORK_SOURCES.files.as_slice())
build_stdlib(STARCOIN_FRAMEWORK_SOURCES.files().as_slice())
.values()
.map(|m| {
let mut blob = vec![];
Expand Down Expand Up @@ -184,7 +184,7 @@ fn module_to_package(
}

pub fn stdlib_files() -> Vec<String> {
STARCOIN_FRAMEWORK_SOURCES.files.clone()
STARCOIN_FRAMEWORK_SOURCES.files()
}

pub fn build_stdlib(targets: &[String]) -> BTreeMap<String, CompiledModule> {
Expand Down
2 changes: 1 addition & 1 deletion vm/stdlib/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ fn main() {
std::env::set_current_dir(&base_path).expect("failed to change directory");

let sources = &STARCOIN_FRAMEWORK_SOURCES;
let new_modules = build_stdlib(&sources.files);
let new_modules = build_stdlib(&sources.files());

if !no_check_compatibility {
if let Some((pre_stable_version, pre_stable_modules)) = pre_version
Expand Down
6 changes: 3 additions & 3 deletions vm/vm-runtime/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn convert_prologue_runtime_error(error: VMError) -> Result<(), VMStatus> {
let status = error.into_vm_status();
Err(match status {
VMStatus::Executed => VMStatus::Executed,
VMStatus::MoveAbort(_location, code) => {
VMStatus::MoveAbort(location, code) => {
let (category, reason) = error_split(code);
let new_major_status = match (category, reason) {
(REQUIRES_ADDRESS, PROLOGUE_ACCOUNT_DOES_NOT_EXIST) => {
Expand Down Expand Up @@ -88,8 +88,8 @@ pub fn convert_prologue_runtime_error(error: VMError) -> Result<(), VMStatus> {
}
(category, reason) => {
warn!(
"prologue runtime unknown: category({}), reason:({})",
category, reason
"prologue runtime unknown: category({}), reason:({}), location:({})",
category, reason, location
);
StatusCode::UNEXPECTED_ERROR_FROM_KNOWN_MOVE_FUNCTION
}
Expand Down

0 comments on commit 18a055f

Please sign in to comment.