Skip to content

Commit

Permalink
Merge pull request #3871 from sisuresh/upgrade-test
Browse files Browse the repository at this point in the history
Add test case for soroban config setting upgrade with minimum settings

Reviewed-by: dmkozh
  • Loading branch information
latobarita authored Aug 8, 2023
2 parents 680c1c7 + d4ad454 commit 1a29f89
Show file tree
Hide file tree
Showing 9 changed files with 287 additions and 36 deletions.
20 changes: 10 additions & 10 deletions Cargo.lock

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

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ members = ["src/rust", "lib/tracy-client-sys"]
[patch.crates-io]
tracy-client-sys = { path = "lib/tracy-client-sys" }

# [patch."https://github.com/stellar/rs-soroban-env"]
# soroban-env-common = { path = "../rs-soroban-env/soroban-env-common" }
# soroban-env-host = { path = "../rs-soroban-env/soroban-env-host/" }
#[patch."https://github.com/stellar/rs-soroban-env"]
#soroban-env-common = { path = "../rs-soroban-env/soroban-env-common" }
#soroban-env-host = { path = "../rs-soroban-env/soroban-env-host/" }
#soroban-test-wasms = { path = "../rs-soroban-env/soroban-test-wasms/" }

# [patch."https://github.com/stellar/rs-stellar-xdr"]
# stellar-xdr = { path = "../rs-stellar-xdr/" }
Expand Down
7 changes: 2 additions & 5 deletions src/herder/Upgrades.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1532,8 +1532,7 @@ ConfigUpgradeSetFrame::isValidForApply() const
cfg.contractLedgerCost().ledgerMaxWriteBytes >=
MinimumSorobanNetworkConfig::LEDGER_MAX_WRITE_BYTES &&
cfg.contractLedgerCost().txMaxReadLedgerEntries >=
MinimumSorobanNetworkConfig::
LEDGER_MAX_READ_LEDGER_ENTRIES &&
MinimumSorobanNetworkConfig::TX_MAX_READ_LEDGER_ENTRIES &&
cfg.contractLedgerCost().txMaxReadBytes >=
MinimumSorobanNetworkConfig::TX_MAX_READ_BYTES &&
cfg.contractLedgerCost().txMaxWriteLedgerEntries >=
Expand Down Expand Up @@ -1561,9 +1560,7 @@ ConfigUpgradeSetFrame::isValidForApply() const
cfg.contractLedgerCost().txMaxWriteBytes;
break;
case ConfigSettingID::CONFIG_SETTING_CONTRACT_EVENTS_V0:
valid = cfg.contractEvents().txMaxContractEventsSizeBytes >=
MinimumSorobanNetworkConfig::
TX_MAX_CONTRACT_EVENTS_SIZE_BYTES &&
valid = cfg.contractEvents().txMaxContractEventsSizeBytes >= 0 &&
cfg.contractEvents().feeContractEvents1KB >= 0;
break;
case ConfigSettingID::CONFIG_SETTING_STATE_EXPIRATION:
Expand Down
5 changes: 1 addition & 4 deletions src/invariant/LedgerEntryIsValid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -718,10 +718,7 @@ LedgerEntryIsValid::checkIsValid(ConfigSettingEntry const& cfg,
}
break;
case ConfigSettingID::CONFIG_SETTING_CONTRACT_EVENTS_V0:
if (cfg.contractEvents().txMaxContractEventsSizeBytes <
MinimumSorobanNetworkConfig::
TX_MAX_CONTRACT_EVENTS_SIZE_BYTES ||
cfg.contractEvents().feeContractEvents1KB < 0)
if (cfg.contractEvents().feeContractEvents1KB < 0)
{
return "Invalid contractMetaData";
}
Expand Down
2 changes: 0 additions & 2 deletions src/ledger/NetworkConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ struct MinimumSorobanNetworkConfig
static constexpr uint32_t LEDGER_MAX_WRITE_LEDGER_ENTRIES = 2;
static constexpr uint32_t LEDGER_MAX_WRITE_BYTES = 5000;

static constexpr uint32_t TX_MAX_CONTRACT_EVENTS_SIZE_BYTES = 0;

static constexpr uint32_t TX_MAX_SIZE_BYTES = 10000;
static constexpr uint32_t LEDGER_MAX_TX_SIZE_BYTES = 10000;

Expand Down
6 changes: 3 additions & 3 deletions src/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ rustc-simple-version = "0.1.0"
version = "0.0.17"
git = "https://github.com/stellar/rs-soroban-env"
package = "soroban-env-host"
rev = "75c043970e9098952848c8dd97e532b86ce78a8f"
rev = "2069b9c10541126f7812c6f807006dfc8470ab3f"

# This copy of the soroban host is _optional_ and only enabled during protocol
# transitions. When transitioning from protocol N to N+1, the `curr` copy
Expand All @@ -52,11 +52,11 @@ optional = true
version = "0.0.17"
git = "https://github.com/stellar/rs-soroban-env"
package = "soroban-env-host"
rev = "14f485683048eb78314cb5f43fcc05d5086f4e99"
rev = "75c043970e9098952848c8dd97e532b86ce78a8f"

[dependencies.soroban-test-wasms]
git = "https://github.com/stellar/rs-soroban-env"
rev = "75c043970e9098952848c8dd97e532b86ce78a8f"
rev = "2069b9c10541126f7812c6f807006dfc8470ab3f"

[dependencies.cargo-lock]
git = "https://github.com/rustsec/rustsec"
Expand Down
8 changes: 4 additions & 4 deletions src/rust/src/host-dep-tree-curr.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
soroban-env-host 0.0.17 git+https://github.com/stellar/rs-soroban-env?rev=75c043970e9098952848c8dd97e532b86ce78a8f#75c043970e9098952848c8dd97e532b86ce78a8f
soroban-env-host 0.0.17 git+https://github.com/stellar/rs-soroban-env?rev=2069b9c10541126f7812c6f807006dfc8470ab3f#2069b9c10541126f7812c6f807006dfc8470ab3f
├── tracy-client 0.15.2 checksum:434ecabbda9f67eeea1eab44d52f4a20538afa3e2c2770f2efc161142b25b608
│ ├── tracy-client-sys 0.20.0 checksum:e8cf8aeb20e40d13be65a0b134f8d82d360e72b2793a11de8867d7fbc0f9d6f6
│ │ └── cc 1.0.79 checksum:50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f
Expand Down Expand Up @@ -86,13 +86,13 @@ soroban-env-host 0.0.17 git+https://github.com/stellar/rs-soroban-env?rev=75c043
│ ├── wasmi_arena 0.4.0 git+https://github.com/stellar/wasmi?rev=284c963ba080703061797e2a3cba0853edee0dd4#284c963ba080703061797e2a3cba0853edee0dd4
│ ├── spin 0.9.8 checksum:6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67
│ └── smallvec 1.10.0 checksum:a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0
├── soroban-native-sdk-macros 0.0.17 git+https://github.com/stellar/rs-soroban-env?rev=75c043970e9098952848c8dd97e532b86ce78a8f#75c043970e9098952848c8dd97e532b86ce78a8f
├── soroban-native-sdk-macros 0.0.17 git+https://github.com/stellar/rs-soroban-env?rev=2069b9c10541126f7812c6f807006dfc8470ab3f#2069b9c10541126f7812c6f807006dfc8470ab3f
│ ├── syn 2.0.18 checksum:32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e
│ ├── quote 1.0.28 checksum:1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488
│ ├── proc-macro2 1.0.60 checksum:dec2b086b7a862cf4de201096214fa870344cf922b2b30c167badb3af3195406
│ └── itertools 0.10.5 checksum:b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473
│ └── either 1.8.1 checksum:7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91
├── soroban-env-common 0.0.17 git+https://github.com/stellar/rs-soroban-env?rev=75c043970e9098952848c8dd97e532b86ce78a8f#75c043970e9098952848c8dd97e532b86ce78a8f
├── soroban-env-common 0.0.17 git+https://github.com/stellar/rs-soroban-env?rev=2069b9c10541126f7812c6f807006dfc8470ab3f#2069b9c10541126f7812c6f807006dfc8470ab3f
│ ├── stellar-xdr 0.0.17 git+https://github.com/stellar/rs-stellar-xdr?rev=d6e02584ac9f4046bf38eaf445ced0d4f33631fd#d6e02584ac9f4046bf38eaf445ced0d4f33631fd
│ │ ├── hex 0.4.3 checksum:7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70
│ │ ├── crate-git-revision 0.0.6 checksum:c521bf1f43d31ed2f73441775ed31935d77901cb3451e44b38a1c1612fcbaf98
Expand All @@ -109,7 +109,7 @@ soroban-env-host 0.0.17 git+https://github.com/stellar/rs-soroban-env?rev=75c043
│ │ └── base64 0.13.1 checksum:9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8
│ ├── static_assertions 1.1.0 checksum:a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f
│ ├── soroban-wasmi 0.30.0-soroban git+https://github.com/stellar/wasmi?rev=284c963ba080703061797e2a3cba0853edee0dd4#284c963ba080703061797e2a3cba0853edee0dd4
│ ├── soroban-env-macros 0.0.17 git+https://github.com/stellar/rs-soroban-env?rev=75c043970e9098952848c8dd97e532b86ce78a8f#75c043970e9098952848c8dd97e532b86ce78a8f
│ ├── soroban-env-macros 0.0.17 git+https://github.com/stellar/rs-soroban-env?rev=2069b9c10541126f7812c6f807006dfc8470ab3f#2069b9c10541126f7812c6f807006dfc8470ab3f
│ │ ├── thiserror 1.0.40 checksum:978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac
│ │ ├── syn 2.0.18 checksum:32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e
│ │ ├── stellar-xdr 0.0.17 git+https://github.com/stellar/rs-stellar-xdr?rev=d6e02584ac9f4046bf38eaf445ced0d4f33631fd#d6e02584ac9f4046bf38eaf445ced0d4f33631fd
Expand Down
7 changes: 7 additions & 0 deletions src/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ mod rust_bridge {
fn get_test_wasm_contract_data() -> Result<RustBuf>;
fn get_test_wasm_complex() -> Result<RustBuf>;
fn get_test_wasm_err() -> Result<RustBuf>;
fn get_write_bytes() -> Result<RustBuf>;

// Return the rustc version used to build this binary.
fn get_rustc_version() -> String;
Expand Down Expand Up @@ -307,6 +308,12 @@ pub(crate) fn get_test_wasm_err() -> Result<RustBuf, Box<dyn std::error::Error>>
})
}

pub(crate) fn get_write_bytes() -> Result<RustBuf, Box<dyn std::error::Error>> {
Ok(RustBuf {
data: soroban_test_wasms::WRITE_BYTES.iter().cloned().collect(),
})
}

use rust_bridge::CxxBuf;
use rust_bridge::CxxFeeConfiguration;
use rust_bridge::CxxLedgerEntryRentChange;
Expand Down
Loading

0 comments on commit 1a29f89

Please sign in to comment.