feat: change TablelandDeployments to use registry impl, not interface#448
Conversation
|
@sanderpick wanted to put this on your radar. i have to fix the tests, but before doing so, i wanted to see if this seemed like the right approach and/or worthwhile doing. TL;DR—the existing |
| @@ -1,23 +1,23 @@ | |||
| export interface TablelandNetworkConfig { | |||
There was a problem hiding this comment.
adjusted this interface so it can be reused below—i don't think this should affect anything downstream but calling it out, in case i should create a separate interface for block polling times.
| // See validator for config for more details; these times consider the `NewBlockPollFreq` & `MinBlockDepth` values | ||
| // Mainnets: https://github.com/tablelandnetwork/go-tableland/blob/main/docker/deployed/mainnet/api/config.json | ||
| // Testnets: https://github.com/tablelandnetwork/go-tableland/blob/main/docker/deployed/testnet/api/config.json | ||
| export const blockPollingTimes: TablelandNetworkConfig = { |
There was a problem hiding this comment.
@sanderpick for the pollingController PR, i've added block times to networks.ts so that the SDK can use them.
i pulled these values from the go-tableland repo. e.g., if a chain has NewBlockPollFreq of 10s and MinBlockDepth of 1, the value used below would be 20_000. or for OP and Arbitrum, we have 5s polling and zero block depth, so i'm using 5_000 as the value.
but, now that i think about it...in reality, the polling frequencies from go-tableland aren't actually the block times, so i guess these values could be misleading. e.g., FIL is 30 second blocks with 5 block depth. instead, maybe the polling periods below might want to be:
b * (d + 1) + b
where b is block time and d is depth. we need d+1 to consider the block the tx is mined in, and the addition of b at the end is a margin of safety. thus:
- FIL would have a value of
210_000(30*6+30) - ethereum would be
40_000(13.5*2+13.5) - matic would be
15_000(5*2+5) - all other L2s would be
10_000(5*1+5) - keep local as
5_000
anyways, i figure the usage with the polling controller would be something like this—and i'm not sold on the name blockPollingTimes fwiw:
import { helpers } from "@tableland/sdk";
// This import would be done under the hood within the SDK so that chains have default times, but shown here an as example
import { blockPollingTimes } from "@tableland/evm";
// For Filecoin testnet
const controller = helpers.createPollingController(blockPollingTimes["filecoin-calibration"], 1500); // polling timeout and intervalThere was a problem hiding this comment.
note: i ended up adjusting things with the logic defined above.
There was a problem hiding this comment.
Making sure I understand here. These values are the maximum amount of time a client should poll the validator for a table txn receipt?
If so, what about the name validatorPollingTimeouts?
There was a problem hiding this comment.
@joewagner correct, i like that better! updated.
There was a problem hiding this comment.
in the past I've used 10m timeout for filecoin. not sure where that came from exactly, but I think it was the "finality" that we are considering in the validator. maybe i was overestimating.
anyway, this looks good to me!
There was a problem hiding this comment.
(i'll keep an eye on if anyone mentions FIL issues in the future wrt the SDK abort signal fix...at least for filecoin calibration, it was working w/ these timeouts. can always increase as needed.)
Summary
Changes the
TablelandDeploymentscontract to return the registry implementation instead of its interface, allowing for more methods to be called (e.g.,safeTransferFrom). Also, agetBaseURImethod was added so that a contract can fetch the Tableland Gateway URI directly from theTablelandDeploymentslibrary. Closes EVM-51.Details
The core change uses the following imports & interface:
Then, when the
get()method is called, instead of returningITablelandTablesat a deployed registry address, the returned value isTablelandTablesImpl. This allows for the methods fromIERC721AUpgradeableto be called.How it was tested
TestTablelandDeployments.solcontract, which makes calls to theTablelandDeployments.sollibrary and executes subsequent methods likecreate,mutate,setController, andsafeTransferFrom.getInterface(), which returns the originalget()method'sITablelandTablesinterface. If you run thenpm run test:gasscript, you'll see the following differences:create, which makes use of theTablelandTablesImpl, uses 90401 gas.createWithInterface, which makes use of theITablelandTables, uses 90423 gas. (interestingly, this uses more gas.)mutate, which makes use of theTablelandTablesImpl, uses 52855 gas.mutateWithInterface, which makes use of theITablelandTables, uses 52789 gas.Checklist: