Skip to content
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

Use upstream account packages #678

Merged
merged 4 commits into from
Nov 6, 2024
Merged

Use upstream account packages #678

merged 4 commits into from
Nov 6, 2024

Conversation

darioush
Copy link
Collaborator

@darioush darioush commented Oct 24, 2024

Why this should be merged

Less code to maintain.

How this works

Since we took types.Transaction, some more interfaces can be unified, and we can drop this code from our codebase.

How this was tested

CI

@darioush darioush changed the base branch from master to use-libevm October 24, 2024 23:23
@darioush darioush force-pushed the use-libevm-account branch 2 times, most recently from e102e7c to 79bcc2d Compare October 24, 2024 23:28
@darioush darioush changed the title Use libevm account Use upstream account packages Oct 24, 2024
@darioush darioush marked this pull request as ready for review October 24, 2024 23:44
@darioush darioush requested review from ceyonur and a team as code owners October 24, 2024 23:44
@@ -426,7 +426,7 @@ type syncVMSetup struct {
serverAppSender *enginetest.Sender

includedAtomicTxs []*Tx
fundedAccounts map[*keystore.Key]*types.StateAccount
fundedAccounts map[*utils.Key]*types.StateAccount
Copy link
Contributor

Choose a reason for hiding this comment

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

Since one of the fields in utils.Key is a pointer, this doesn't guarantee uniqueness. Is that ok?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It seems okay as randomly generated keys would likely not be duplicate and this change does not modify this part of the behavior

@@ -116,7 +116,7 @@ func fillAccountsWithStorage(t *testing.T, serverDB ethdb.Database, serverTrieDB
// returns the new trie root and a map of funded keys to StateAccount structs.
func FillAccountsWithOverlappingStorage(
t *testing.T, trieDB *triedb.Database, root common.Hash, numAccounts int, numOverlappingStorageRoots int,
) (common.Hash, map[*keystore.Key]*types.StateAccount) {
) (common.Hash, map[*utils.Key]*types.StateAccount) {
Copy link
Contributor

Choose a reason for hiding this comment

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

See earlier re unique keys.

PrivateKey *ecdsa.PrivateKey
}

func NewKey(rand io.Reader) (*Key, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why accept the reader if it's always crypto/rand.Reader (at least in the code I can see)? I understand wanting stable keys in tests, but it doesn't look like that's being done and this risks someone may accidentally pass a non-secure source.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this is fine since it's the same in the existing code it was adapted from and also in ecdsa.GenerateKey
Additionally it's recommended to receive interfaces in golang as opposed to concrete types

Copy link
Contributor

Choose a reason for hiding this comment

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

receive interfaces in golang as opposed to concrete types

I mean not receive anything at all and just use crypto/rand.Reader inside the function. I'm happy with whatever you decide here—consider my original question as just a prompt to spur thinking.

@darioush darioush merged commit a203ea6 into use-libevm Nov 6, 2024
6 checks passed
@darioush darioush deleted the use-libevm-account branch November 6, 2024 16:23
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.

2 participants