-
Notifications
You must be signed in to change notification settings - Fork 13
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
test: check witness when contract creation fails #333
test: check witness when contract creation fails #333
Conversation
gspec = &Genesis{ | ||
Config: config, | ||
Alloc: GenesisAlloc{ | ||
coinbase: GenesisAccount{ | ||
Balance: big.NewInt(1000000000000000000), // 1 ether | ||
Nonce: 0, | ||
}, | ||
account1: GenesisAccount{ | ||
Balance: big.NewInt(1000000000000000000), // 1 ether | ||
Nonce: 0, | ||
}, | ||
account2: GenesisAccount{ | ||
Balance: big.NewInt(1000000000000000000), // 1 ether | ||
Nonce: 1, | ||
}, | ||
}, | ||
} | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these values are chosen to simulate the state of kaustinen on blocks 13 and 16, since that's what these problematic txs are taken from.
gen.AddTx(&tx3) | ||
} else { | ||
var tx types.Transaction | ||
txpayload := common.Hex2Bytes("01f8d683010f2c028443ad7d0e830186a08080b880b00e7fa3c849dce891cce5fae8a4c46cbb313d6aec0c0ffe7863e05fb7b22d4807674c6055527ffbfcb0938f3e18f7937aa8fa95d880afebd5c4cec0d85186095832d03c85cf8a60755260ab60955360cf6096536066609753606e60985360fa609953609e609a53608e609b536024609c5360f6609d536072609e5360a4609fc080a08fc6f7101f292ff1fb0de8ac69c2d320fbb23bfe61cf327173786ea5daee6e37a044c42d91838ef06646294bf4f9835588aee66243b16a66a2da37641fae4c045f") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
immediately reverts.
func GetTreeKeyStorageSlot(address []byte, storageKey *uint256.Int) []byte { | ||
pos := storageKey.Clone() | ||
if storageKey.Cmp(codeStorageDelta) < 0 { | ||
pos.Add(HeaderStorageOffset, storageKey) | ||
} else { | ||
pos.Add(MainStorageOffset, storageKey) | ||
} | ||
treeIndex := new(uint256.Int).Div(pos, VerkleNodeWidth) | ||
|
||
// calculate the sub_index, i.e. the index in the stem tree. | ||
// Because the modulus is 256, it's the last byte of treeIndex | ||
subIndexMod := new(uint256.Int).Mod(pos, VerkleNodeWidth) | ||
var subIndex byte | ||
if len(subIndexMod) != 0 { | ||
// uint256 is broken into 4 little-endian quads, | ||
// each with native endianness. Extract the least | ||
// significant byte. | ||
subIndex = byte(subIndexMod[0]) | ||
} | ||
return GetTreeKey(address, treeIndex, subIndex) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is not used anywhere, and is buggy. Removing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not buggy, as it turns out, but still unnecessary
trie/utils/verkle.go
Outdated
// Get the new offset since we now know that we are above 64. | ||
pos.Sub(&pos, codeStorageDelta) | ||
suffix := byte(pos[0] & 0xFF) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
subtract the code storage from the offset before adding the main storage offset value. Get the last byte, because what follows is a right shift.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, left a small nit comment.
core/state_processor_test.go
Outdated
blockchain, _ := NewBlockChain(bcdb, nil, gspec, nil, beacon.New(ethash.NewFaker()), vm.Config{}, nil, nil) | ||
defer blockchain.Stop() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like these two lines can be removed, since blockchain
isn't used in this test.
The suffix value for a slot was not computed properly: 64 weren't subtracted in order to account for the first 64 slots being in the account header.This PR also adds tests that verify the content of the produced witness, and ensure that the main storage slots will end up where they should. These tests add several transactions taken from Kaustinen (really
verkle-gen-devnet-2
), which are contract creation transactions that fail during the execution of the init code. The first two of these transactions are in the first block, and perform aSSTORE
before the init code reverts. This means that these values should end up in the witness. The third, in the second block, immediately reverts and so the witness should show no proof of absence at code locations.