PatrickAlphaC / hardhat-smartcontract-lottery-fcc

MIT License
117 stars 182 forks source link

Update Raffle.sol #146

Closed solvman closed 1 year ago

solvman commented 1 year ago

Passing "" (an empty string) to checkUpkeep(""), makes the function throw out "Error: invalid arrayify value (argument="value", value="", code=INVALID_ARGUMENT, version=bytes/5.5.0)"

PatrickAlphaC commented 1 year ago

What are you doing to get that error?

Our tests are still passing as they currently are written: https://github.com/PatrickAlphaC/hardhat-smartcontract-lottery-fcc/blob/d7a615595007d4b666486f1d06d9733a8124f334/test/unit/Raffle.test.js#L59

solvman commented 1 year ago

Calling performUpkeep() on a contract deployed on goerli. Execution times out and then transaction reverts with an error. Weirdly enough local tests pass, but test to goerli fails. To replicate, deploy Raffle.sol to goerli and manually try calling performUpkeep() passing 0x00 to it. performUpkeep() tries to call checkUpkeep(“”), and it fails since EVM does not recognize “” as a bytes argument. Apparently, “” (empty string) in solidity is not equal to 0x00 (1 byte of zeros). Even though, we don’t need that argument, we still must have it. Solidity doesn’t seem to support optional arguments.

solvman commented 1 year ago

Technically, calling checkUpkeep(“”) within performUpkeep() function is equal to checkUpkeep() with no arguments, which fails. Why it executes in hardhat EVM, I have no clue, but it definitely fails in goerli, as it should. Since checkUpkeep requires single argument of type bytes, and it receives nothing.

solvman commented 1 year ago

If you pass it “0”, it will be getting 0x30 as a single byte argument. You can really pass it whatever, but not an empty string of “”, which is treated as nothing in that particular case.

PatrickAlphaC commented 1 year ago

Ah, calling a transaction on Etherscan vs Hardhat vs command line all have a different idea of what a "null" bytes object is.

A little confusing, but what we have currently is correct. Passing a zero string is actually different than a blank one odd enough!

solvman commented 1 year ago

No, it doesn't work. You have empty string hardcoded in your contract.

MrUchie commented 1 year ago

@solvman What'd you end up doing?

solvman commented 1 year ago

@MrUchie Replacing that empty string "" with the "0". It doesn't really matter what you put in that string as long as it is not empty. I guess new compiler doesn't like it, but @PatrickAlphaC still insists that it should work. It didn't work for me for sure. I spent a day trying to figure it out. 😃