Skip to content

Commit

Permalink
Merge b6a05fb into faf9bb4
Browse files Browse the repository at this point in the history
  • Loading branch information
nkysg authored Dec 26, 2022
2 parents faf9bb4 + b6a05fb commit 82bccb5
Show file tree
Hide file tree
Showing 245 changed files with 5,189 additions and 1,634 deletions.
909 changes: 558 additions & 351 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ members = [
"vm/transaction-builder-generator",
"vm/move-coverage",
"vm/resource-viewer",
"vm/starcoin-gas",
"vm/dev",
"vm/gas-algebra-ext",
"vm/move-explain",
"vm/move-package-manager",
"vm/vm-status-translator",
Expand Down Expand Up @@ -178,7 +180,9 @@ default-members = [
"vm/transaction-builder-generator",
"vm/move-coverage",
"vm/resource-viewer",
"vm/starcoin-gas",
"vm/dev",
"vm/gas-algebra-ext",
"vm/move-explain",
"vm/move-package-manager",
"vm/vm-status-translator",
Expand Down
2 changes: 1 addition & 1 deletion abi/decoder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ version = "1.12.5"
[dependencies]
anyhow = "1.0.41"
hex = "0.4.3"
move-binary-format = { git = "https://github.com/starcoinorg/move", rev = "204da96abcb6eb82bc50fcbcd4331f6cc3d17439" }
move-binary-format = { git = "https://github.com/starcoinorg/move", rev = "8613078820ba81686071b224e64441b68d6dc6cf" }
starcoin-resource-viewer = { path = "../../vm/resource-viewer" }
starcoin-vm-types = { path = "../../vm/types" }
starcoin-abi-types = { path = "../types" }
Expand Down
4 changes: 4 additions & 0 deletions abi/decoder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,12 @@ fn value_to_json(origin: AnnotatedMoveValue) -> serde_json::Value {
use serde_json::Value;
match origin {
AnnotatedMoveValue::U8(v) => Value::Number(v.into()),
AnnotatedMoveValue::U16(v) => Value::Number(v.into()),
AnnotatedMoveValue::U32(v) => Value::Number(v.into()),
AnnotatedMoveValue::U64(v) => Value::Number(v.into()),
AnnotatedMoveValue::U128(v) => Value::Number(v.into()),
// XXX FIXME YSG
AnnotatedMoveValue::U256(v) => Value::String(v.to_string()),
AnnotatedMoveValue::Bool(v) => Value::Bool(v),
AnnotatedMoveValue::Address(v) => Value::String(v.to_string()),
AnnotatedMoveValue::Vector(v) => Value::Array(v.into_iter().map(value_to_json).collect()),
Expand Down
2 changes: 1 addition & 1 deletion abi/resolver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ starcoin-vm-types = { path = "../../vm/types" }
starcoin-abi-types = { path = "../types" }
anyhow = "~1"
starcoin-resource-viewer = { path = "../../vm/resource-viewer" }
move-model = { git = "https://github.com/starcoinorg/move", rev = "204da96abcb6eb82bc50fcbcd4331f6cc3d17439" }
move-model = { git = "https://github.com/starcoinorg/move", rev = "8613078820ba81686071b224e64441b68d6dc6cf" }
[dev-dependencies]
stdlib = { path = "../../vm/stdlib" }
serde_json = "1"
Expand Down
13 changes: 9 additions & 4 deletions abi/resolver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use starcoin_resource_viewer::module_cache::ModuleCache;
use starcoin_resource_viewer::resolver::Resolver;
use starcoin_vm_types::access::ModuleAccess;
use starcoin_vm_types::file_format::{
CompiledModule, CompiledScript, FunctionDefinitionIndex, StructDefinitionIndex, Visibility,
CompiledModule, CompiledScript, FunctionDefinitionIndex, StructDefinitionIndex,
};
use starcoin_vm_types::identifier::{IdentStr, Identifier};
use starcoin_vm_types::language_storage::{ModuleId, StructTag, TypeTag};
Expand Down Expand Up @@ -63,7 +63,7 @@ impl<'a> ABIResolver<'a> {
let functions = m
.exposed_functions
.iter()
.filter(|(_, func)| func.visibility == Visibility::Script) // only script functions
// .filter(|(_, func)| func.visibility == Visibility::Script) // only script functions
.map(|(name, func)| self.function_to_abi(&module_id, name.as_ident_str(), func))
.collect::<Result<Vec<_>>>()?;
Ok(ModuleABI::new(m.module_id(), structs, functions))
Expand Down Expand Up @@ -108,8 +108,11 @@ impl<'a> ABIResolver<'a> {
Ok(match type_tag {
TypeTag::Bool => TypeInstantiation::Bool,
TypeTag::U8 => TypeInstantiation::U8,
TypeTag::U16 => TypeInstantiation::U16,
TypeTag::U32 => TypeInstantiation::U32,
TypeTag::U64 => TypeInstantiation::U64,
TypeTag::U128 => TypeInstantiation::U128,
TypeTag::U256 => TypeInstantiation::U256,
TypeTag::Address => TypeInstantiation::Address,

TypeTag::Signer => TypeInstantiation::Signer,
Expand All @@ -134,8 +137,11 @@ impl<'a> ABIResolver<'a> {
Ok(match ty {
Type::Bool => TypeInstantiation::Bool,
Type::U8 => TypeInstantiation::U8,
Type::U16 => TypeInstantiation::U16,
Type::U32 => TypeInstantiation::U32,
Type::U64 => TypeInstantiation::U64,
Type::U128 => TypeInstantiation::U128,
Type::U256 => TypeInstantiation::U256,
Type::Address => TypeInstantiation::Address,
Type::Signer => TypeInstantiation::Signer,
Type::Struct {
Expand Down Expand Up @@ -388,8 +394,7 @@ mod tests {
}))
}
StateKey::TableItem(_table_item) => {
// XXX FIXME YSG
unimplemented!()
anyhow::bail!("no need table_item")
}
}
}
Expand Down
1 change: 1 addition & 0 deletions abi/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ serde_bytes = "0.11"
serde_json = "~1"
hex = "0.4"
schemars = { git = "https://github.com/starcoinorg/schemars", rev = "6972da92f4360e1779168bb3fe0274c521d324e2" }
move-core-types = { git = "https://github.com/starcoinorg/move", rev = "8613078820ba81686071b224e64441b68d6dc6cf" }
17 changes: 14 additions & 3 deletions abi/types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,8 +571,11 @@ impl FieldABI {
pub enum TypeInstantiation {
Bool,
U8,
U16,
U32,
U64,
U128,
U256,
Address,
Signer,
Vector(Box<TypeInstantiation>),
Expand All @@ -591,9 +594,11 @@ impl TypeInstantiation {
Ok(match self {
Self::Bool => MoveTypeLayout::Bool,
Self::U8 => MoveTypeLayout::U8,

Self::U16 => MoveTypeLayout::U16,
Self::U32 => MoveTypeLayout::U32,
Self::U64 => MoveTypeLayout::U64,
Self::U128 => MoveTypeLayout::U128,
Self::U256 => MoveTypeLayout::U256,
Self::Address => MoveTypeLayout::Address,
Self::Signer => MoveTypeLayout::Signer,

Expand All @@ -607,14 +612,16 @@ impl TypeInstantiation {
Ok(match self {
Self::Bool => TypeTag::Bool,
Self::U8 => TypeTag::U8,

Self::U16 => TypeTag::U16,
Self::U32 => TypeTag::U32,
Self::U64 => TypeTag::U64,
Self::U128 => TypeTag::U128,
Self::U256 => TypeTag::U256,
Self::Address => TypeTag::Address,
Self::Signer => TypeTag::Signer,

Self::Vector(t) => TypeTag::Vector(Box::new(t.type_tag()?)),
Self::Struct(s) => TypeTag::Struct(s.struct_tag()?),
Self::Struct(s) => TypeTag::Struct(Box::new(s.struct_tag()?)),
Self::TypeParameter(_) => anyhow::bail!("get type tag failed -- {:?}", self),
Self::Reference(_, _) => anyhow::bail!("get type tag failed -- {:?}", self),
})
Expand Down Expand Up @@ -650,8 +657,12 @@ impl<'d> serde::de::DeserializeSeed<'d> for &TypeInstantiation {
match &self {
T::Bool => bool::deserialize(deserializer).map(V::Bool),
T::U8 => u8::deserialize(deserializer).map(Into::into),
T::U16 => u16::deserialize(deserializer).map(Into::into),
T::U32 => u32::deserialize(deserializer).map(Into::into),
T::U64 => u64::deserialize(deserializer).map(Into::into),
T::U128 => u128::deserialize(deserializer).map(Into::into),
// XXX FIXME YSG
T::U256 => Err(D::Error::custom("type U256 not process variant")),
T::Address => {
AccountAddress::deserialize(deserializer).map(|addr| V::String(addr.to_string()))
}
Expand Down
4 changes: 2 additions & 2 deletions chain/tests/test_block_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ fn test_chain_filter_events() {
let times = 10;
mock_chain.produce_and_apply_times(times).unwrap();

let event_type_tag = TypeTag::Struct(StructTag {
let event_type_tag = TypeTag::Struct(Box::new(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.
Expand Down
2 changes: 1 addition & 1 deletion cmd/airdrop/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ async fn main() -> Result<()> {
.token_code
.unwrap_or_else(|| G_STC_TOKEN_CODE.clone())
.try_into()?;
let is_stc = stc_type_tag().eq(&TypeTag::Struct(token_type.clone()));
let is_stc = stc_type_tag().eq(&TypeTag::Struct(Box::new(token_type.clone())));

let mut total_amount = 0u128;
let airdrop_infos: Vec<AirdropInfo> = {
Expand Down
4 changes: 2 additions & 2 deletions cmd/db-exporter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ logger = { path = "../../commons/logger", package = "starcoin-logger" }
clap = { version = "3", features = ["derive"] }
atomic-counter = "1.0.1"
tokio = { version = "^1", features = ["full"] }
move-binary-format = { git = "https://github.com/starcoinorg/move", rev = "204da96abcb6eb82bc50fcbcd4331f6cc3d17439" }
move-bytecode-verifier = { git = "https://github.com/starcoinorg/move", rev = "204da96abcb6eb82bc50fcbcd4331f6cc3d17439" }
move-binary-format = { git = "https://github.com/starcoinorg/move", rev = "8613078820ba81686071b224e64441b68d6dc6cf" }
move-bytecode-verifier = { git = "https://github.com/starcoinorg/move", rev = "8613078820ba81686071b224e64441b68d6dc6cf" }
starcoin-resource-viewer = { path = "../../vm/resource-viewer" }
starcoin-state-tree = { path = "../../state/state-tree" }
[target."cfg(target_os=\"linux\")".dependencies]
Expand Down
10 changes: 3 additions & 7 deletions cmd/db-exporter/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,7 @@ pub fn apply_block(
network: BuiltinNetworkID,
verifier: Verifier,
) -> anyhow::Result<()> {
::logger::init();
let net = ChainNetwork::new_builtin(network);
let db_storage = DBStorage::new(to_dir.join("starcoindb/db"), RocksdbConfig::default(), None)?;
let storage = Arc::new(Storage::new(StorageInstance::new_cache_and_db_instance(
Expand Down Expand Up @@ -767,12 +768,6 @@ pub fn startup_info_back(

let cur_num = chain.status().head().number();
let back_size = back_size.unwrap_or(BACK_SIZE);
let back_size = if back_size < BACK_SIZE {
BACK_SIZE
} else {
back_size
};

if cur_num <= back_size {
println!(
"startup_info block number {} <= back_size {}",
Expand Down Expand Up @@ -1838,12 +1833,13 @@ impl serde::Serialize for MoveValue {
}
AnnotatedMoveValue::Bytes(v) => hex::encode(v).serialize(serializer),
AnnotatedMoveValue::Struct(v) => MoveStruct(v.clone()).serialize(serializer),
_ => todo!("XXX FXIME YSG"),
}
}
}
fn parse_struct_tag(input: &str) -> anyhow::Result<StructTag> {
match parse_type_tag(input)? {
TypeTag::Struct(s) => Ok(s),
TypeTag::Struct(s) => Ok(*s),
_ => {
anyhow::bail!("invalid struct tag")
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/resource-exporter/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,14 @@ impl serde::Serialize for MoveValue {
}
AnnotatedMoveValue::Bytes(v) => hex::encode(v).serialize(serializer),
AnnotatedMoveValue::Struct(v) => MoveStruct(v.clone()).serialize(serializer),
_ => todo!("XXX FIXME YSG"),
}
}
}

fn parse_struct_tag(input: &str) -> anyhow::Result<StructTag> {
match parse_type_tag(input)? {
TypeTag::Struct(s) => Ok(s),
TypeTag::Struct(s) => Ok(*s),
_ => {
anyhow::bail!("invalid struct tag")
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/starcoin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ starcoin-resource-viewer = { path = "../../vm/resource-viewer" }
starcoin-service-registry = { path = "../../commons/service-registry" }
starcoin-move-explain = { path = "../../vm/move-explain" }
vm-status-translator = { path = "../../vm/vm-status-translator" }
move-errmapgen = { git = "https://github.com/starcoinorg/move", rev = "204da96abcb6eb82bc50fcbcd4331f6cc3d17439" }
move-errmapgen = { git = "https://github.com/starcoinorg/move", rev = "8613078820ba81686071b224e64441b68d6dc6cf" }
network-api = { path = "../../network/api", package = "network-api" }
starcoin-network-rpc-api = { path = "../../network-rpc/api" }
starcoin-abi-decoder = { path = "../../abi/decoder" }
starcoin-abi-resolver = { path = "../../abi/resolver" }
starcoin-abi-types = { path = "../../abi/types" }
move-command-line-common = { git = "https://github.com/starcoinorg/move", rev = "204da96abcb6eb82bc50fcbcd4331f6cc3d17439" }
move-command-line-common = { git = "https://github.com/starcoinorg/move", rev = "8613078820ba81686071b224e64441b68d6dc6cf" }

[dev-dependencies]
test-helper = { path = "../../test-helper" }
Expand Down
4 changes: 3 additions & 1 deletion cmd/starcoin/src/account/accept_token_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ impl CommandAction for AcceptTokenCommand {
TransactionPayload::ScriptFunction(ScriptFunction::new(
ModuleId::new(core_code_address(), Identifier::new("Account").unwrap()),
Identifier::new("accept_token").unwrap(),
vec![TypeTag::Struct(opt.token_code.clone().try_into().unwrap())],
vec![TypeTag::Struct(Box::new(
opt.token_code.clone().try_into().unwrap(),
))],
vec![],
)),
)
Expand Down
14 changes: 7 additions & 7 deletions cmd/starcoin/src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ pub enum EventDataView {

impl EventDataView {
pub fn new(event_type_tag: &TypeTag, event_data: &[u8]) -> anyhow::Result<Self> {
if event_type_tag == &TypeTag::Struct(DepositEvent::struct_tag()) {
if event_type_tag == &TypeTag::Struct(Box::new(DepositEvent::struct_tag())) {
if let Ok(received_event) = DepositEvent::try_from_bytes(event_data) {
Ok(EventDataView::ReceivedPayment {
amount: received_event.amount(),
Expand All @@ -179,7 +179,7 @@ impl EventDataView {
} else {
Err(format_err!("Unable to parse ReceivedPaymentEvent"))
}
} else if event_type_tag == &TypeTag::Struct(WithdrawEvent::struct_tag()) {
} else if event_type_tag == &TypeTag::Struct(Box::new(WithdrawEvent::struct_tag())) {
if let Ok(sent_event) = WithdrawEvent::try_from_bytes(event_data) {
Ok(EventDataView::SentPayment {
amount: sent_event.amount(),
Expand All @@ -189,7 +189,7 @@ impl EventDataView {
} else {
Err(format_err!("Unable to parse SentPaymentEvent"))
}
} else if event_type_tag == &TypeTag::Struct(MintEvent::struct_tag()) {
} else if event_type_tag == &TypeTag::Struct(Box::new(MintEvent::struct_tag())) {
if let Ok(mint_event) = MintEvent::try_from_bytes(event_data) {
Ok(EventDataView::Mint {
amount: mint_event.amount(),
Expand All @@ -198,7 +198,7 @@ impl EventDataView {
} else {
Err(format_err!("Unable to parse MintEvent"))
}
} else if event_type_tag == &TypeTag::Struct(ProposalCreatedEvent::struct_tag()) {
} else if event_type_tag == &TypeTag::Struct(Box::new(ProposalCreatedEvent::struct_tag())) {
if let Ok(event) = ProposalCreatedEvent::try_from_bytes(event_data) {
Ok(EventDataView::ProposalCreated {
proposal_id: event.proposal_id,
Expand All @@ -207,7 +207,7 @@ impl EventDataView {
} else {
Err(format_err!("Unable to parse ProposalCreatedEvent"))
}
} else if event_type_tag == &TypeTag::Struct(VoteChangedEvent::struct_tag()) {
} else if event_type_tag == &TypeTag::Struct(Box::new(VoteChangedEvent::struct_tag())) {
if let Ok(event) = VoteChangedEvent::try_from_bytes(event_data) {
Ok(EventDataView::VoteChanged {
proposal_id: event.proposal_id,
Expand All @@ -219,15 +219,15 @@ impl EventDataView {
} else {
Err(format_err!("Unable to parse VoteChangedEvent"))
}
} else if event_type_tag == &TypeTag::Struct(AcceptTokenEvent::struct_tag()) {
} else if event_type_tag == &TypeTag::Struct(Box::new(AcceptTokenEvent::struct_tag())) {
if let Ok(event) = AcceptTokenEvent::try_from_bytes(event_data) {
Ok(EventDataView::AcceptToken {
token_code: event.token_code().to_string(),
})
} else {
Err(format_err!("Unable to parse VoteChangedEvent"))
}
} else if event_type_tag == &TypeTag::Struct(BlockRewardEvent::struct_tag()) {
} else if event_type_tag == &TypeTag::Struct(Box::new(BlockRewardEvent::struct_tag())) {
Ok(BlockRewardEvent::try_from_bytes(event_data)
.map_err(|_| format_err!("Unable to parse {}", BlockRewardEvent::struct_tag()))?
.into())
Expand Down
2 changes: 1 addition & 1 deletion commons/bcs_ext/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ version = "1.12.5"

[dependencies]
anyhow = "1.0.41"
bcs = "0.1.3"
bcs = "0.1.4"
serde = {version = "1.0.130"}
2 changes: 1 addition & 1 deletion commons/proptest-helpers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ version = "1.12.5"

[dependencies]
crossbeam = "0.7.3"
diem-proptest-helpers = { package = "diem-proptest-helpers", git = "https://github.com/starcoinorg/move", rev = "204da96abcb6eb82bc50fcbcd4331f6cc3d17439" }
diem-proptest-helpers = { package = "diem-proptest-helpers", git = "https://github.com/starcoinorg/move", rev = "8613078820ba81686071b224e64441b68d6dc6cf" }
proptest = "1.0.0"
proptest-derive = "0.3.0"
2 changes: 2 additions & 0 deletions config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ serde_json = { version = "1.0", features = ["arbitrary_precision"] }
starcoin-time-service = { path = "../commons/time-service" }
thiserror = "1.0"
toml = { version = "0.5.9", default-features = false }
gas-algebra-ext = { path = "../vm/gas-algebra-ext" }
starcoin-gas = { path = "../vm/starcoin-gas" }
14 changes: 5 additions & 9 deletions config/example/proxima/genesis_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -443,27 +443,23 @@
"memory_gas": 1
},
{
"instruction_gas": 4,
"memory_gas": 1
},
{
"instruction_gas": 4,
"instruction_gas": 10,
"memory_gas": 1
},
{
"instruction_gas": 4,
"instruction_gas": 8,
"memory_gas": 1
},
{
"instruction_gas": 4,
"instruction_gas": 40,
"memory_gas": 1
},
{
"instruction_gas": 4,
"instruction_gas": 20,
"memory_gas": 1
},
{
"instruction_gas": 4,
"instruction_gas": 73,
"memory_gas": 1
},
{
Expand Down
Loading

0 comments on commit 82bccb5

Please sign in to comment.