Skip to content

Commit

Permalink
Merge branch 'main' into gregor/create-multi-key
Browse files Browse the repository at this point in the history
  • Loading branch information
devbugging authored May 17, 2024
2 parents 806ea5e + 313d201 commit b1adab6
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 25 deletions.
32 changes: 19 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@

# BUILD BIN

FROM golang:1.22.0 as builder
FROM golang:1.20.0 as app-builder

# Build the app binary in /app
WORKDIR /app

# Install go modules
WORKDIR /flow-evm-gateway
COPY go.* ./
COPY . ./

RUN go mod download
RUN go mod verify
RUN CGO_ENABLED=1 go build -o evm-gateway ./cmd/main/main.go
RUN chmod a+x evm-gateway
RUN chmod a+x ./scripts/run.sh

# Build binary
RUN CGO_ENABLED=1 go build -o bin ./cmd/main/main.go
RUN chmod a+x bin

# RUN APP

FROM debian:latest

WORKDIR /flow-evm-gateway
# ENV MNT_DIR /flow-evm-gateway/db

RUN apt-get update
# RUN apt-get install -y nfs-common
COPY --from=builder /flow-evm-gateway/evm-gateway /flow-evm-gateway/evm-gateway
COPY --from=builder /flow-evm-gateway/previewnet-keys.json /flow-evm-gateway/previewnet-keys.json
COPY --from=builder /flow-evm-gateway/scripts/run.sh /flow-evm-gateway/run.sh

COPY --from=app-builder /app/bin /flow-evm-gateway/app
COPY --from=app-builder /app/previewnet-keys.json /flow-evm-gateway/previewnet-keys.json

EXPOSE 8545
WORKDIR /flow-evm-gateway
ENTRYPOINT ["sh", "run.sh"]

ENTRYPOINT ["/flow-evm-gateway/app"]
12 changes: 12 additions & 0 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,18 @@ func (b *BlockChainAPI) prepareBlockResponse(
Timestamp: hexutil.Uint64(block.Timestamp),
}

// todo remove after previewnet, temp fix to mock some of the timestamps
if block.Timestamp == 0 {
first := uint64(1715189257)
blockTime := uint64(200)
firstRecordedTimestampBlock := uint64(5493)

diff := firstRecordedTimestampBlock - block.Height
timestamp := first - blockTime*diff

blockResponse.Timestamp = hexutil.Uint64(timestamp)
}

transactions, err := b.fetchBlockTransactions(ctx, block)
if err != nil {
return nil, err
Expand Down
8 changes: 0 additions & 8 deletions scripts/run.sh

This file was deleted.

10 changes: 9 additions & 1 deletion services/requester/requester.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
gethCore "github.com/onflow/go-ethereum/core"
"github.com/onflow/go-ethereum/core/types"
gethVM "github.com/onflow/go-ethereum/core/vm"
"github.com/onflow/go-ethereum/params"
"github.com/rs/zerolog"
"golang.org/x/sync/errgroup"

Expand Down Expand Up @@ -401,7 +402,14 @@ func (e *EVM) EstimateGas(
return 0, getErrorForCode(evmResult.ErrorCode)
}

return evmResult.GasConsumed, nil
// This minimum gas availability is needed for:
// https://github.com/onflow/go-ethereum/blob/master/core/vm/operations_acl.go#L29-L32
// Note that this is not actually consumed in the end.
// TODO: Consider moving this to `EVM.dryRun`, if we want the
// fix to also apply for the EVM API, on Cadence side.
gasConsumed := evmResult.GasConsumed + params.SstoreSentryGasEIP2200 + 1

return gasConsumed, nil
}

func (e *EVM) GetCode(
Expand Down
22 changes: 19 additions & 3 deletions tests/web3js/eth_deploy_contract_and_interact_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ it('deploy contract and interact', async() => {
result = await web3.eth.call({to: contractAddress, data: callRetrieve}, "latest")
assert.equal(result, initValue)

// update the value on the contract
let newValue = 100
let updateData = deployed.contract.methods.store(newValue).encodeABI()
// set the value on the contract, to its current value
let updateData = deployed.contract.methods.store(initValue).encodeABI()
// store a value in the contract
let res = await helpers.signAndSend({
from: conf.eoa.address,
Expand All @@ -57,6 +56,23 @@ it('deploy contract and interact', async() => {
})
assert.equal(res.receipt.status, conf.successStatus)

// check the new value on contract
result = await web3.eth.call({to: contractAddress, data: callRetrieve}, "latest")
assert.equal(result, initValue)

// update the value on the contract
newValue = 100
updateData = deployed.contract.methods.store(newValue).encodeABI()
// store a value in the contract
res = await helpers.signAndSend({
from: conf.eoa.address,
to: contractAddress,
data: updateData,
value: '0',
gasPrice: '0',
})
assert.equal(res.receipt.status, conf.successStatus)

// check the new value on contract
result = await web3.eth.call({to: contractAddress, data: callRetrieve}, "latest")
assert.equal(result, newValue)
Expand Down

0 comments on commit b1adab6

Please sign in to comment.