Skip to content

Commit

Permalink
Merge pull request #3786 from dmkozh/auth_xdr
Browse files Browse the repository at this point in the history
Bump Soroban env & XDR.

Reviewed-by: sisuresh
  • Loading branch information
latobarita authored Jun 20, 2023
2 parents f7394f1 + a5fced5 commit 9c0e0c8
Show file tree
Hide file tree
Showing 26 changed files with 1,238 additions and 894 deletions.
595 changes: 461 additions & 134 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions src/bucket/Bucket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,8 +719,7 @@ refersToSameEntry(T const& lhs, T const& rhs)
{
if (lhs.type() == CONTRACT_DATA)
{
return lhs.contractData().contractID ==
rhs.contractData().contractID &&
return lhs.contractData().contract == rhs.contractData().contract &&
lhs.contractData().key == rhs.contractData().key;
}
else if (lhs.type() == CONTRACT_CODE)
Expand Down
4 changes: 2 additions & 2 deletions src/bucket/LedgerCmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ struct LedgerEntryIdCmp
#ifdef ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION
case CONTRACT_DATA:
{
return lexCompare(a.contractData().contractID,
b.contractData().contractID, a.contractData().key,
return lexCompare(a.contractData().contract,
b.contractData().contract, a.contractData().key,
b.contractData().key, a.contractData().type,
b.contractData().type, getLeType(a),
getLeType(b));
Expand Down
7 changes: 4 additions & 3 deletions src/bucket/test/BucketIndexTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,10 @@ class BucketIndexTest
return le;
};

std::vector<LedgerEntry> entries = {generateEntry(TEMPORARY),
generateEntry(MERGEABLE),
generateEntry(EXCLUSIVE)};
std::vector<LedgerEntry> entries = {
generateEntry(ContractDataType::TEMPORARY),
generateEntry(ContractDataType::PERSISTENT),
};
for (auto const& e : entries)
{
auto k = LedgerEntryKey(e);
Expand Down
3 changes: 2 additions & 1 deletion src/herder/Upgrades.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,8 @@ ConfigUpgradeSetFrame::getLedgerKey(ConfigUpgradeSetKey const& upgradeKey)

LedgerKey lk;
lk.type(CONTRACT_DATA);
lk.contractData().contractID = upgradeKey.contractID;
lk.contractData().contract.type(SC_ADDRESS_TYPE_CONTRACT);
lk.contractData().contract.contractId() = upgradeKey.contractID;
lk.contractData().key = v;
return lk;
}
Expand Down
7 changes: 5 additions & 2 deletions src/herder/test/UpgradesTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ makeConfigUpgradeSet(AbstractLedgerTxn& ltx, ConfigUpgradeSet configUpgradeSet)
LedgerEntry le;
le.data.type(CONTRACT_DATA);
le.data.contractData().body.leType(DATA_ENTRY);
le.data.contractData().contractID = contractID;
le.data.contractData().contract.type(SC_ADDRESS_TYPE_CONTRACT);
le.data.contractData().contract.contractId() = contractID;
le.data.contractData().key = key;
le.data.contractData().body.data().val = val;

Expand Down Expand Up @@ -720,7 +721,9 @@ TEST_CASE("config upgrade validation", "[upgrades]")
LedgerEntry le;
le.data.type(CONTRACT_DATA);
le.data.contractData().body.leType(DATA_ENTRY);
le.data.contractData().contractID = contractID;
le.data.contractData().contract.type(
SC_ADDRESS_TYPE_CONTRACT);
le.data.contractData().contract.contractId() = contractID;
le.data.contractData().key = key;
le.data.contractData().body.data().val = val;

Expand Down
3 changes: 2 additions & 1 deletion src/invariant/ConservationOfLumens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ calculateDeltaBalance(LedgerEntry const* current, LedgerEntry const* previous)
{
auto const& contractData = current ? current->data.contractData()
: previous->data.contractData();
if (contractData.contractID != lumenContractID ||
if (contractData.contract.type() != SC_ADDRESS_TYPE_CONTRACT ||
contractData.contract.contractId() != lumenContractID ||
contractData.key.type() != SCV_VEC || !contractData.key.vec() ||
contractData.key.vec().size() == 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ class ApplyBucketsWorkModifyEntry : public ApplyBucketsWork
entry.data.contractData() =
LedgerTestUtils::generateValidContractDataEntry(5);

entry.data.contractData().contractID = cd.contractID;
entry.data.contractData().contract = cd.contract;
entry.data.contractData().key = cd.key;
}

Expand Down
15 changes: 13 additions & 2 deletions src/ledger/LedgerHashUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,19 @@ template <> class hash<stellar::LedgerKey>
break;
#ifdef ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION
case stellar::CONTRACT_DATA:
stellar::hashMix(res, std::hash<stellar::uint256>()(
lk.contractData().contractID));
switch (lk.contractData().contract.type())
{
case stellar::SC_ADDRESS_TYPE_ACCOUNT:
stellar::hashMix(
res, std::hash<stellar::uint256>()(
lk.contractData().contract.accountId().ed25519()));
break;
case stellar::SC_ADDRESS_TYPE_CONTRACT:
stellar::hashMix(res,
std::hash<stellar::uint256>()(
lk.contractData().contract.contractId()));
break;
}
stellar::hashMix(
res, stellar::shortHash::xdrComputeHash(lk.contractData().key));
break;
Expand Down
8 changes: 4 additions & 4 deletions src/ledger/LedgerTxnContractDataSQL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ LedgerTxnRoot::Impl::loadContractData(LedgerKey const& k) const
return nullptr;
}

auto contractID = toOpaqueBase64(k.contractData().contractID);
auto contractID = toOpaqueBase64(k.contractData().contract);
auto key = toOpaqueBase64(k.contractData().key);
int32_t type = k.contractData().type;
std::string contractDataEntryStr;
Expand Down Expand Up @@ -116,7 +116,7 @@ class BulkLoadContractDataOperation
}

mContractIDs.emplace_back(
toOpaqueBase64(k.contractData().contractID));
toOpaqueBase64(k.contractData().contract));
mKeys.emplace_back(toOpaqueBase64(k.contractData().key));
mTypes.emplace_back(k.contractData().type);
}
Expand Down Expand Up @@ -244,7 +244,7 @@ class BulkDeleteContractDataOperation
}

mContractIDs.emplace_back(
toOpaqueBase64(e.key().ledgerKey().contractData().contractID));
toOpaqueBase64(e.key().ledgerKey().contractData().contract));
mKeys.emplace_back(
toOpaqueBase64(e.key().ledgerKey().contractData().key));
mTypes.emplace_back(e.key().ledgerKey().contractData().type);
Expand Down Expand Up @@ -338,7 +338,7 @@ class BulkUpsertContractDataOperation
throwIfNotContractData(entry.data.type());

mContractIDs.emplace_back(
toOpaqueBase64(entry.data.contractData().contractID));
toOpaqueBase64(entry.data.contractData().contract));
mKeys.emplace_back(toOpaqueBase64(entry.data.contractData().key));
mTypes.emplace_back(entry.data.contractData().type);
mContractDataEntries.emplace_back(toOpaqueBase64(entry));
Expand Down
4 changes: 2 additions & 2 deletions src/ledger/test/LedgerTxnTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ generateLedgerEntryWithSameKey(LedgerEntry const& leBase)
case CONTRACT_DATA:
le.data.contractData() =
LedgerTestUtils::generateValidContractDataEntry();
le.data.contractData().contractID =
leBase.data.contractData().contractID;
le.data.contractData().contract =
leBase.data.contractData().contract;
le.data.contractData().key = leBase.data.contractData().key;
le.data.contractData().type = leBase.data.contractData().type;
break;
Expand Down
2 changes: 1 addition & 1 deletion src/protocol-next/xdr
6 changes: 3 additions & 3 deletions src/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ rustc-simple-version = "0.1.0"
version = "0.0.16"
git = "https://github.com/stellar/rs-soroban-env"
package = "soroban-env-host"
rev = "d83c7e90dc8abcf7f141fdc13b0f85f8f08f8b0c"
rev = "e6e02dc4b5cf946028e51603883bd81ca38ce519"

# 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 @@ -51,11 +51,11 @@ optional = true
version = "0.0.16"
git = "https://github.com/stellar/rs-soroban-env"
package = "soroban-env-host"
rev = "a531f7213604f8776547b257f402de6247ec5a6f"
rev = "16bdf376278e1f6322beebad0a11e3c484b1eef9"

[dependencies.soroban-test-wasms]
git = "https://github.com/stellar/rs-soroban-env"
rev = "d83c7e90dc8abcf7f141fdc13b0f85f8f08f8b0c"
rev = "e6e02dc4b5cf946028e51603883bd81ca38ce519"

[dependencies.cargo-lock]
git = "https://github.com/rustsec/rustsec"
Expand Down
4 changes: 2 additions & 2 deletions src/rust/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl From<CxxLedgerInfo> for LedgerInfo {
network_id: c.network_id.try_into().unwrap(),
base_reserve: c.base_reserve,
min_temp_entry_expiration: c.min_temp_entry_expiration,
min_restorable_entry_expiration: c.min_restorable_entry_expiration,
min_persistent_entry_expiration: c.min_persistent_entry_expiration,
}
}
}
Expand Down Expand Up @@ -211,7 +211,7 @@ fn ledger_entry_to_ledger_key(le: &LedgerEntry) -> Result<LedgerKey, CoreHostErr
asset: tl.asset.clone(),
})),
LedgerEntryData::ContractData(cd) => Ok(LedgerKey::ContractData(LedgerKeyContractData {
contract_id: cd.contract_id.clone(),
contract: cd.contract.clone(),
key: cd.key.clone(),
type_: cd.type_.clone(),
le_type: match &cd.body {
Expand Down
Loading

0 comments on commit 9c0e0c8

Please sign in to comment.