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

Update to Cadence v1.2.1 #623

Merged
merged 7 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
20 changes: 10 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ require (
github.com/cockroachdb/pebble v1.1.1
github.com/goccy/go-json v0.10.2
github.com/hashicorp/golang-lru/v2 v2.0.7
github.com/onflow/atree v0.8.0-rc.6
github.com/onflow/cadence v1.0.0
github.com/onflow/flow-go v0.38.0-preview.0.0.20241007124218-3602aeb7dfec
github.com/onflow/flow-go-sdk v1.0.0
github.com/onflow/atree v0.8.0
github.com/onflow/cadence v1.2.1
github.com/onflow/flow-go v0.38.0-preview.0.0.20241022154145-6a254edbec23
github.com/onflow/flow-go-sdk v1.2.2
github.com/onflow/flow/protobuf/go/flow v0.4.7
github.com/onflow/go-ethereum v1.14.7
github.com/prometheus/client_golang v1.18.0
Expand Down Expand Up @@ -136,12 +136,12 @@ require (
github.com/multiformats/go-varint v0.0.7 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/onflow/crypto v0.25.2 // indirect
github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.1 // indirect
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.1 // indirect
github.com/onflow/flow-ft/lib/go/contracts v1.0.0 // indirect
github.com/onflow/flow-ft/lib/go/templates v1.0.0 // indirect
github.com/onflow/flow-nft/lib/go/contracts v1.2.1 // indirect
github.com/onflow/flow-nft/lib/go/templates v1.2.0 // indirect
github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.0 // indirect
github.com/onflow/flow-core-contracts/lib/go/templates v1.4.0 // indirect
github.com/onflow/flow-ft/lib/go/contracts v1.0.1 // indirect
github.com/onflow/flow-ft/lib/go/templates v1.0.1 // indirect
github.com/onflow/flow-nft/lib/go/contracts v1.2.2 // indirect
github.com/onflow/flow-nft/lib/go/templates v1.2.1 // indirect
github.com/onflow/sdks v0.6.0-preview.1 // indirect
github.com/onsi/gomega v1.18.1 // indirect
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
Expand Down
2,077 changes: 20 additions & 2,057 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion services/ingestion/subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"errors"
"fmt"

"github.com/onflow/cadence/runtime/common"
"github.com/onflow/cadence/common"
"github.com/onflow/flow-go/fvm/evm/events"

"github.com/onflow/flow-evm-gateway/models"
Expand Down
23 changes: 12 additions & 11 deletions tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ go 1.22

require (
github.com/goccy/go-json v0.10.2
github.com/onflow/cadence v1.0.0
github.com/onflow/cadence v1.2.1
github.com/onflow/crypto v0.25.2
github.com/onflow/flow-emulator v1.0.1
github.com/onflow/flow-emulator v1.1.0
github.com/onflow/flow-evm-gateway v0.0.0-20240201154855-4d4d3d3f19c7
github.com/onflow/flow-go v0.38.0-preview.0.0.20241007124218-3602aeb7dfec
github.com/onflow/flow-go-sdk v1.0.0
github.com/onflow/flow-go v0.38.0-preview.0.0.20241022154145-6a254edbec23
github.com/onflow/flow-go-sdk v1.2.2
github.com/onflow/go-ethereum v1.14.7
github.com/rs/zerolog v1.33.0
github.com/stretchr/testify v1.9.0
Expand Down Expand Up @@ -146,14 +146,15 @@ require (
github.com/multiformats/go-multistream v0.5.0 // indirect
github.com/multiformats/go-varint v0.0.7 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/onflow/atree v0.8.0-rc.6 // indirect
github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.1 // indirect
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.1 // indirect
github.com/onflow/flow-ft/lib/go/contracts v1.0.0 // indirect
github.com/onflow/flow-ft/lib/go/templates v1.0.0 // indirect
github.com/onflow/flow-nft/lib/go/contracts v1.2.1 // indirect
github.com/onflow/flow-nft/lib/go/templates v1.2.0 // indirect
github.com/onflow/atree v0.8.0 // indirect
github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.0 // indirect
github.com/onflow/flow-core-contracts/lib/go/templates v1.4.0 // indirect
github.com/onflow/flow-ft/lib/go/contracts v1.0.1 // indirect
github.com/onflow/flow-ft/lib/go/templates v1.0.1 // indirect
github.com/onflow/flow-nft/lib/go/contracts v1.2.2 // indirect
github.com/onflow/flow-nft/lib/go/templates v1.2.1 // indirect
github.com/onflow/flow/protobuf/go/flow v0.4.7 // indirect
github.com/onflow/nft-storefront/lib/go/contracts v1.0.0 // indirect
github.com/onflow/sdks v0.6.0-preview.1 // indirect
github.com/onflow/wal v1.0.2 // indirect
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
Expand Down
2,020 changes: 24 additions & 1,996 deletions tests/go.sum

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions tests/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,13 @@ func Test_EthClientTest(t *testing.T) {
ethClient, err := ethclient.Dial("http://127.0.0.1:8545")
require.NoError(t, err)

blockNumber, err := ethClient.BlockNumber(context.Background())
ctx = context.Background()
blockNumber, err := ethClient.BlockNumber(ctx)
require.NoError(t, err)
assert.Equal(t, uint64(3), blockNumber)

block, err := ethClient.BlockByNumber(context.Background(), big.NewInt(3))
block, err := ethClient.BlockByNumber(ctx, big.NewInt(int64(blockNumber)))
require.NoError(t, err)
assert.Equal(t, big.NewInt(3), block.Number())
assert.Equal(t, big.NewInt(int64(blockNumber)), block.Number())
}

func Test_CloudKMSConcurrentTransactionSubmission(t *testing.T) {
Expand Down
18 changes: 14 additions & 4 deletions tests/web3js/build_evm_state_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ const web3 = conf.web3

it('should handle a large number of EVM interactions', async () => {
let latest = await web3.eth.getBlockNumber()
assert.equal(latest, 2n)
let expectedBlockHeight = conf.startBlockHeight
assert.equal(latest, expectedBlockHeight)

let eoaCount = 20
let accounts = []
Expand Down Expand Up @@ -37,12 +38,15 @@ it('should handle a large number of EVM interactions', async () => {

accounts.push(receiver)
}
// Add 20 to the expected block height, as we did 20 transactions,
// which formed 20 blocks.
expectedBlockHeight += 20n

let senderBalance = await web3.eth.getBalance(conf.eoa.address)
assert.equal(senderBalance, 1999999999937000000n)

latest = await web3.eth.getBlockNumber()
assert.equal(latest, 22n)
assert.equal(latest, expectedBlockHeight)

// Add some calls to test historic heights, for balance and nonce
let randomEOA = randomItem(accounts)
Expand Down Expand Up @@ -85,9 +89,12 @@ it('should handle a large number of EVM interactions', async () => {
assert.equal(transfer.receipt.to, receiver.address)
}
}
// Add 60 to the expected block height, as we did 60 transactions,
// which formed 60 blocks.
expectedBlockHeight += 60n

latest = await web3.eth.getBlockNumber()
assert.equal(latest, 82n)
assert.equal(latest, expectedBlockHeight)

// Add some calls to test historic heights, for balance and nonce
randomEOABalance = await web3.eth.getBalance(randomEOA.address, latest)
Expand Down Expand Up @@ -133,9 +140,12 @@ it('should handle a large number of EVM interactions', async () => {
})
assert.equal(res.receipt.status, conf.successStatus)
}
// Add 60 to the expected block height, as we did 60 transactions,
// which formed 60 blocks.
expectedBlockHeight += 60n

latest = await web3.eth.getBlockNumber()
assert.equal(latest, 142n)
assert.equal(latest, expectedBlockHeight)

// Add calls to verify correctness of eth_estimateGas on historical heights
let storeData = deployed.contract.methods.store(0).encodeABI()
Expand Down
9 changes: 4 additions & 5 deletions tests/web3js/config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
const { Web3 } = require('web3')

const web3 = new Web3("http://127.0.0.1:8545")
const web3 = new Web3('http://127.0.0.1:8545')

module.exports = {
web3: web3,
eoa: web3.eth.accounts.privateKeyToAccount("0xf6d5333177711e562cabf1f311916196ee6ffc2a07966d9d4628094073bd5442"), // eoa is 0xfacf71692421039876a5bb4f10ef7a439d8ef61e
eoa: web3.eth.accounts.privateKeyToAccount('0xf6d5333177711e562cabf1f311916196ee6ffc2a07966d9d4628094073bd5442'), // eoa is 0xfacf71692421039876a5bb4f10ef7a439d8ef61e
fundedAmount: 5.0,
startBlockHeight: 2n, // start block height after setup accounts
coinbase: "0x658bdf435d810c91414ec09147daa6db62406379", // configured account to receive fees
startBlockHeight: 3n, // start block height after setup accounts
coinbase: '0x658bdf435d810c91414ec09147daa6db62406379', // configured account to receive fees
successStatus: 1n,
minGasPrice: 150n
}
4 changes: 2 additions & 2 deletions tests/web3js/eth_filter_endpoints_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ describe('eth_getFilterChanges', async () => {
assert.lengthOf(transactions, 2) // the last transaction is the COA transfer for gas fees
let expectedTx = {
blockHash: res.receipt.blockHash,
blockNumber: '0xc',
blockNumber: '0xd',
from: '0xFACF71692421039876a5BB4F10EF7A439D8ef61E',
gas: '0xf4240',
gasPrice: '0x96',
Expand All @@ -410,7 +410,7 @@ describe('eth_getFilterChanges', async () => {

let expectedCoaTx = {
blockHash: res.receipt.blockHash,
blockNumber: '0xc',
blockNumber: '0xd',
from: '0x0000000000000000000000030000000000000000',
gas: '0x5b04',
gasPrice: '0x0',
Expand Down
14 changes: 7 additions & 7 deletions tests/web3js/eth_non_interactive_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,12 @@ it('get block and transactions with COA interactions', async () => {
}

// get block transaction
let tx = await web3.eth.getTransactionFromBlock(2n, 0)
let tx = await web3.eth.getTransactionFromBlock(conf.startBlockHeight, 0)
assert.equal(tx.v, "0xff")
assert.equal(tx.r, "0x0000000000000000000000000000000000000000000000020000000000000000")
assert.equal(tx.s, "0x0000000000000000000000000000000000000000000000000000000000000004")

tx = await web3.eth.getTransactionFromBlock(2n, 1)
tx = await web3.eth.getTransactionFromBlock(conf.startBlockHeight, 1)
assert.equal(tx.v, "0xff")
assert.equal(tx.r, "0x0000000000000000000000000000000000000000000000010000000000000000")
assert.equal(tx.s, "0x0000000000000000000000000000000000000000000000000000000000000001")
Expand Down Expand Up @@ -314,7 +314,7 @@ it('can make batch requests', async () => {
jsonrpc: '2.0',
id: 5,
method: 'eth_getBlockTransactionCountByNumber',
params: ['0x2'],
params: ['0x3'],
}

batch.add(getBlockNumber)
Expand All @@ -327,7 +327,7 @@ it('can make batch requests', async () => {

assert.deepEqual(
results[0],
{ jsonrpc: '2.0', id: 1, result: '0x2' }
{ jsonrpc: '2.0', id: 1, result: '0x3' }
)
assert.deepEqual(
results[1],
Expand Down Expand Up @@ -378,9 +378,9 @@ it('get fee history', async () => {
response,
{
oldestBlock: 1n,
reward: [['0x96'], ['0x96']], // gas price is 150 during testing
baseFeePerGas: [0n, 0n],
gasUsedRatio: [0, 0.006205458333333334]
reward: [['0x96'], ['0x96'], ['0x96']], // gas price is 150 during testing
baseFeePerGas: [0n, 0n, 0n],
gasUsedRatio: [0, 0, 0.006205458333333334]
}
)
})
6 changes: 3 additions & 3 deletions tests/web3js/eth_revert_reason_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const helpers = require('./helpers')
const web3 = conf.web3

it('store revertReason field in transaction receipts', async () => {
let deployed = await helpers.deployContract("storage")
let deployed = await helpers.deployContract('storage')
let contractAddress = deployed.receipt.contractAddress

// make sure deploy was successful
Expand Down Expand Up @@ -43,7 +43,7 @@ it('store revertReason field in transaction receipts', async () => {

let latestHeight = await web3.eth.getBlockNumber()
let block = await web3.eth.getBlock(latestHeight)
assert.equal(block.number, 4n)
assert.equal(block.number, conf.startBlockHeight + 2n)

let revertedTx = await web3.eth.getTransactionFromBlock(latestHeight, 0)
// Give some time to the engine to ingest the latest transaction
Expand Down Expand Up @@ -77,7 +77,7 @@ it('store revertReason field in transaction receipts', async () => {

latestHeight = await web3.eth.getBlockNumber()
block = await web3.eth.getBlock(latestHeight)
assert.equal(block.number, 5n)
assert.equal(block.number, conf.startBlockHeight + 3n)

revertedTx = await web3.eth.getTransactionFromBlock(latestHeight, 0)
// Give some time to the engine to ingest the latest transaction
Expand Down
Loading