Giter VIP home page Giter VIP logo

Comments (8)

fleupold avatar fleupold commented on August 14, 2024 3

One cool hack that was presented at EthLondon last weekend is Lurch, which allows evaluating arbitrary bytecode given some calldata.

We could implement the predicate as bytecode and pass it in to the MockContract. Then when the mock contract matches the method-name it could evaluate the bytecode given the calldata in lurch and if it returns true execute the given expectation.

I'm not sure how practical it will be to compile predicates into bytecode and if it could be done nicely in JS.

from mock-contract.

fvictorio avatar fvictorio commented on August 14, 2024 2

My two cents in case anyone cares: I feel like solidity needs some extra features before something like this can be implemented, unless you do something like deploying ad-hoc contracts, like @fleupold suggested.

More specifically, I think for doing this you should need to store information about how to decode a given calldata, but AFAIK you can't store a tuple of types, which is the type of the second parameter of abi.decode:

abi.decode(someBytes, (uint, string))

I mean, someone calling a givenPredicateCalldata* method should also provide info about how to decode this. If this is possible, I think #14 becomes much easier too.

from mock-contract.

josojo avatar josojo commented on August 14, 2024 1

@bh2smith Yeah, they are exercises, which will be posted in gitcoin. It is not specifically for trufflecon

from mock-contract.

fleupold avatar fleupold commented on August 14, 2024

This one is a little more tricky than the previous one. I was thinking that we could actually allow people to write the predicate as a boolean expression in solidity (with a somehow defined naming scheme for variables).

E.g. GREATER_THAN(10) could be implemented as

contract.method.givenConditionReturn("arg0 > 10", true)

which under the hood (in js) could be implemented by deploying a new contract instance (using something like this) which inherits MockContract, and implements the method something like:

function method(arg0, arg1, ...) returns (bool) {
  if ($condition) {
    return $returnValue
  } else {
    super.method(arg0, arg1, ...)
  }
}

Of course there is still some more fine technical detail which has to be ironed out, which is why this task is definitely more involved than #14

But I'm also happy leaving it open like this to see if someone comes up with a better idea.

from mock-contract.

bh2smith avatar bh2smith commented on August 14, 2024

Don't forget to update this!

The MockContract allows for all of that without having to write a separate test contract each time.

with

The MockContract facilitates these features without requiring any separate test contracts.

from mock-contract.

bh2smith avatar bh2smith commented on August 14, 2024

Are these exercises to be given out for prizes at the trufflecon?

from mock-contract.

gitcoinbot avatar gitcoinbot commented on August 14, 2024

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


This issue now has a funding of 0.75 ETH (159.1 USD @ $212.14/ETH) attached to it as part of the Gnosis fund.

from mock-contract.

gitcoinbot avatar gitcoinbot commented on August 14, 2024

Issue Status: 1. Open 2. Cancelled


The funding of 0.75 ETH (100.64 USD @ $134.18/ETH) attached to this issue has been cancelled by the bounty submitter

from mock-contract.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.