mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-08 03:51:20 +00:00
11f4978ed4
Following our previous discussion on erigon's discord, this PR requests to upstream all Otterscan modifications to erigon's repo. That decision comes after getting feedback from lots of users at events this year, and although it may introduce some friction for development, it will make integrators life easier by having all our modifications available out of box, e.g., dappnode users will get our RPCs since their official packages are built from erigon repo. I'm submitting the source-code as-is, please let me know if you think there is a better code organization. The current set of modifications comprises only new RPCs. There are some proposals for extra-stages that would add new tables, but they are still WIP and will be submitted separately in future after more testing.
61 lines
1.6 KiB
Go
61 lines
1.6 KiB
Go
package commands
|
|
|
|
import (
|
|
"context"
|
|
"math/big"
|
|
|
|
"github.com/ledgerwatch/erigon/common"
|
|
"github.com/ledgerwatch/erigon/common/hexutil"
|
|
"github.com/ledgerwatch/erigon/core/vm"
|
|
)
|
|
|
|
type OperationType int
|
|
|
|
const (
|
|
OP_TRANSFER OperationType = 0
|
|
OP_SELF_DESTRUCT OperationType = 1
|
|
OP_CREATE OperationType = 2
|
|
OP_CREATE2 OperationType = 3
|
|
)
|
|
|
|
type InternalOperation struct {
|
|
Type OperationType `json:"type"`
|
|
From common.Address `json:"from"`
|
|
To common.Address `json:"to"`
|
|
Value *hexutil.Big `json:"value"`
|
|
}
|
|
|
|
type OperationsTracer struct {
|
|
DefaultTracer
|
|
ctx context.Context
|
|
Results []*InternalOperation
|
|
}
|
|
|
|
func NewOperationsTracer(ctx context.Context) *OperationsTracer {
|
|
return &OperationsTracer{
|
|
ctx: ctx,
|
|
Results: make([]*InternalOperation, 0),
|
|
}
|
|
}
|
|
|
|
func (t *OperationsTracer) CaptureStart(env *vm.EVM, depth int, from common.Address, to common.Address, precompile bool, create bool, calltype vm.CallType, input []byte, gas uint64, value *big.Int, code []byte) {
|
|
if depth == 0 {
|
|
return
|
|
}
|
|
|
|
if calltype == vm.CALLT && value.Uint64() != 0 {
|
|
t.Results = append(t.Results, &InternalOperation{OP_TRANSFER, from, to, (*hexutil.Big)(value)})
|
|
return
|
|
}
|
|
if calltype == vm.CREATET {
|
|
t.Results = append(t.Results, &InternalOperation{OP_CREATE, from, to, (*hexutil.Big)(value)})
|
|
}
|
|
if calltype == vm.CREATE2T {
|
|
t.Results = append(t.Results, &InternalOperation{OP_CREATE2, from, to, (*hexutil.Big)(value)})
|
|
}
|
|
}
|
|
|
|
func (l *OperationsTracer) CaptureSelfDestruct(from common.Address, to common.Address, value *big.Int) {
|
|
l.Results = append(l.Results, &InternalOperation{OP_SELF_DESTRUCT, from, to, (*hexutil.Big)(value)})
|
|
}
|