forked from move-language/move-sui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Description Organize better several limits... ## Test Plan How did you test the new or updated feature? --- If your changes are not user-facing and do not break anything, you can skip the following section. Otherwise, please briefly describe what has changed under the Release Notes section. ### Type of Change (Check all that apply) - [ ] protocol change - [ ] user-visible impact - [ ] breaking change for a client SDKs - [ ] breaking change for FNs (FN binary must upgrade) - [ ] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [ ] necessitate either a data wipe or data migration ### Release notes --------- Co-authored-by: Ashok Menon <[email protected]> Co-authored-by: Stefan Stanciulescu <[email protected]>
- Loading branch information
1 parent
662294d
commit b80a2c9
Showing
161 changed files
with
22,881 additions
and
591 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// Copyright (c) The Move Contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
|
||
use crate::file_format_common::VERSION_MAX; | ||
|
||
/// Configuration for the binary format related to table size. | ||
/// Maps to all tables in the binary format. | ||
#[derive(Clone, Debug)] | ||
pub struct TableConfig { | ||
pub module_handles: u16, | ||
pub struct_handles: u16, | ||
pub function_handles: u16, | ||
pub function_instantiations: u16, | ||
pub signatures: u16, | ||
pub constant_pool: u16, | ||
pub identifiers: u16, | ||
pub address_identifiers: u16, | ||
pub struct_defs: u16, | ||
pub struct_def_instantiations: u16, | ||
pub function_defs: u16, | ||
pub field_handles: u16, | ||
pub field_instantiations: u16, | ||
pub friend_decls: u16, | ||
} | ||
|
||
impl TableConfig { | ||
// The deserializer and other parts of the system already have limits in place, | ||
// this is the "legacy" configuration that is effectively the "no limits" setup. | ||
// This table is a noop with `u16::MAX`. | ||
pub fn legacy() -> Self { | ||
TableConfig { | ||
module_handles: u16::MAX, | ||
struct_handles: u16::MAX, | ||
function_handles: u16::MAX, | ||
function_instantiations: u16::MAX, | ||
signatures: u16::MAX, | ||
constant_pool: u16::MAX, | ||
identifiers: u16::MAX, | ||
address_identifiers: u16::MAX, | ||
struct_defs: u16::MAX, | ||
struct_def_instantiations: u16::MAX, | ||
function_defs: u16::MAX, | ||
field_handles: u16::MAX, | ||
field_instantiations: u16::MAX, | ||
friend_decls: u16::MAX, | ||
} | ||
} | ||
} | ||
|
||
/// Configuration information for deserializing a binary. | ||
/// Controls multiple aspects of the deserialization process. | ||
#[derive(Clone, Debug)] | ||
pub struct BinaryConfig { | ||
pub max_binary_format_version: u32, | ||
pub check_no_extraneous_bytes: bool, | ||
pub table_config: TableConfig, | ||
} | ||
|
||
impl BinaryConfig { | ||
pub fn new( | ||
max_binary_format_version: u32, | ||
check_no_extraneous_bytes: bool, | ||
table_config: TableConfig, | ||
) -> Self { | ||
Self { | ||
max_binary_format_version, | ||
check_no_extraneous_bytes, | ||
table_config, | ||
} | ||
} | ||
|
||
// We want to make this disappear from the public API in favor of a "true" config | ||
pub fn legacy(max_binary_format_version: u32, check_no_extraneous_bytes: bool) -> Self { | ||
Self { | ||
max_binary_format_version, | ||
check_no_extraneous_bytes, | ||
table_config: TableConfig::legacy(), | ||
} | ||
} | ||
|
||
/// Run always with the max version but with controllable "extraneous bytes check" | ||
pub fn with_extraneous_bytes_check(check_no_extraneous_bytes: bool) -> Self { | ||
Self { | ||
max_binary_format_version: VERSION_MAX, | ||
check_no_extraneous_bytes, | ||
table_config: TableConfig::legacy(), | ||
} | ||
} | ||
|
||
/// VERSION_MAX and check_no_extraneous_bytes = true | ||
/// common "standard/default" in code base now | ||
pub fn standard() -> Self { | ||
Self { | ||
max_binary_format_version: VERSION_MAX, | ||
check_no_extraneous_bytes: true, | ||
table_config: TableConfig::legacy(), | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.