Skip to content

Commit

Permalink
More consistently support overriding Execution :D.
Browse files Browse the repository at this point in the history
  • Loading branch information
saurik committed Jul 30, 2024
1 parent a06c3d5 commit f3314e5
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 88 deletions.
133 changes: 67 additions & 66 deletions eth-sender/source/main.cpp

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions lib-protocol/source/chain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,20 +380,20 @@ Brick<32> Name(const std::string &name) {
return HashK(Tie(Name(name.substr(period + 1)), HashK(name.substr(0, period))));
} }

task<S<Chain>> Chain::New(Endpoint endpoint, Flags flags, uint256_t chain) {
co_return Break<Chain>(std::move(endpoint), std::move(flags), std::move(chain));
task<S<Chain>> Chain::New(Endpoint endpoint, uint256_t chain) {
co_return Break<Chain>(std::move(endpoint), std::move(chain));
}

task<S<Chain>> Chain::New(Endpoint endpoint, Flags flags) {
task<S<Chain>> Chain::New(Endpoint endpoint) {
auto chain(
endpoint.operator const Locator &().origin_.host_ == "cloudflare-eth.com" ? 1 :
endpoint.operator const Locator &().origin_.host_ == "rpc.mainnet.near.org" ? 1313161554 :
uint256_t((co_await endpoint("eth_chainId", {})).asString()));
co_return co_await New(std::move(endpoint), std::move(flags), std::move(chain));
co_return co_await New(std::move(endpoint), std::move(chain));
}

task<uint256_t> Chain::Bid() const {
co_return flags_.bid_ ? *flags_.bid_ : uint256_t((co_await operator()("eth_gasPrice", {})).asString());
co_return uint256_t((co_await operator()("eth_gasPrice", {})).asString());
}

task<uint64_t> Chain::Height() const {
Expand Down
13 changes: 3 additions & 10 deletions lib-protocol/source/chain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,6 @@ struct Account final {
Account(const Json::Value &value, const Block &block);
};

struct Flags {
bool verbose_ = false;
std::optional<uint256_t> bid_;
};

struct Entry {
uint64_t block_;
Bytes data_;
Expand All @@ -130,7 +125,6 @@ class Chain :
typedef uint256_t type;
};

const Flags flags_;
const uint256_t chain_;

bool Insecure() const {
Expand Down Expand Up @@ -163,19 +157,18 @@ class Chain :
}

public:
Chain(Endpoint endpoint, Flags flags, uint256_t chain) :
Chain(Endpoint endpoint, uint256_t chain) :
Valve(typeid(*this).name()),
Endpoint(std::move(endpoint)),
flags_(std::move(flags)),
chain_(std::move(chain))
{
}

Chain(const Chain &rhs) = delete;
Chain(Chain &&rhs) = delete;

static task<S<Chain>> New(Endpoint endpoint, Flags flags, uint256_t chain);
static task<S<Chain>> New(Endpoint endpoint, Flags flags);
static task<S<Chain>> New(Endpoint endpoint, uint256_t chain);
static task<S<Chain>> New(Endpoint endpoint);

task<void> Shut() noexcept override {
co_await Valve::Shut();
Expand Down
2 changes: 1 addition & 1 deletion lib-protocol/source/ethereum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
namespace orc {

task<S<Ethereum>> Ethereum::New(const S<Base> &base, const Locator &locator) {
co_return Make<Ethereum>(co_await Chain::New({locator, base}, {}, 1));
co_return Make<Ethereum>(co_await Chain::New({locator, base}, 1));
}

task<S<Ethereum>> Ethereum::New(const S<Base> &base, const std::vector<std::string> &chains) {
Expand Down
2 changes: 1 addition & 1 deletion lib-protocol/source/market.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ task<Market> Market::New(unsigned milliseconds, S<Chain> chain, Currency currenc
}

task<Market> Market::New(unsigned milliseconds, const S<Ethereum> &ethereum, const S<Base> &base, uint256_t chain, std::string currency, Locator locator) {
auto [chain$, currency$] = *co_await Parallel(Chain::New({std::move(locator), base}, {}, chain), Currency::New(milliseconds, ethereum, base, std::move(currency)));
auto [chain$, currency$] = *co_await Parallel(Chain::New({std::move(locator), base}, chain), Currency::New(milliseconds, ethereum, base, std::move(currency)));
co_return co_await New(milliseconds, std::move(chain$), std::move(currency$));
}

Expand Down
2 changes: 1 addition & 1 deletion tst-ethereum/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ task<int> Main(int argc, const char *const argv[]) {
}

const S<Base> base(Break<Local>());
const auto chain(co_await Chain::New({args["rpc"].as<std::string>(), base}, {}));
const auto chain(co_await Chain::New({args["rpc"].as<std::string>(), base}));

std::vector<UnlockedExecutor> accounts;
for (const auto &account : co_await (*chain)("personal_listAccounts", {})) {
Expand Down
2 changes: 1 addition & 1 deletion tst-explore/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ int Main(int argc, const char *const argv[]) {

const S<Base> base(Break<Local>());
const std::string rpc(args["rpc"].as<std::string>());
const auto chain(Wait(Chain::New({rpc, base}, {})));
const auto chain(Wait(Chain::New({rpc, base})));

const auto gauge(Make<Gauge>(60*1000, base));

Expand Down
4 changes: 2 additions & 2 deletions tst-ticket/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ task<void> Decode0(const Brick<32> &hash) {
const Address contract("0xb02396f06cc894834b7934ecf8c8e5ab5c1d12f1");

const S<Base> base(Break<Local>());
const auto chain(co_await Chain::New(Endpoint({{"https", "cloudflare-eth.com", "443"}, "/"}, base), {}));
const auto chain(co_await Chain::New(Endpoint({{"https", "cloudflare-eth.com", "443"}, "/"}, base)));

const auto input(co_await Search(chain, contract, hash));

Expand Down Expand Up @@ -124,7 +124,7 @@ task<void> Decode1(const Brick<32> &hash) {
const Address contract("0x6dB8381b2B41b74E17F5D4eB82E8d5b04ddA0a82");

const S<Base> base(Break<Local>());
const auto chain(co_await Chain::New(Endpoint({{"https", "rpc.xdaichain.com", "443"}, "/"}, base), {}));
const auto chain(co_await Chain::New(Endpoint({{"https", "rpc.xdaichain.com", "443"}, "/"}, base)));

const auto input(co_await Search(chain, contract, hash));

Expand Down
2 changes: 1 addition & 1 deletion vpn-shared/source/capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ task<void> Single(BufferSunk &sunk, Heap &heap, const S<Network> &network, const
const auto secret(orc_value(return, Bless<Secret>(heap.eval<std::string>(hops + ".secret")), "parsing .secret"));
const Address funder(heap.eval<std::string>(hops + ".funder"));
const std::string curator(heap.eval<std::string>(hops + ".curator"));
auto chain(co_await Chain::New({locator, base}, {}, uint256_t(heap.eval<double>(hops + ".chainid", 1))));
auto chain(co_await Chain::New({locator, base}, uint256_t(heap.eval<double>(hops + ".chainid", 1))));
const auto provider(co_await network->Select(curator, heap.eval<std::string>(hops + ".provider", "0x0000000000000000000000000000000000000000")));
auto &client(co_await Client0::Wire(sunk, oracle, oxt, lottery, secret, funder));
co_await client.Open(provider, base);
Expand Down

0 comments on commit f3314e5

Please sign in to comment.