-
Notifications
You must be signed in to change notification settings - Fork 71
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
feat: add support for creating allocations via EVM contract #1970
feat: add support for creating allocations via EVM contract #1970
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly looks good with some changes required. Can we please paste invoked command and the test results in the PR? It would also be ideal to test batch request transfer as well. Please test it on the limit of 500.
cmd/boost/direct_deal.go
Outdated
@@ -93,6 +93,10 @@ var directDealAllocate = &cli.Command{ | |||
Usage: "automatic yes to prompts; assume 'yes' as answer to all prompts and run non-interactively", | |||
Aliases: []string{"y", "yes"}, | |||
}, | |||
&cli.StringFlag{ | |||
Name: "evm-client-contract", | |||
Usage: "address of EVM contract to spend DataCap from", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should clarify here that we are expecting F4 address and not Eth address.
cmd/boost/direct_deal.go
Outdated
return err | ||
var msgs []*types.Message | ||
var allocationsAddr address.Address | ||
evmContract := cctx.String("evm-client-contract") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest checking if the flag is set and if the value if empty then return an error.
cmd/boost/direct_deal.go
Outdated
@@ -287,7 +307,7 @@ var directDealAllocate = &cli.Command{ | |||
mcidStr = append(mcidStr, c.String()) | |||
} | |||
|
|||
log.Infow("submitted data cap allocation message[s]", mcidStr) | |||
log.Infow("submitted data cap allocation message[s]", "mcidStr", mcidStr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Infow("submitted data cap allocation message[s]", "mcidStr", mcidStr) | |
log.Infow("submitted data cap allocation message[s]", "CID", mcidStr) |
} | ||
|
||
// Decode return value (cbor -> evm ABI -> math/big Int -> filecoin big Int) | ||
var decodedReturn abi.CborBytes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check exit code success here before unmarshaling the result
Please fix the failing test as well |
Code updated as requested in review and bench test is fixed. Manual test results & invoke commands:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
See #1961 for detailed context.
Summary
This PR adds a new option to
boost allocate
command:--evm-client-contract
. When the option is provided, instead of calling transfer method on datacap actor directly, it invokes transfer method on the provided EVM contract. It's assumed that the contract is an instance of fidlabs Client.sol.Notable changes
As recommended by @LexLuthr , this adds
go-ethereum
dependency. This requires replacing go-crypto v0.0.1 with v0.1.0 to make linker happy.Tests
No unit tests were added, as new code relies heavily on API. No integration tests were added, as the feature depends on an external smart contract. If you think unit or integration tests should be added, please provide guidance on how to make this work.
It tested manually using the docker devnet with the following procedure:
boost allocate
with--evm-client-contract
option and verified that it failed'increaseAllowance(address,uint256)'
on the Client.sol contract to grant datacap allowance to boost addressboost allocate
again, verified that it succeededlotus filplus list-allocations
to verify that allocation was createdLet me know if detailed instruction for setting up a dev env with the contract is needed.
Known Issues
For me, on docker devnet, it sometimes fails with
03: f06 (method 3726118371) -- allocation expiration 195886 exceeds maximum 195885 (16)
. The expiration is always 1 higher than the maximum. This is unrelated to the contract change, as this is something I also experience onmain
branch version with normal allocations.