Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
fix: various build fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
atanmarko committed Sep 15, 2023
1 parent 1bc41d0 commit 526a3a2
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 40 deletions.
4 changes: 2 additions & 2 deletions consensus/ibft/signer/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func Test_wrapCommitHash(t *testing.T) {
assert.Equal(t, expectedOutput, output)
}

//nolint
// nolint
func Test_getOrCreateECDSAKey(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -184,7 +184,7 @@ func Test_getOrCreateECDSAKey(t *testing.T) {
}
}

//nolint
// nolint
func Test_getOrCreateBLSKey(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ require (
github.com/quasilyte/go-ruleguard v0.4.0
github.com/quasilyte/go-ruleguard/dsl v0.3.22
github.com/sethvargo/go-retry v0.2.4
github.com/topos-protocol/go-topos-sequencer-client v0.0.0-20230719150134-37636f549da4
golang.org/x/sync v0.3.0
google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98
gopkg.in/DataDog/dd-trace-go.v1 v1.54.1
Expand Down Expand Up @@ -97,7 +98,6 @@ require (
github.com/richardartoul/molecule v1.0.1-0.20221107223329-32cfee06a052 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
github.com/secure-systems-lab/go-securesystemslib v0.7.0 // indirect
github.com/topos-protocol/go-topos-sequencer-client v0.0.0-20230719150134-37636f549da4 // indirect
go.uber.org/dig v1.16.1 // indirect
go.uber.org/fx v1.19.2 // indirect
golang.org/x/exp v0.0.0-20230725012225-302865e7556b // indirect
Expand Down
16 changes: 8 additions & 8 deletions jsonrpc/eth_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (

"github.com/0xPolygon/polygon-edge/chain"
"github.com/0xPolygon/polygon-edge/crypto"
"github.com/0xPolygon/polygon-edge/gasprice"
"github.com/0xPolygon/polygon-edge/helper/common"
"github.com/0xPolygon/polygon-edge/helper/hex"
"github.com/0xPolygon/polygon-edge/helper/progress"
"github.com/0xPolygon/polygon-edge/prover"
"github.com/0xPolygon/polygon-edge/state"
Expand Down Expand Up @@ -112,7 +112,7 @@ var (
//Empty code hash is 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470
EmptyCodeHashBytes = []byte{197, 210, 70, 1, 134, 247, 35, 60, 146, 126, 125,
178, 220, 199, 3, 192, 229, 0, 182, 83, 202, 130, 39, 59, 123, 250, 216, 4, 93, 133, 164, 112}
EmptyCodeHash = hex.EncodeToHex(EmptyCodeHashBytes)
EmptyCodeHash = "0x" + hex.EncodeToString(EmptyCodeHashBytes)
)

// ChainId returns the chain id of the client
Expand Down Expand Up @@ -992,7 +992,7 @@ func (e *Eth) GetProverData(block BlockNumberOrHash) (interface{}, error) {
Nonce: acc.Nonce,
Balance: acc.Balance,
Root: acc.Root.String(),
CodeHash: hex.EncodeToHex(acc.CodeHash),
CodeHash: "0x" + hex.EncodeToString(acc.CodeHash),
}
}

Expand Down Expand Up @@ -1020,7 +1020,7 @@ func (e *Eth) GetProverData(block BlockNumberOrHash) (interface{}, error) {

ss := make([]string, len(storageMerkleProof))
for i, s := range storageMerkleProof {
ss[i] = hex.EncodeToHex(s)
ss[i] = "0x" + hex.EncodeToString(s)
}

storageAccesses = append(storageAccesses, prover.StorageAccess{
Expand All @@ -1041,7 +1041,7 @@ func (e *Eth) GetProverData(block BlockNumberOrHash) (interface{}, error) {

transactions := make([]string, 0)
for _, transaction := range fullBlock.Transactions {
transactions = append(transactions, hex.EncodeToHex(transaction.MarshalRLP()))
transactions = append(transactions, "0x"+hex.EncodeToString(transaction.MarshalRLP()))
}

// Receipts from this block
Expand All @@ -1061,7 +1061,7 @@ func (e *Eth) GetProverData(block BlockNumberOrHash) (interface{}, error) {
}

codeHash := crypto.Keccak256(contractCode)
contractCodes[hex.EncodeToHex(codeHash)] = hex.EncodeToHex(contractCode)
contractCodes["0x"+hex.EncodeToString(codeHash)] = "0x" + hex.EncodeToString(contractCode)
} else {
// Add empty code hash
contractCodes[EmptyCodeHash] = "0x"
Expand All @@ -1079,7 +1079,7 @@ func (e *Eth) GetProverData(block BlockNumberOrHash) (interface{}, error) {

aa := make([]string, 0)
for _, proof := range accountProof {
aa = append(aa, hex.EncodeToHex(proof))
aa = append(aa, "0x"+hex.EncodeToString(proof))
}

state = append(state, prover.ProverAccountProof{
Expand All @@ -1098,7 +1098,7 @@ func (e *Eth) GetProverData(block BlockNumberOrHash) (interface{}, error) {

zeroAccountProofArray := make([]string, 0)
for _, proof := range zeroAccountProof {
zeroAccountProofArray = append(zeroAccountProofArray, hex.EncodeToHex(proof))
zeroAccountProofArray = append(zeroAccountProofArray, "0x"+hex.EncodeToString(proof))
}

state = append(state, prover.ProverAccountProof{
Expand Down
2 changes: 1 addition & 1 deletion prover/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func ParseTraceForStorageAccess(tracesJSON []interface{}) (map[string][]structtr

for account, storage := range trace.StorageUpdates {
for storageAccess := range storage {
storageChanges[account.String()] = append(storageChanges[account.String()], storageAccess)
storageChanges[account] = append(storageChanges[account], storageAccess)
}
}
}
Expand Down
47 changes: 19 additions & 28 deletions state/runtime/tracer/structtracer/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,16 @@ type StructTracer struct {
currentMemory [][]byte
currentStack [][]*big.Int

contractAddress types.Address
contractAddress string
storageAccess []map[StorageAccess]bool
accountStorageUpdates map[types.Address]map[StorageAccess]bool
accountStorageUpdates map[string]map[StorageAccess]bool
}

func NewStructTracer(config Config) *StructTracer {
storage := make([](map[types.Address]map[types.Hash]types.Hash), 1)
storage[0] = make(map[types.Address]map[types.Hash]types.Hash)
storageAccess := make([]map[StorageAccess]bool, 1)
storageAccess[0] = make(map[StorageAccess]bool)

return &StructTracer{
Config: config,
Expand All @@ -73,7 +75,7 @@ func NewStructTracer(config Config) *StructTracer {
currentMemory: make([][]byte, 1),
currentStack: make([][]*big.Int, 1),
storageAccess: storageAccess,
accountStorageUpdates: make(map[types.Address]map[StorageAccess]bool),
accountStorageUpdates: make(map[string]map[StorageAccess]bool),
}
}

Expand Down Expand Up @@ -301,7 +303,7 @@ func (t *StructTracer) ExecuteState(
if t.Config.EnableStorage {
if isCallOp {

contract := types.BytesToAddress(stack[len(stack)-2].Bytes())
contract := stack[len(stack)-2]
t.accountStorageUpdates[contract] = t.storageAccess[len(t.storageAccess)-1]

t.storage = t.storage[:len(t.storage)-1]
Expand All @@ -325,7 +327,7 @@ func (t *StructTracer) ExecuteState(
errStr = err.Error()
}

t.contractAddress = contractAddress
t.contractAddress = contractAddress.String()

t.logs = append(
t.logs,
Expand All @@ -346,25 +348,12 @@ func (t *StructTracer) ExecuteState(
}

type StructTraceResult struct {
Account string `json:"account"`
Failed bool `json:"failed"`
StorageUpdates map[types.Address]map[StorageAccess]bool `json:"storageUpdates"`
Gas uint64 `json:"gas"`
ReturnValue string `json:"returnValue"`
StructLogs []StructLogRes `json:"structLogs"`
}

type StructLogRes struct {
Pc uint64 `json:"pc"`
Op string `json:"op"`
Gas uint64 `json:"gas"`
GasCost uint64 `json:"gasCost"`
Depth int `json:"depth"`
Error string `json:"error,omitempty"`
Stack []string `json:"stack"`
Memory []string `json:"memory"`
Storage map[string]string `json:"storage"`
RefundCounter uint64 `json:"refund,omitempty"`
Failed bool `json:"failed"`
Gas uint64 `json:"gas"`
ReturnValue string `json:"returnValue"`
StructLogs []StructLog `json:"structLogs"`
Account string `json:"account"`
StorageUpdates map[string]map[StorageAccess]bool `json:"storageUpdates"`
}

func (t *StructTracer) GetResult() (interface{}, error) {
Expand All @@ -384,9 +373,11 @@ func (t *StructTracer) GetResult() (interface{}, error) {
storageUpdates := t.accountStorageUpdates

return &StructTraceResult{
Failed: t.err != nil,
Gas: t.consumedGas,
ReturnValue: returnValue,
StructLogs: t.logs,
Failed: t.err != nil,
Gas: t.consumedGas,
ReturnValue: returnValue,
StructLogs: t.logs,
StorageUpdates: storageUpdates,
Account: t.contractAddress,
}, nil
}

0 comments on commit 526a3a2

Please sign in to comment.