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

fix CaptureState #56

Merged
merged 9 commits into from
Mar 28, 2022
Merged
Changes from 1 commit
Commits
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
Get storage key from stack of last log.
  • Loading branch information
silathdiir committed Mar 28, 2022
commit 0fbefb19c54a2426094ad045bcd13a40e9ed7d3f
8 changes: 4 additions & 4 deletions core/vm/logger.go
Original file line number Diff line number Diff line change
@@ -206,7 +206,7 @@ func (l *StructLogger) CaptureState(pc uint64, op OpCode, gas, cost uint64, scop
l.storage[contractAddress][storageKey] = storageValue
storage = l.storage[contractAddress].Copy()

if err := traceContractProof(l, scope, extraData); err != nil {
if err := traceStorageProof(l, scope, extraData); err != nil {
log.Error("Failed to trace data", "opcode", op.String(), "err", err)
}
}
@@ -231,15 +231,15 @@ func (l *StructLogger) CaptureState(pc uint64, op OpCode, gas, cost uint64, scop
}

func (l *StructLogger) CaptureStateAfter(pc uint64, op OpCode, gas, cost uint64, scope *ScopeContext, rData []byte, depth int, err error) {
if !l.cfg.DisableStorage && op == SLOAD {
if !l.cfg.DisableStorage && op == SSTORE {
logLen := len(l.logs)
if logLen <= 0 {
log.Error("Failed to trace after_state for sstore", "err", "empty length log")
return
}

lastLog := l.logs[logLen-1]
if lastLog.Op != SLOAD {
if lastLog.Op != SSTORE {
log.Error("Failed to trace after_state for sstore", "err", "op mismatch")
return
}
@@ -249,7 +249,7 @@ func (l *StructLogger) CaptureStateAfter(pc uint64, op OpCode, gas, cost uint64,
}

contractAddress := scope.Contract.Address()
var storageKey common.Hash // TODO: how to get this?
storageKey := common.Hash(lastLog.Stack[len(lastLog.Stack)-1].Bytes32())
proof, err := getWrappedProofForStorage(l, contractAddress, storageKey)
if err != nil {
log.Error("Failed to trace after_state storage_proof for sstore", "err", err)