Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6a3ebe1
Re-apply warp precompile interface changes
aaronbuchwald Feb 22, 2023
9474829
Address nits
aaronbuchwald Feb 22, 2023
0d2c92b
Merge branch 'master' into precompile-pre-post-handling
aaronbuchwald Feb 23, 2023
29277c5
Separate predicate storage slot preparation into separate function in…
aaronbuchwald Feb 23, 2023
83036b7
fix lint
aaronbuchwald Feb 23, 2023
7e10491
improve miner enforcePredicates comment
aaronbuchwald Feb 23, 2023
dcfd120
Merge branch 'master' into precompile-pre-post-handling
aaronbuchwald Feb 23, 2023
584bcaa
Add HashSliceToBytes test case for empty slice
aaronbuchwald Feb 23, 2023
73aee4b
Address comments
aaronbuchwald Feb 27, 2023
2eff72e
Address comments WIP
aaronbuchwald Feb 27, 2023
e3c0899
Pre+post handling diff for shared mem precompile
Feb 27, 2023
cd79963
Separate proposer and general precompile predicates
aaronbuchwald Mar 7, 2023
be31bea
Update ShouldVerifyWithContext to return true iff proposer predicate …
aaronbuchwald Mar 7, 2023
67b7f7c
Add checkPredicates unit test
aaronbuchwald Mar 7, 2023
0d4ad9f
Merge branch 'master' into precompile-pre-post-handling
aaronbuchwald Mar 7, 2023
cde76df
Merge branch 'precompile-pre-post-handling' into precompile-pre-post-…
aaronbuchwald Mar 7, 2023
ffdda86
Update .gitignore
aaronbuchwald Mar 7, 2023
e6d6d78
goimports
aaronbuchwald Mar 7, 2023
794122d
update
aaronbuchwald Mar 7, 2023
eb2bb88
goimports config
aaronbuchwald Mar 7, 2023
2edac77
Address PR review comments and improve comments
aaronbuchwald Mar 7, 2023
15bcbe8
Merge branch 'master' into precompile-pre-post-handling
aaronbuchwald Mar 15, 2023
485ed59
Fix typo
aaronbuchwald Mar 15, 2023
5fa5bb5
Address PR comments
aaronbuchwald Mar 16, 2023
67116e0
Add rules into PrepareAccessList
aaronbuchwald Mar 16, 2023
972e486
Only copy bytes in preparePredicates if predicate precompile is active
aaronbuchwald Mar 16, 2023
9d5246c
Merge branch 'master' into precompile-pre-post-handling
aaronbuchwald Mar 16, 2023
336f0cc
Address PR comments
aaronbuchwald Mar 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address comments
  • Loading branch information
aaronbuchwald committed Feb 27, 2023
commit 73aee4bf481cebe836e124b562e68de273bdee4e
2 changes: 1 addition & 1 deletion core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ func (db *StateDB) ForEachStorage(addr common.Address, cb func(key, value common

// copyPredicateStorageSlots creates a deep copy of the provided predicateStorageSlots map.
func copyPredicateStorageSlots(predicateStorageSlots map[common.Address][]byte) map[common.Address][]byte {
res := make(map[common.Address][]byte)
res := make(map[common.Address][]byte, len(predicateStorageSlots))
for address, slots := range predicateStorageSlots {
res[address] = common.CopyBytes(slots)
}
Expand Down
17 changes: 12 additions & 5 deletions precompile/contract/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,30 @@ type StatefulPrecompiledContract interface {

// PredicateContext provides context to stateful precompile predicates
type PredicateContext struct {
SnowCtx *snow.Context
SnowCtx *snow.Context
// Note: ProposerVMBlockCtx may be nil if the Snowman Consensus Engine calls BuildBlock or Verify
// instead of BuildBlockWithContext or VerifyWithContext.
// In this case, it is up to the precompile to determine if a nil ProposerVMBlockCtx is valid.
ProposerVMBlockCtx *block.Context
}

// Predicater is an optional interface for StatefulPrecompiledContracts to implement.
// If implemented, the predicate will be enforced on every transaction in a block, prior to the block's execution.
// If VerifyPredicate returns an error, the block will fail verification with no further processing.
// WARNING: this is not intended to be used for custom precompiles. Backwards compatibility with custom precompiles that
// use the Predicater interface will not be supported.
// Note: ProposerVMBlockCtx may be nil if the engine does not specify it. In this case,
// it's up to the precompile to determine if a nil ProposerVMBlockCtx is valid.
// WARNING: If you are implementing a custom precompile, beware that subnet-evm
// will not maintain backwards compatibility of this interface and your code should not
// rely on this. Designed for use only by precompiles that ship with subnet-evm.
type Predicater interface {
VerifyPredicate(predicateContext *PredicateContext, storageSlots []byte) error
}

// Accepter is an optional interface for StatefulPrecompiledContracts to implement.
// If implemented, Accept will be called for every log with the address of the precompile when the block is accepted.
// WARNING: this is not intended to be used for custom precompiles. Backwards compatibility with custom precompiles that
// use the Accepter interface will not be supported.
// WARNING: If you are implementing a custom precompile, beware that subnet-evm
// will not maintain backwards compatibility of this interface and your code should not
// rely on this. Designed for use only by precompiles that ship with subnet-evm.
type Accepter interface {
Accept(txHash common.Hash, logIndex int, topics []common.Hash, logData []byte) error

Choose a reason for hiding this comment

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

From my understanding, Accept should also take *SnowCtx so it can gain access to the shared memory.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I'd prefer to modify this as needed when the precompile that uses it goes in because I want to add a Backend interface that provides all of the necessary functionality instead of adding one-offs for everything.

}
Expand Down