Skip to content

Add fields for syncedBlock and leaves in EVMChainStorage class#106

Closed
nepoche wants to merge 6 commits into
masterfrom
add-leaves-EvmStorage
Closed

Add fields for syncedBlock and leaves in EVMChainStorage class#106
nepoche wants to merge 6 commits into
masterfrom
add-leaves-EvmStorage

Conversation

@nepoche
Copy link
Copy Markdown
Contributor

@nepoche nepoche commented Jun 22, 2021

I'm trying to determine:

  1. Where should we store the dynamic data of syncedBlock and leaves in the localStorage?
  • I have added it to EVMChainStorage in this PR.
  1. Where should we update the data for syncedBlock and leaves?
  • I have noted the place in the contract and comments for how we can update this storage.

@nepoche nepoche requested a review from AhmedKorim June 22, 2021 17:37
@nepoche nepoche force-pushed the add-beresheet-mixers branch from 44a3466 to 4e87984 Compare June 22, 2021 18:27
@AhmedKorim
Copy link
Copy Markdown
Contributor

@nepoche are we mergin this or it was just a plaground?

Base automatically changed from add-beresheet-mixers to master June 22, 2021 20:38
@drewstone
Copy link
Copy Markdown
Contributor

drewstone commented Jun 23, 2021 via email

@drewstone
Copy link
Copy Markdown
Contributor

I suggest renaming these files too tbh. evm-chain-storage.interface.ts is a mouthful. What's the point of naming things like this?

Also, we're mixing camel case named files WebbProvider, SettingsManager, with hyphen delineated files. Lets stick to one...

I vote camelcasing. My suggestion is:

  • Create a folder packages/apps/src/configs/storages/evm/
  • Name the chain storage interface evm/IChainStorage.ts or evm/IStorage.ts
  • Name the storage implementation evm/storage.ts.

gasLimit: 6000000,
gasPrice: utils.toWei('1', 'gwei'),
value: '0x16345785D8A0000',
value: await this.denomination,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I don't know much about getters but why are we awaiting this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes a call to the RPC to read the denomination from the contract deployed on the evm. We need to wait for the RPC response.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, so this is mostly to generalise over Substrate chains and EVM, since we get denomination info often asynchronously. Good stuff!

}
const address = JSON.parse(data).contractsAddresses;
return {
nativeAnchor: new EvmChainStorage(address),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this currently a nativeAnchor because the only mixers we currently have supported in the dApp are native? I suppose we'll want to plan accordingly for ERC20 supported mixers. Might be worth updating this now, thoughts?

size: 0.1,
address: '0x876eCe69618e8E8dd743250B036785813824D2D7',
symbol: 'ETH',
syncedBlock: 120000, // should be hardcoded to deployed block number
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't know what syncedBlock means. This should err on the side of being as verbose as needed. Is this the latest synced block? If so, lets call it, latestSyncedBlock or lastSyncedBlock or lastQueriedBlock, etc.

I think we should also add another parameter for createdAtBlock to indicate the block at which these mixers were created. This way, for new clients, we can begin fetching events immediately from the point they were created rather than before ever, mistakenly

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree the field can be named something more descriptive like lastQueriedBlock.

I think that these EvmChainStorage objects will be passed default values as params to the constructor. Therefore, the lastQueriedBlock can pass the deployed block number, and new clients will only ever start querying from the deployed block. In the constructor, we can read from the localStorage to determine if the client has anything in storage for the particular mixer.

Comment thread packages/apps/src/configs/storages/evm-storage.ts
@@ -0,0 +1,22 @@
import { MixerSize } from '@webb-dapp/react-environment';

export class EvmChainStorage {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this class should be renamed to EvmChainMixerInfo. This is because most of the fields inside of this class should not be dealing with storage.

@nepoche nepoche closed this Jun 25, 2021
@nepoche nepoche deleted the add-leaves-EvmStorage branch July 28, 2021 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants