Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preliminary value overhaul change #3673

Merged
merged 1 commit into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion src/protocol-next/xdr
4 changes: 2 additions & 2 deletions src/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ rustc-simple-version = "0.1.0"
[dependencies.soroban-env-host]
version = "0.0.14"
git = "https://github.com/stellar/rs-soroban-env"
rev = "5695440da452837555d8f7f259cc33341fdf07b0"
rev = "a66f0815ba06a2f5328ac420950690fd1642f887"
features = ["vm"]

[dependencies.soroban-test-wasms]
git = "https://github.com/stellar/rs-soroban-env"
rev = "5695440da452837555d8f7f259cc33341fdf07b0"
rev = "a66f0815ba06a2f5328ac420950690fd1642f887"
4 changes: 2 additions & 2 deletions src/transactions/InvokeHostFunctionOpFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ struct HostFunctionMetrics
isCodeKey(LedgerKey const& lk)
{
return lk.type() == CONTRACT_DATA &&
lk.contractData().key.type() == SCValType::SCV_STATIC &&
lk.contractData().key.ic() == SCS_LEDGER_KEY_CONTRACT_CODE;
lk.contractData().key.type() ==
SCValType::SCV_LEDGER_KEY_CONTRACT_EXECUTABLE;
}

void
Expand Down
33 changes: 13 additions & 20 deletions src/transactions/test/InvokeHostFunctionTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,19 @@ template <typename T>
SCVal
makeBinary(T begin, T end)
{
SCVal val(SCValType::SCV_OBJECT);
val.obj().activate().type(SCO_BYTES);
val.obj()->bin().assign(begin, end);
SCVal val(SCValType::SCV_BYTES);
val.bytes().assign(begin, end);
return val;
}

template <typename T>
SCVal
makeWasmRefScContractCode(T const& hash)
{
SCVal val(SCValType::SCV_OBJECT);
val.obj().activate().type(stellar::SCO_CONTRACT_CODE);
val.obj()->contractCode().type(stellar::SCCONTRACT_CODE_WASM_REF);
std::copy(hash.begin(), hash.end(),
val.obj()->contractCode().wasm_id().begin());
SCVal val(SCValType::SCV_CONTRACT_EXECUTABLE);
val.exec().type(SCContractExecutableType::SCCONTRACT_EXECUTABLE_WASM_REF);

std::copy(hash.begin(), hash.end(), val.exec().wasm_id().begin());
return val;
}

Expand Down Expand Up @@ -138,12 +136,11 @@ deployContractWithSourceAccount(Application& app, RustBuf const& contractWasm,
createContractArgs.contractID.type(CONTRACT_ID_FROM_SOURCE_ACCOUNT);
createContractArgs.contractID.salt() = salt;

createContractArgs.source.type(SCCONTRACT_CODE_WASM_REF);
createContractArgs.source.type(SCCONTRACT_EXECUTABLE_WASM_REF);
createContractArgs.source.wasm_id() =
contractCodeLedgerKey.contractCode().hash;

SCVal scContractSourceRefKey(SCValType::SCV_STATIC);
scContractSourceRefKey.ic() = SCStatic::SCS_LEDGER_KEY_CONTRACT_CODE;
SCVal scContractSourceRefKey(SCValType::SCV_LEDGER_KEY_CONTRACT_EXECUTABLE);

LedgerKey contractSourceRefLedgerKey;
contractSourceRefLedgerKey.type(CONTRACT_DATA);
Expand Down Expand Up @@ -200,7 +197,7 @@ TEST_CASE("invoke host function", "[tx][contract]")
ltx.commit();
SCVal resultVal;
resultVal.type(stellar::SCV_STATUS);
resultVal.status().type(SCStatusType::SST_UNKNOWN_ERROR);
resultVal.error().type(SCStatusType::SST_UNKNOWN_ERROR);
if (tx->getResult().result.code() == txSUCCESS &&
!tx->getResult().result.results().empty())
{
Expand Down Expand Up @@ -421,13 +418,9 @@ TEST_CASE("complex contract with preflight", "[tx][contract]")
REQUIRE(txm.getXDR().v3().events.size() == 1);
REQUIRE(txm.getXDR().v3().events.at(0).events.at(0).type ==
ContractEventType::CONTRACT);
REQUIRE(txm.getXDR()
.v3()
.events.at(0)
.events.at(0)
.body.v0()
.data.obj()
->type() == SCO_BYTES);
REQUIRE(
txm.getXDR().v3().events.at(0).events.at(0).body.v0().data.type() ==
SCV_BYTES);
}
SECTION("multiple ops")
{
Expand All @@ -446,7 +439,7 @@ TEST_CASE("complex contract with preflight", "[tx][contract]")
for (auto const& e : txm.getXDR().v3().events.at(i).events)
{
REQUIRE(e.type == ContractEventType::CONTRACT);
REQUIRE(e.body.v0().data.obj()->type() == SCO_BYTES);
REQUIRE(e.body.v0().data.type() == SCV_BYTES);
}
}
}
Expand Down