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

Substate interface #939

Merged
merged 37 commits into from
Jan 22, 2024
Merged

Substate interface #939

merged 37 commits into from
Jan 22, 2024

Conversation

cabrador
Copy link
Collaborator

@cabrador cabrador commented Jan 12, 2024

Description

This PR creates TransactionData interface to unify the transaction like code.
Any transaction execution-like data should implement this interface in order to unify the code and avoid code redundancy.

Before merging this PR:

  • Nightly test of whole Aida passes (changes from substate are used)
  • Remove replace for substate in go.mod

TODOs in separate PR:
#942 - Remove setters from the interface done
#943 - Remove hard substate dependency
#944 - Use new SubstateDB
#945 - Change AidaDb type to leveldb
#947 - Use execution data inside processor

Type of change

  • New feature (non-breaking change which adds functionality)
  • Refactoring (changes that do NOT affect functionality)

Copy link
Collaborator

@b-scholz b-scholz left a comment

Choose a reason for hiding this comment

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

Please provide unit test cases for each adapter (old_substate_account/substate_account).
Also, there are some methods in the interface definition that require unit tests (equal and stringify methods). Finally, can you make sure that the new interface does not impose a performance penalty (e.g. measure the runtime before and after your change for checking substate execution). Great job!

executor/transaction/account.go Outdated Show resolved Hide resolved
executor/transaction/alloc.go Outdated Show resolved Hide resolved
executor/transaction/env.go Outdated Show resolved Hide resolved
executor/transaction/result.go Outdated Show resolved Hide resolved
executor/transaction/account.go Outdated Show resolved Hide resolved
executor/transaction/account.go Outdated Show resolved Hide resolved
executor/transaction/alloc.go Outdated Show resolved Hide resolved
executor/transaction/alloc.go Outdated Show resolved Hide resolved
executor/transaction/result.go Outdated Show resolved Hide resolved
@cabrador cabrador force-pushed the petr/substate-interface branch from 930a63f to 7e1f9ff Compare January 16, 2024 04:21
@wsodsong
Copy link
Collaborator

We have mixed uses of ethereum/common and substate/common type. I suggest that we have an independent module for common and types. This will be used by Aida and substate. ethereum/common will only be used in state/geth.go. This is an action item for future work.

cmd/aida-vm-sdb/run_tx_generator.go Outdated Show resolved Hide resolved
executor/transaction/account.go Outdated Show resolved Hide resolved
executor/transaction/receipt.go Outdated Show resolved Hide resolved
executor/transaction/block_environment.go Outdated Show resolved Hide resolved
executor/transaction/account.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@wsodsong wsodsong left a comment

Choose a reason for hiding this comment

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

Regarding file names, since the file is under substate package. I suggest rename them to
substate_alloc.go -> world_state.go or substate_world_state.go
substate_env -> block_environment.go or substate_block_env.go
substate_result -> reciept.go or substate_reciept.go

executor/transaction/validation_data.go Outdated Show resolved Hide resolved
executor/transaction/validation_data.go Outdated Show resolved Hide resolved
executor/transaction/validation_data.go Outdated Show resolved Hide resolved
executor/transaction/transaction_data.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@wsodsong wsodsong left a comment

Choose a reason for hiding this comment

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

Please check txcontact replace in comments. Some doesn't make sense.

cmd/util-db/db/lachesis-update.go Outdated Show resolved Hide resolved
cmd/util-db/db/lachesis-update.go Outdated Show resolved Hide resolved
cmd/util-updateset/updateset/generate.go Outdated Show resolved Hide resolved
cmd/util-updateset/updateset/generate.go Outdated Show resolved Hide resolved
executor/executor.go Outdated Show resolved Hide resolved
executor/executor.go Outdated Show resolved Hide resolved
txcontext/context.go Outdated Show resolved Hide resolved
txcontext/context.go Outdated Show resolved Hide resolved
txcontext/context.go Outdated Show resolved Hide resolved
txcontext/context.go Outdated Show resolved Hide resolved
@cabrador cabrador requested a review from b-scholz January 18, 2024 07:55
@cabrador cabrador force-pushed the petr/substate-interface branch from a27af1f to ff9dd19 Compare January 18, 2024 08:35
@cabrador cabrador marked this pull request as ready for review January 18, 2024 09:40
Comment on lines 267 to 277
getHash := func(num uint64) common.Hash {
if inputEnv.BlockHashes == nil {
*hashError = fmt.Errorf("getHash(%d) invoked, no blockhashes provided", num)
return common.Hash{}
}
h, ok := inputEnv.BlockHashes[num]
if !ok {
*hashError = fmt.Errorf("getHash(%d) invoked, blockhash for that block not provided", num)
}
return h
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Note that this getHash function returns common.Hash{} when Env.BlockHashes is nil. The function inputEnv.GetBlockHash doesn't seem to handle this.

Copy link
Collaborator Author

@cabrador cabrador Jan 19, 2024

Choose a reason for hiding this comment

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

I have brought back the hash error

executor/substate_provider.go Outdated Show resolved Hide resolved
profile/blockprofile/context_test.go Outdated Show resolved Hide resolved
txcontext/substate/newsubstate/substate.go Outdated Show resolved Hide resolved
stochastic/replay.go Outdated Show resolved Hide resolved
txcontext/substate/substate.go Outdated Show resolved Hide resolved
utils/prime_ctx.go Outdated Show resolved Hide resolved
@cabrador cabrador requested a review from wsodsong January 19, 2024 04:45
Copy link
Collaborator

@wsodsong wsodsong left a comment

Choose a reason for hiding this comment

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

Looks good! Let's do follow up items in later PRs.

Copy link
Collaborator

@b-scholz b-scholz left a comment

Choose a reason for hiding this comment

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

Please can you double-check your comments? You may have replaced strings too eagerly (transaction to tx / txcontext/ etc.). Also please add some comments to your unit tests.
Great!

executor/extension/statedb/temporary_archive_prepper.go Outdated Show resolved Hide resolved
executor/extension/validator/rpc_comparator_test.go Outdated Show resolved Hide resolved
rpc/execute.go Outdated Show resolved Hide resolved
txcontext/substate/account_test.go Show resolved Hide resolved
@cabrador cabrador merged commit 387ce8e into develop Jan 22, 2024
1 check passed
@wsodsong wsodsong deleted the petr/substate-interface branch April 18, 2024 09:15
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